Skip to content

osorosia/9cc

Repository files navigation

9cc

EBNF

program     = func_definition*
function_definition = typ ident "(" (arg ("," arg)*)? ")" "{" stmt "}"
arg         = typ ident
stmt        = expr ";"
            | "{" stmt* "}"
            | "if" "(" expr ")" stmt ("else" stmt)?
            | "while" "(" expr ")" stmt
            | "for" "(" expr? ";" expr? ";" expr? ")" stmt
            | "return" expr? ";"
            | typ ident ("=" expr)? ";"
            | typ ident "[" num "]" ";"
expr        = assign
assign      = equality ("=" assign)?
equality    = relational ("==" relational | "!=" relational)*
relational  = add ("<" add | "<=" add | ">" add | ">=" add)*
add         = mul ("+" mul | "-" mul)*
mul         = unary ("*" unary | "/" unary)*
unary       = ("+" | "-")? primary
            | ("*" | "&" | "sizeof") unary
primary     = num
            | (ident ( "(" (expr ( "," expr)*)? ")" )?
            | "(" expr ")"
typ         = "int" "*"*

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •