CSC448: AST: More Compact Notation [4/18] Previous pageContentsNext page

ExtDecl ::=
   Decl { Type type; String name; Optional<Exp> eo; }
 | FunDefSig

FunDefSig { Type type; String name; List<Decl> params; } ::=
   FunDef { StatCompound body; }

Type ::=
   TypeArray { Type type; }
 | TypeInt { }
 | TypeVoid { }

Stat { List<String> labels; } ::=
   StatCompound { List<Decl> decls; List<Stat> stats; }
 | StatExp { Exp exp; }
 | StatGoto { String target; }
 | StatIf { Exp exp; Stat statT; Stat statF; }
 | StatReturn { Optional<Exp> oe; }
 | StatSkip { }
 | StatWhile { Exp exp; Stat stat; }

Exp { Optional<Type> to; } ::=
   ExpArrayAccess { Exp array; Exp index; }
 | ExpAssign { Exp left; Exp right; }
 | ExpBinOp { BinOp op; Exp left; Exp right; }
 | ExpComma { Exp left; Exp right; }
 | ExpFunCall { String name; List<Exp> args; }
 | ExpInt { int value; }
 | ExpNew { Type contentType; Exp size; }
 | ExpString { String value; }
 | ExpUnOp { UnOp op; Exp exp; }
 | ExpVar { String name; }

Previous pageContentsNext page