BNF for cplusplus.jj

NON-TERMINALS

translation_unit ::= ( external_declaration )* <EOF>
external_declaration ::= var_declaration
| function_defn
| struct_defn
| enum_defn
function_defn ::= type_name declarator compound_statement
struct_defn ::= "struct" <ID> "{" var_decl_list "}" ";"
var_decl_list ::= ( var_declaration )+
enum_defn ::= "enum" <ID> "{" enum_id_list "}" ";"
enum_id_list ::= ( <ID> ( "," <ID> )* )?
var_declaration ::= type_name declarator_list
declarator_list ::= declarator ( init | ) ( ";" | "," declarator_list )
init ::= "=" exp
type_name ::= "void"
| "char"
| "signed" ( "char" | "short" ( "int" )? | "long" ( "int" )? | ( "int" )? )
| "unsigned" ( "char" | "short" ( "int" )? | "long" ( "int" )? | ( "int" )? )
| "short" ( "int" )?
| "bool"
| "int"
| "long" ( "int" )?
| "float"
| "double"
| <ID>
declarator ::= <ID> declarator_prime
| "(" declarator ")" declarator_prime
| "*" declarator
| "&" declarator
declarator_prime ::= ( "[" expression "]" | parameter_list )*
parameter_list ::= "(" ( param_declaration ( "," param_declaration )* )? ")"
param_declaration ::= type_name declarator
statement ::= "break" ";"
| "continue" ";"
| "return" opt_exp ";"
| compound_statement
| var_declaration
| opt_exp ";"
| "if" "(" expression ")" statement ( "else" statement | )
| "switch" "(" expression ")" "{" cases "}"
| "while" "(" expression ")" statement
| "do" statement "while" "(" expression ")" ";"
| "for" "(" more_for
more_for ::= var_declaration opt_exp ";" opt_exp ")" statement
| opt_exp ";" opt_exp ";" opt_exp ")" statement
opt_exp ::= expression
|
cases ::= ( ( ( "case" expression ":" | "default" ":" ) )+ ( statement )+ )+
compound_statement ::= "{" ( statement )* "}"
expression ::= exp
exp ::= unary ( ( binaryOp exp | "?" expression ":" exp ) )*
unary ::= unaryOp exp
| "delete" ( "[" "]" exp | exp )
| simple
unaryOp ::= ( "++" | "--" | "~" | "!" | "-" | "+" | "&" | "*" )
binaryOp ::= ( "*" | "/" | "%" | "+" | "-" | "<<" | ">>" | "<" | "<=" | ">" | ">=" | "==" | "!=" | "&" | "^" | "|" | "&&" | "||" | "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | "&=" | "|=" | "^=" | "," )
simple ::= "new" type_name ( "[" expression "]" | )
| primary after_primary
after_primary ::= ( "++" | "--" | "." <ID> | "->" <ID> | "[" expression "]" | "(" argument_list ")" )*
argument_list ::= ( exp ( "," exp )* )?
primary ::= "(" expression ")"
| <ID>
| constant
constant ::= <OCTALINT>
| <DECIMALINT>
| <FLOATONE>
| <FLOATTWO>
| <CHARACTER>
| <STRING>