-
Notifications
You must be signed in to change notification settings - Fork 28
VGDL Grammar
This is the formal syntax definition, but it is generally easier to understand from looking at examples.
The syntax of a game dynamics description is given in a Python-like indented format. The accompanying level descriptions are simple text strings/files where all lines have the same number of characters.
game_dynamics ::= GameType (\1 block)*
There are four possible blocks. They can appear in any order, but at most once.
block ::= sprite_block | level_block | end_block | collision_block
sprite_block ::= 'SpriteSet' (\1 sprite_node)*
sprite_node ::= sprite_leaf | sprite_internal
sprite_internal ::= category_name '>' SpriteClass? args \1 sprite_node (\1 sprite_node)+
In other words, if a sprite type is defined to have children, it must have at least two.
sprite_leaf ::= sprite_name '>' SpriteClass? args
If the leaf node does not define a SpriteClass, one of its parents must do so.
level_block ::= 'LevelMapping' (\1 char_mapping)*
char_mapping ::= char '>' (sprite_name)+
where char
is a single ASCII character. Any sprite_name
used must be defined in the sprite block.
collision_block ::= (any_name any_name '>' EffectClass args)*
any_name ::= sprite_name | category_name
Again, any sprite_name
or category_name
used must be defined in the sprite block.
end_block ::= 'TerminationSet' (\1 EndClass args)*
Grammatical categories in UpperCamelCase are not defined here, but refer to classes defined in the language-accompanying ontology, of the appropriate type. The symbol \1
denotes a line-break with a level of indentation more than its parent. Note that empty lines and anything after a comment character ('#') is ignored, so the description files can be commented at will.
args ::= (option_name'='option_value)*
Note that there is no space permitted on either side of the equal sign. This is an exception, elsewhere in the description, terms can be separated by arbitrary spacing (as long as the indentation levels match up).
The terms option_name
, sprite_name
, category_name
are regular strings. option_value
is a Python-parsable string (e.g. '0.3e4'), which can include constants or classes defined in the ontology (e.g. 'BLUE').