Example #1
0
        private Surface.Expr Term()
        {
            Surface.Expr left = Factor();

            int type = lookahead.Type;

            switch (type)
            {
            case SchoolLexer.MUL:
            case SchoolLexer.DIV:
                Consume();
                break;

            default:
                return(left);
            }

            Surface.Expr right = Term();

            Surface.Expr expr;
            switch (type)
            {
            case SchoolLexer.MUL:
                expr = new Surface.Mul(left, right);
                break;

            case SchoolLexer.DIV:
                expr = new Surface.Div(left, right);
                break;

            default:
                throw new ParserException("unreachable code");
            }
            return(expr);
        }
Example #2
0
 Core.Expr Surface.IExprVisitor <Core.Expr> .Visit(Surface.Div div)
 {
     Core.Expr left  = div.Left.Accept(this);
     Core.Expr right = div.Right.Accept(this);
     return(new Core.FunApp("div", new Core.Expr[] { left, right }));
 }
Example #3
0
 object Surface.IExprVisitor <object> .Visit(Surface.Div div)
 {
     PrintBinaryOperator(div, '/');
     return(null);
 }