/* grammar of GNU bison parse-gram.y without action code of git branch-2.5 date Fri May 7 2010 */ /*==========\ | Grammar. | \==========*/ input: prologue_declarations "%%" grammar epilogue.opt ; /*------------------------------------. | Declarations: before the first %%. | `------------------------------------*/ prologue_declarations: /* empty */ | prologue_declarations prologue_declaration ; prologue_declaration: grammar_declaration | "%{...%}" | "%" | "%define" variable content.opt | "%defines" | "%defines" STRING | "%error-verbose" | "%expect" INT | "%expect-rr" INT | "%file-prefix" STRING | "%file-prefix" "=" STRING | "%glr-parser" | "%initial-action" "{...}" | "%language" STRING | "%name-prefix" STRING | "%name-prefix" "=" STRING | "%no-lines" | "%nondeterministic-parser" | "%output" STRING | "%output" "=" STRING | "%param" params | "%require" STRING | "%skeleton" STRING | "%token-table" | "%verbose" | "%yacc" | ";" ; params: params "{...}" | "{...}" ; /*----------------------. | grammar_declaration. | `----------------------*/ grammar_declaration: precedence_declaration | symbol_declaration | "%start" symbol | "%destructor" "{...}" generic_symlist | "%printer" "{...}" generic_symlist | "%default-prec" | "%no-default-prec" | "%code" braceless | "%code" ID braceless ; /*---------. | %union. | `---------*/ union_name: /* empty */ | ID ; grammar_declaration: "%union" union_name braceless ; symbol_declaration: "%nterm" symbol_defs.1 | "%token" symbol_defs.1 | "%type" TAG symbols.1 ; precedence_declaration: precedence_declarator tag.opt symbols.prec ; precedence_declarator: "%left" | "%right" | "%nonassoc" | "%precedence" ; tag.opt: /* empty */ | TAG ; symbols.prec: symbol.prec | symbols.prec symbol.prec ; symbol.prec: symbol | symbol INT ; symbols.1: symbol | symbols.1 symbol ; generic_symlist: generic_symlist_item | generic_symlist generic_symlist_item ; generic_symlist_item: symbol | TAG | "<*>" | "<>" ; symbol_def: TAG | id | id INT | id string_as_id | id INT string_as_id ; symbol_defs.1: symbol_def | symbol_defs.1 symbol_def ; /*------------------------------------------. | The grammar section: between the two %%. | `------------------------------------------*/ grammar: rules_or_grammar_declaration | grammar rules_or_grammar_declaration ; rules_or_grammar_declaration: rules | grammar_declaration ";" | error ";" ; rules: id_colon named_ref.opt rhses.1 ; rhses.1: rhs | rhses.1 "|" rhs | rhses.1 ";" ; rhs: /* empty */ | rhs symbol named_ref.opt | rhs "{...}" named_ref.opt | rhs "%prec" symbol | rhs "%dprec" INT | rhs "%merge" TAG ; named_ref.opt: /* empty */ | BRACKETED_ID ; /*---------------------------. | variable and content.opt. | `---------------------------*/ variable: ID | STRING ; content.opt: /* empty */ | ID | STRING ; /*------------. | braceless. | `------------*/ braceless: "{...}" ; /*--------------. | Identifiers. | `--------------*/ id: ID | CHAR ; id_colon: ID_COLON ; symbol: id | string_as_id ; string_as_id: STRING ; epilogue.opt: /* empty */ | "%%" EPILOGUE ; /* end. */