Skip to content

tkuramot/minicc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minicc

features

  • arithmetic operators
  • operator precedence
  • relational and logical operators
  • multiple statements
  • variable declaration and assignments
  • conditional statements
  • iteration structure (while, for)
  • compound statements
  • function call with and without arguments
  • function definition
  • address and dereference
  • type (int, pointer)

syntax

program    = func*
func       = type ident "(" params? ")" "{" stmt* "}"
stmt       = expr ";"
            | "{" stmt* "}"
            | "if" "(" expr ")" stmt ("else" stmt)?
            | "while" "(" expr ")" stmt
            | "for" "(" expr? ";" expr? ";" expr? ")" stmt
            | "return" expr ";"
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 | "-"? primary | "*" unary | "&" unary
primary    = num | type? '*'* ident ("(" args? ")")? | "(" expr ")"
args       = expr ("," expr)*
params     = type ident ("," ident)*
type       = int '*'*

references

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published