CSC448: CLOGS summary: Three-Address-Code Abstract Syntax [20/26] Previous pageContentsNext page

Abstract syntax for three-address code:

            n : Integer         (integer)
        f,l,x : Identifier      (identifier: function, label, variable)
            v ::= n | x         (integer or 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)

 compoundStat ::= { decl1 ... decln stat1 ... statm }     (StatCompound)

         stat ::= compoundStat                            
                | exp;                                    (StatExp)
                | goto l;                                 (StatGoto)
                | if (exp) goto l1; else goto l2;         (StatIf)
                | return;                                 (StatReturn)
                | return exp;                             (StatReturn)
                | skip;                                   (StatSkip)

          exp ::= rhs
                | lhs = rhs                               (ExpAssign)

          lhs ::= x                                       (ExpVar)
                | x[v]                                    (ExpArrayAccess)

          rhs ::= x[v]                                    (ExpArrayAccess)
                | vL binop vR                             (ExpBinOp)
                | f(v1,...,vn)                            (ExpFunCall)
                | n                                       (ExpInt)
                | new T[v]                                (ExpNew)
                | "value"                                 (ExpString)
                | unop v                                  (ExpUnOp)
                | x                                       (ExpVar)

Previous pageContentsNext page