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 =
|
2020-02-24 18:33:59 +01:00
|
|
|
n '\t' key:identifier s value:string
|
2019-12-01 01:04:13 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
location = >location_header items:{ block } ;
|
|
|
|
|
|
|
|
|
2020-01-27 19:15:24 +01:00
|
|
|
attributes =
|
2023-06-13 21:39:19 +02:00
|
|
|
name:/[^\n#]*?(?= +-- | | €| *\n| *#)/
|
2021-06-20 22:08:41 +02:00
|
|
|
[ s '--' ~ s description:/[^\n#]*?(?= | *\n| *#)/ ]
|
2023-06-13 21:39:19 +02:00
|
|
|
[ / +/ ~
|
2021-06-20 22:08:41 +02:00
|
|
|
[ {[ s ] ('{' tags+:identifier '}')} / +|$/ ]
|
|
|
|
[ price:price ]
|
|
|
|
]
|
2019-12-01 01:04:13 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
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 19:15:24 +01:00
|
|
|
id:identifier ':' s >attributes 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 19:15:24 +01:00
|
|
|
| kind:`declaration` id:identifier ':' ~ s >attributes 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
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2021-06-20 22:08:41 +02:00
|
|
|
s = / +/ ;
|
2019-12-01 01:04:13 +01:00
|
|
|
n = '\n' {{'\t'} '\n'} ;
|
|
|
|
|
|
|
|
@name
|
|
|
|
identifier = /[a-z0-9_-]+/ ;
|
2020-02-29 22:26:17 +01:00
|
|
|
string = /[^\n#]+/ ;
|
2019-12-01 01:04:13 +01:00
|
|
|
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}/ ] ;
|