EBNF
実装済みのEBNFを書いていく
code: EBNF
toplevel = (type ident ( "(" param (, param)* ")" "{" compound-stmt )| vardef) ";"
param = type vardef
compound-stmt = (stmt) stmt* "}"
stmt = (type decl
| "if" "(" expr ")" stmt ("else" stmt)?
| "for" "(" type decl | expr-stmt) expr ";" expr ";" expr ")" stmt
| return expr ";"
| "{" (stmt)* "}"
| expr-stmt
decl = type ident ("=" expr)? ";"
expr-stmt = expr ";"
expr = assign ("," expr)?
assign = conditional ("=" conditional)?
conditional = logor ("?" expr ":" conditional)?
logor = logand("||" logand)*
logand = equality("&&" equality)*
equality = rel(("==" | "!=") rel)*
rel = add(("<"|">") add)*
add = mul(("+"|"-" mul)*
mul = unary("*"|"/"|"%" mul)*
unary = (("*"|"&") unary)
| ("sizeof" unary)
| postfix
postfix = primary ("expr "")*
primary = "(" ("{" compound-stmt ")" )? expr ")"
| num
| str
| ident ( "(" assign (, assign)* ")")