opensourcegames/code/grammar_entries.lark
2020-09-04 17:12:58 +02:00

24 lines
817 B
Plaintext

start: title _EL property+ _EL (note)? building
title: "#" /(?! ).+(?<! )/ _NL // not starting or ending with a space
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]+(?<![ \"])/ // cannot contain commas, cannot start or end with quotation mark
note: /(?![\-#]).*\n/+ // Unstructured text, not starting with - or #
building: "## Building" _NL (_EL property+)? (_EL note)? _EL* // the "building" section
_NUMBER: /[0-9]+/
CR : /\r/
LF : /\n/
_NL : CR? LF
WS : (" "|/\t/)+
_EL : /^$\n/m
%ignore WS