program |
::= |
( declassignment ";" | functiondefinition )* |
functiondefinition |
::= |
type id "(" ( parameterlist )? ")" "{" statementlist "}" |
parameterlist |
::= |
type id ( "," type id )* |
functioncall |
::= |
id "(" ( assignment ( "," assignment )* )? ")" |
statementlist |
::= |
( block )* |
block |
::= |
"{" statementlist "}" |
|
| |
statement |
block2 |
::= |
"{" statementlist "}" |
|
| |
statement |
statement |
::= |
ifstatement |
|
| |
forstatement |
|
| |
whilestatement |
|
| |
returnstatement ";" |
|
| |
dowhilestatement ";" |
|
| |
printf ";" |
|
| |
declassignment ";" |
|
| |
statassignment ";" |
|
| |
functioncall ";" |
ifstatement |
::= |
<KW_IF> "(" assignment ")" block2 ( <KW_ELSE> block2 )? |
forstatement |
::= |
<KW_FOR> "(" ( statassignment | declassignment ) ";" expr ";" statassignment ")" block2 |
dowhilestatement |
::= |
<KW_DO> block2 <KW_WHILE> "(" assignment ")" |
whilestatement |
::= |
<KW_WHILE> "(" assignment ")" block2 |
returnstatement |
::= |
<KW_RETURN> ( assignment )? |
printf |
::= |
<KW_PRINTF> "(" assignment ")" |
declassignment |
::= |
type id ( "=" assignment )? |
type |
::= |
<KW_BOOLEAN> |
|
| |
<KW_FLOAT> |
|
| |
<KW_INT> |
|
| |
<KW_VOID> |
statassignment |
::= |
id "=" assignment |
assignment |
::= |
id "=" assignment |
|
| |
expr |
expr |
::= |
simpexpr ( "==" simpexpr | "!=" simpexpr | "<=" simpexpr | ">=" simpexpr | "<" simpexpr | ">" simpexpr )? |
simpexpr |
::= |
( "-" term | term ) ( "+" term | "-" term | "||" term )* |
term |
::= |
factor ( "*" factor | "/" factor | "&&" factor )* |
factor |
::= |
<CONST_INT> |
|
| |
<CONST_FLOAT> |
|
| |
<CONST_BOOLEAN> |
|
| |
functioncall |
|
| |
id |
|
| |
"(" assignment ")" |
id |
::= |
<ID> |