/********************************************** * AOSD 10 Submission Files * * exp.cd : * * Contains all the Exp structures * * * *********************************************/ include "asm.cd"; package gen; // To eliminate syntax on definitions lookahead = 2; import edu.neu.ccs.demeterf.*; import edu.neu.ccs.demeterf.lib.*; // Extra syntax (*s / *l / +/-) adds spaces, lines, and in/decrease // indentation for after line breaks Exp = Ifz | Def | Bin | Var | Num. Ifz = "ifz" *s Exp +*l "then" *s Exp *l "else" *s Exp -. Def = ident *s "=" *s Exp ";" *l Exp. Bin = "(" Oper *s Exp *s Exp ")". Var = ident. Num = int. // Used for inlining/generation // Num = Simplify$Zero int. // extern Simplify$Zero = . Oper= Sub. Sub = "-". Env = ExtEnv | EmptyEnv. ExtEnv = ident *s "=" *s int ";" *s Env. EmptyEnv = . extern RuntimeException = error. error = .