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

25 lines
766 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 comment_value?) | (unquoted_value comment_value?)
quoted_value : /\".*?\"/
unquoted_value : /(?![ \"]).+?(?=,|\n| \()/
comment_value : /(?<= )\(.+?\)/
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