VGL Guide — Grammar
Estimated reading time: 1 minutes.
Grammar
Simplified BNF:
file ::= vnotation* (document | metagraph)
document ::= "vgraph" identifier ":" notation ("," extension)* label? "{" statement* "}"
metagraph ::= "metagraph" 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 ";"?)
| ("node" "type" ":" identifier attributes? ";"?)
| ("edge" "type" ":" identifier "from" ":" identifier "to" ":" identifier attributes? ";"?)
layout_dir ::= "topToBottom" | "leftToRight" | "bottomToTop" | "rightToLeft"
extension ::= identifier // available: Annotation
statement ::= group | node | edge | attribute
group ::= "group" identifier label? "{" statement* "}" ";"?
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-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