[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
grammar of bison
From: |
tys lefering |
Subject: |
grammar of bison |
Date: |
Fri, 7 May 2010 23:16:04 +0200 |
User-agent: |
SquirrelMail/1.4.18 |
Hi,
Doing things with a small tool to
rewrite a grammar without action code
for easy reading, did it for bison
grammar of bison itself of the branch-2.5.
Noticed such short grammar is not in the docs.
Here it is, just in case someone wants this
or for the docs. (also attached as txt file)
Thanks.
/* 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
| "%{...%}"
| "%<flag>"
| "%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. */
--
bisongrammar-2.5.txt
Description: Text document
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- grammar of bison,
tys lefering <=