Skip to content

Latest commit

 

History

History
55 lines (35 loc) · 664 Bytes

grammar.md

File metadata and controls

55 lines (35 loc) · 664 Bytes

[Prog] ==> {

  • [Stmt]*
    

}

[Stmt] ==> {

  • exit([Expr]); 
    
  • let ident = [Expr];
    
  • ident = [Expr];
    
  • print([Expr]);
    
  • [Scope]
    
  • if ([Expr]) [Scope] [IfPred]
    
  • while([Expr])[Scope]
    

}

[Scope] ==> {

  • [Stmt]*
    

}

[IfPred] ==> {

  • elif([expr])[Scope][IfPred]
    
  • else[Scope]
    
  • ε
    

}

[Expr] ==> {

  • [Term]
    
  • [BinExpr]
    

}

[BinExpr] ==> {

  • [Expr] * [Expr] & precedence = 1
    
  • [Expr] / [Expr] & precedence = 1
    
  • [Expr] + [Expr] & precedence = 0
    
  • [Expr] - [Expr] & precedence = 0
    

}

[Term] ==>{

  • int_lit
    
  • ident
    
  • ([Expr])
    

}