Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
67 lines (47 sloc) 1.6 KB
PDefs. Program ::= [Def] ;
DFun. Def ::= Type Id "(" [Arg] ")" "{" [Stm] "}" ;
terminator Def "" ;
ADecl. Arg ::= Type Id ;
separator Arg "," ;
SExp. Stm ::= Exp ";" ;
SDecls. Stm ::= Type [Id] ";" ;
SInit. Stm ::= Type Id "=" Exp ";" ;
SReturn. Stm ::= "return" Exp ";" ;
SReturnVoid. Stm ::= "return" ";" ;
SWhile. Stm ::= "while" "(" Exp ")" Stm ;
SBlock. Stm ::= "{" [Stm] "}" ;
SIfElse. Stm ::= "if" "(" Exp ")" Stm "else" Stm ;
terminator Stm "" ;
ETrue. Exp15 ::= "true" ;
EFalse. Exp15 ::= "false" ;
EInt. Exp15 ::= Integer ;
EDouble. Exp15 ::= Double ;
EString. Exp15 ::= String ;
EId. Exp15 ::= Id ;
EApp. Exp15 ::= Id "(" [Exp] ")" ;
EPIncr. Exp14 ::= Exp15 "++" ;
EPDecr. Exp14 ::= Exp15 "--" ;
EIncr. Exp13 ::= "++" Exp14 ;
EDecr. Exp13 ::= "--" Exp14 ;
ETimes. Exp12 ::= Exp12 "*" Exp13 ;
EDiv. Exp12 ::= Exp12 "/" Exp13 ;
EPlus. Exp11 ::= Exp11 "+" Exp12 ;
EMinus. Exp11 ::= Exp11 "-" Exp12 ;
ELt. Exp9 ::= Exp9 "<" Exp10 ;
EGt. Exp9 ::= Exp9 ">" Exp10 ;
ELtEq. Exp9 ::= Exp9 "<=" Exp10 ;
EGtEq. Exp9 ::= Exp9 ">=" Exp10 ;
EEq. Exp8 ::= Exp8 "==" Exp9 ;
ENEq. Exp8 ::= Exp8 "!=" Exp9 ;
EAnd. Exp4 ::= Exp4 "&&" Exp5 ;
EOr. Exp3 ::= Exp3 "||" Exp4 ;
EAss. Exp2 ::= Exp3 "=" Exp2 ;
internal ETyped. Exp15 ::= "(" Exp ":" Type ")" ;
coercions Exp 15 ;
separator Exp "," ;
rules Type ::= "bool" | "int" | "double" | "void" | "string" ;
token Id (letter (letter | digit | '_')*) ;
separator nonempty Id "," ;
comment "#" ;
comment "//" ;
comment "/*" "*/" ;