VGL Guide — Grammar
Estimated reading time: 2 minutes.
Grammar
The VGL grammar is defined as follows (simplified BNF notation):
file ::= vnotation* (document | metagraph)
document ::= "vgraph" identifier ":" notation ("," extension)* label? "{" statement* "}"
metagraph ::= "metagraph" notation label? ";"?
// Renders the notation itself as a diagram: each NodeType becomes a node,
// each EdgeType becomes an edge, styled per the notation. No body, no id.
// If label is omitted, it defaults to "<NotationName> Meta Model".
notation ::= identifier
// Built-in: IBIS, BBS, ImpactMapping, ConceptMap, CRT, EC, FRT, PRT, TRT, ADTree, GoalTree, CLD, DecisionTree, Timeline
// User-defined: any vnotation declared earlier in the same 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 extensions: 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]*
Key Grammar Rules:
- Document Structure: A VGL file contains zero or more
vnotationblocks followed by either onevgraphor onemetagraphdeclaration - File ordering:
vnotationblocks must appear before anyvgraphormetagraphthat references them - Node IDs: Must be unique throughout the document
- Edge References: Edges can only reference nodes that have been declared
- Type Validation: Node types and edge types must be valid for the chosen notation, or will be marked as "unknown"
- Attributes: Can appear inline with brackets
[]or as separate statements within groups - Semicolons: Optional after nodes, edges, groups, and standalone attributes
- Quoted Strings: Used for labels and string attribute values, support escape sequences (
\",\\, etc.) - Comments: Single-line only, using
//syntax
Home