#region 3-Rules
         Root           = stmtList
                        ;
         stmtList.Rule  = MakePlusRule(stmtList, stmt)
                        ; 
         stmt.Rule      = Id + Assignment + expr + Terminator
                        | Comment
                        ;
         expr.Rule      = numeric
                        | Id
                        | OpenParen + expr + CloseParen
                        | expr + binaryOp + expr
                        | unaryOp + expr + ReduceHere()
                        ;
         unaryOp.Rule   = ToTerm("+") | "-" 
                        ;
         binaryOp.Rule   = ToTerm("*") | "/" | unaryOp
                        ;
         numeric.Rule   = IntNum
                        | RealNum
                        ;
         stmt.ErrorRule = SyntaxError + Terminator
                        ;

         RegisterBracePair("(", ")");

         // operator associativites in decreasing order of precedence
         RegisterOperators(20, Associativity.Left, "*", "/");
         RegisterOperators(10, Associativity.Left, "+", "-");
      #endregion

Last edited Nov 7, 2012 at 5:59 PM by pgeerkens, version 1

Comments

No comments yet.