2019-12-01 01:04:13 +01:00
|
|
|
# This is a Tatsu file.
|
|
|
|
# Syntax is explained at
|
|
|
|
# https://tatsu.readthedocs.io/en/stable/syntax.html
|
|
|
|
|
|
|
|
@@grammar :: Hlds
|
|
|
|
|
|
|
|
# Don't ignore any whitespace
|
|
|
|
@@whitespace :: //
|
|
|
|
|
|
|
|
@@eol_comments :: /[ \t]*#.*?$/
|
2020-01-26 23:51:29 +01:00
|
|
|
@@keyword :: single_choice multi_choice dish preset only requires except
|
2019-12-01 01:04:13 +01:00
|
|
|
|
|
|
|
|
2020-01-24 15:16:01 +01:00
|
|
|
start = [n] { @+:location } $ ;
|
2019-12-01 01:04:13 +01:00
|
|
|
|
|
|
|
location_header =
|
2020-01-26 15:30:32 +01:00
|
|
|
/={3,}/ n ~
|
2019-12-01 01:04:13 +01:00
|
|
|
id:identifier ':' s name:string
|
|
|
|
attributes:{ location_attribute }
|
2020-01-26 15:30:32 +01:00
|
|
|
[ n ]
|
|
|
|
/={3,}\n+/
|
2019-12-01 01:04:13 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
location_attribute =
|
|
|
|
n '\t' key:identifier ' ' value:string
|
|
|
|
;
|
|
|
|
|
|
|
|
location = >location_header items:{ block } ;
|
|
|
|
|
|
|
|
|
2020-01-27 00:26:51 +01:00
|
|
|
name_and_description =
|
2019-12-01 01:04:13 +01:00
|
|
|
name:/[^\n]*?(?= +-- | +:: | +€ |\n)/
|
|
|
|
[ s '--' ~ s description:/[^\n]*?(?= +:: | +€ |\n)/ ]
|
2020-01-27 00:26:51 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
attributes =
|
|
|
|
>name_and_description
|
2019-12-01 01:04:13 +01:00
|
|
|
[ s '::' {s ('{' tags+:identifier '}')} ]
|
|
|
|
[ [ s '::' ~ ] s price:price ]
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
block =
|
2020-01-26 23:51:29 +01:00
|
|
|
| dish_block
|
2019-12-01 01:04:13 +01:00
|
|
|
| choice_block
|
|
|
|
;
|
|
|
|
|
2020-01-26 23:51:29 +01:00
|
|
|
dish_block =
|
|
|
|
'dish' s ~
|
2019-12-01 01:04:13 +01:00
|
|
|
id:identifier ':' s >attributes
|
|
|
|
n
|
|
|
|
choices:{ indent_choice_block }
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
choice_entry = id:identifier ':' s >attributes ;
|
|
|
|
|
|
|
|
noindent_choice_entry = n '\t' >choice_entry ;
|
|
|
|
indent_choice_entry = n '\t\t' >choice_entry ;
|
|
|
|
|
|
|
|
# Toplevel choice definitions
|
|
|
|
choice_block =
|
2020-01-27 00:26:51 +01:00
|
|
|
id:identifier ':' s >name_and_description entries:{ noindent_choice_entry }
|
2019-12-01 01:04:13 +01:00
|
|
|
n
|
|
|
|
;
|
|
|
|
|
2020-01-26 23:51:29 +01:00
|
|
|
# Appears in a dish block. One of:
|
2019-12-01 01:04:13 +01:00
|
|
|
# 1) reference to toplevel choice definition
|
|
|
|
# 2) inline choice declaration (as opposed to globally declared and referenced)
|
|
|
|
indent_choice_block =
|
|
|
|
'\t' type:choice_type s
|
|
|
|
(
|
2020-01-27 00:26:51 +01:00
|
|
|
| kind:`declaration` id:identifier ':' ~ s >name_and_description entries:{ indent_choice_entry }
|
2020-01-24 00:26:53 +01:00
|
|
|
| kind:`reference` id:identifier [ s price:price ]
|
2019-12-01 01:04:13 +01:00
|
|
|
)
|
|
|
|
n
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
s = / +/ ;
|
|
|
|
n = '\n' {{'\t'} '\n'} ;
|
|
|
|
|
|
|
|
@name
|
|
|
|
identifier = /[a-z0-9_-]+/ ;
|
|
|
|
string = /[^\n]+/ ;
|
|
|
|
choice_type = 'single_choice' | 'multi_choice' ;
|
|
|
|
|
2020-01-26 15:09:22 +01:00
|
|
|
int = /[0-9]+/ ;
|
2019-12-01 01:04:13 +01:00
|
|
|
|
|
|
|
currency = '€' ;
|
2020-01-26 15:09:22 +01:00
|
|
|
price = currency:currency s value_unit:int [ '.' value_cents:/[0-9]{,2}/ ] ;
|