VGL Guide — Grammar
Estimated reading time: 2 minutes.
Grammar
Simplified BNF:
file ::= vnotation* (document | metagraph) view*
view ::= "vview" identifier label? attributes? "{" (view_rule | view_statement)* "}"
view_rule ::= ("include" | "exclude") selector ";"?
| "expand" number ";"?
selector ::= ("*" | ("node" | "group") ("type" ":")? identifier ("," identifier)*) reach?
reach ::= "+" number | "downstream" number | "upstream" number
view_statement ::= "folded"? ("node" | "group") ("type" ":")? identifier ("," identifier)*
attributes? ";"?
document ::= "vgraph" identifier ":" notation ("," extension)* label? "{" statement* "}"
metagraph ::= ("metagraph" | "metadescription") notation label? ";"?
notation ::= identifier
// a built-in notation, or a vnotation declared earlier in the file
vnotation ::= "vnotation" identifier ("extends" identifier)? "{" vnotation_body* "}"
vnotation_body ::= ("layout" ":" layout_dir ";"?)
| ("icon" identifier "[" "viewBox" ":" quoted_string ","?
"path" ":" quoted_string "]" ";"?)
| ("node" "type" ":" identifier type_attributes? ";"?)
| ("edge" "type" ":" identifier "from" ":" identifier "to" ":" identifier attributes? ";"?)
| ("group" "type" ":" identifier attributes? ";"?)
| ("qualityCheck" ":" identifier ("(" value ("," value)* ")")? ";"?)
| ("transform" ":" identifier ";"?)
| attribute
type_attributes ::= "[" ((attribute | detailed_by) (";" | ",")?)* "]"
detailed_by ::= "detailedBy" ":" "(" identifier ("," identifier)* ")"
layout_dir ::= "topToBottom" | "leftToRight" | "bottomToTop" | "rightToLeft"
extension ::= identifier // available: Annotation
statement ::= group | node | edge | attribute
group ::= "folded"? "group" identifier (":" identifier)? label? "{" statement* "}" ";"?
// the type is a group type, or a node type for a detailed node
node ::= "node" identifier ":" identifier label? attributes? ";"?
edge ::= "edge" identifier "->" identifier (":" identifier)? label? attributes? ";"?
attribute ::= identifier ":" value ";"?
attributes ::= "[" (attribute (";" | ",")?)* "]"
label ::= quoted_string
value ::= quoted_string | number | identifier
identifier ::= [a-zA-Z_][a-zA-Z0-9_.\-]*
number ::= [-]?[0-9]+(\.[0-9]+)?
quoted_string::= "\"" ([^\"\\] | "\\" .)* "\""
comment ::= "//" [^\n]*
Rules worth stating separately:
- Node ids must be unique throughout the document, and an edge may only reference nodes already declared.
- Semicolons are optional after nodes, edges, groups and standalone attributes.
- A node or edge type that is not valid for the notation is not an error: it becomes an unknown type, rendered bold red and reported as a quality warning, so a document always opens. Check the spelling.
Home