opensourcegames/code/grammar_entries.lark

27 lines
911 B
Plaintext

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