Vithanco

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:

  1. Document Structure: A VGL file contains zero or more vnotation blocks followed by either one vgraph or one metagraph declaration
  2. File ordering: vnotation blocks must appear before any vgraph or metagraph that references them
  3. Node IDs: Must be unique throughout the document
  4. Edge References: Edges can only reference nodes that have been declared
  5. Type Validation: Node types and edge types must be valid for the chosen notation, or will be marked as "unknown"
  6. Attributes: Can appear inline with brackets [] or as separate statements within groups
  7. Semicolons: Optional after nodes, edges, groups, and standalone attributes
  8. Quoted Strings: Used for labels and string attribute values, support escape sequences (\", \\, etc.)
  9. Comments: Single-line only, using // syntax