CSC448: Phases: Abstract Syntax [1/8] |
Clogs abstract syntax (for well-formed, typed programs)
n : Integer (integer) f,l,x : Identifier (identifier: function, label, variable) T,S ::= int | T[] (non-void type) program ::= extdecl1 ... extdecln extdecl ::= decl | T f (S1 x1,...,Sn xn) compoundStat (FunDef) | void f (T1 x1,...,Tn xn) compoundStat (FunDef) decl ::= T x; (Decl) | T x = exp; (Decl) compoundStat ::= { decl1 ... decln stat1 ... statm } (StatCompound) stat ::= compoundStat | exp; (StatExp) | goto l; (StatGoto) | if (exp) statT else statF (StatIf) | return; (StatReturn) | return exp; (StatReturn) | skip; (StatSkip) | while (exp) stat (StatWhile) exp ::= expA[expI] (ExpArrayAccess) | x = expR (ExpAssign) | expA[expI] = expR (ExpAssign) | expL binop expR (ExpBinOp) | expL , expR (ExpComma) | f(exp1,...,expn) (ExpFunCall) | n (ExpInt) | new T[exp] (ExpNew) | "value" (ExpString) | unop exp (ExpUnOp) | x (ExpVar)