opensourcegames/code/grammar_listing.lark
2020-08-31 23:50:45 +02:00

19 lines
714 B
Plaintext

start: entry*
entry: "##" name "(" _NUMBER ")\n" property+
property: "-" _key ":" _values "\n"
_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]+(?<![ \"])/ // cannot contain commas, cannot start or end with quotation mark
name: /(?! ).+?(?= \()/ // developer name: everything until " ("
_NUMBER: /[0-9]+/
%import common.WS
%ignore WS
%ignore /^\[comment\]: #.*$\n/m // [comment]: # xxx
%ignore /^# .+$\n/m // the line starting with "# "
%ignore /^$\n/m // empty lines