1 # Grammar for the pgen parser specification language
3 # This was used to bootstrap the parser for the emu-grammar parser
4 # specification language, and it's not clear why we should have two things.
14 token Token = "token";
20 token OpenBrace = "{";
21 token CloseBrace = "}";
22 token OpenParen = "(";
23 token CloseParen = ")";
25 token QuestionMark = "?";
28 token_defs? nt_defs => grammar($0, $1);
32 token_def => single($0);
33 token_defs token_def => append($0, $1);
37 "token" IDENT "=" STR ";" => const_token($1, $3);
38 "var" "token" IDENT ";" => var_token($2);
42 nt_def => nt_defs_single($0);
43 nt_defs nt_def => nt_defs_append($0, $1);
47 COMMENT? "goal"? "nt" IDENT "{" prods? "}" => nt_def($0, $1, $3, $5);
52 prods prod => append($0, $1);
57 terms reducer? ";" => prod($0, $1);
62 terms term => append($0, $1);
67 symbol "?" => optional($0);
80 MATCH => expr_match($0);
81 IDENT "(" expr_args? ")" => expr_call($0, $2);
82 "Some" "(" expr ")" => expr_some($2);
83 "None" => expr_none();
87 expr => args_single($0);
88 expr_args "," expr => args_append($0, $2);