| translation_unit | ::= | ( external_declaration )* <EOF> |
| external_declaration | ::= | var_declaration |
| | | function_defn | |
| | | struct_defn | |
| | | "using" "namespace" <ID> ";" | |
| function_defn | ::= | declaration_specifiers declarator compound_statement |
| struct_defn | ::= | "struct" <ID> "{" var_decl_list "}" ";" |
| var_decl_list | ::= | ( var_declaration )+ |
| var_declaration | ::= | declaration_specifiers declarator_list |
| declarator_list | ::= | declarator ( init | ) ( ";" | "," declarator_list ) |
| init | ::= | "=" exp |
| declaration_specifiers | ::= | ( storage_class | type_qualifier )* type_name ( storage_class | type_qualifier )* |
| storage_class | ::= | "extern" |
| | | "static" | |
| | | "auto" | |
| | | "register" | |
| type_qualifier | ::= | "const" |
| | | "volitile" | |
| type_name | ::= | "void" |
| | | "char" | |
| | | "signed" ( "char" | "long" ( "int" )? | ( "int" )? ) | |
| | | "bool" | |
| | | "int" | |
| | | "long" ( "int" )? | |
| | | "float" | |
| | | "double" | |
| | | <ID> | |
| declarator | ::= | <ID> declarator_prime |
| | | "(" declarator ")" declarator_prime | |
| | | "*" declarator | |
| | | "&" declarator | |
| declarator_prime | ::= | ( "[" ( <DECIMALINT> | ) "]" | parameter_list )* |
| parameter_list | ::= | "(" ( param_declaration ( "," param_declaration )* )? ")" |
| param_declaration | ::= | declaration_specifiers declarator |
| statement | ::= | "break" ";" |
| | | "continue" ";" | |
| | | "return" opt_exp ";" | |
| | | compound_statement | |
| | | var_declaration | |
| | | ";" | |
| | | expression ";" | |
| | | "if" "(" expression ")" statement ( "else" statement | ) | |
| | | "switch" "(" expression ")" statement | |
| | | "case" constant ":" statement | |
| | | "default" ":" statement | |
| | | "while" "(" expression ")" statement | |
| | | "do" statement "while" "(" expression ")" ";" | |
| | | "for" "(" more_for | |
| more_for | ::= | ( var_declaration | opt_exp ";" ) opt_exp ";" opt_exp ")" statement |
| opt_exp | ::= | expression |
| | | ||
| compound_statement | ::= | "{" statement_list "}" |
| statement_list | ::= | ( statement )* |
| expression | ::= | exp |
| exp | ::= | unary ( ( binaryOp exp | "?" expression ":" exp ) )* |
| unary | ::= | unaryOp exp |
| | | simple | |
| unaryOp | ::= | ( "++" | "--" | "~" | "!" | "-" | "+" | "&" | "*" ) |
| binaryOp | ::= | ( "*" | "/" | "%" | "+" | "-" | "<<" | ">>" | "<" | "<=" | ">" | ">=" | "==" | "!=" | "&" | "^" | "|" | "&&" | "||" | "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | "&=" | "|=" | "^=" | "," ) |
| simple | ::= | "new" ( "(" <ID> ")" )? type_name ( "[" expression "]" | ) |
| | | primary after_primary | |
| after_primary | ::= | ( "++" | "--" | "." <ID> | "->" <ID> | "[" expression "]" | "(" argument_list ")" )* |
| argument_list | ::= | ( exp ( "," exp )* )? |
| primary | ::= | "(" expression ")" |
| | | <ID> | |
| | | constant | |
| constant | ::= | "EOF" |
| | | <OCTALINT> | |
| | | <DECIMALINT> | |
| | | "NULL" | |
| | | <DOUBLECONST> | |
| | | <CHARACTER> | |
| | | <STRING> | |
| | | <TRUETOK> | |
| | | <FALSETOK> |