opensourcegames/code/grammar_listing.lark
2020-09-07 16:01:22 +02:00

25 lines
740 B
Plaintext

start: _COMMENT _HEADER entry*
entry: "##" name "[" _NUMBER "]" _NL property+
property: "-" _key ":" _values _NL
_key : /(?! ).+?(?= *:)/ // key: everything until next ":", not beginning or ending with a space
_values : [_value ("," _value)*]
_value : quoted_value | unquoted_value
quoted_value : /\".*?\"/ // with quotation marks, can contain commas
unquoted_value : /(?![ \"]).+?(?= *,| *\n)/
name: /(?! ).+?(?= +\[)/ // developer name: everything until " ["
_NUMBER: /[0-9]+/
CR : /\r/
LF : /\n/
_NL : CR? LF
WS : (" "|/\t/)+
_EL : /^$\n/m // empty new line
_COMMENT : /^\[comment\]: #.*$\n/m // [comment]: # xxx
_HEADER : /^# .+$\n/m // line staring with "# "
%ignore WS
%ignore _EL