Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
 Core.Expr Surface.IExprVisitor <Core.Expr> .Visit(Surface.Mul mul)
 {
     Core.Expr left  = mul.Left.Accept(this);
     Core.Expr right = mul.Right.Accept(this);
     return(new Core.FunApp("mul", new Core.Expr[] { left, right }));
 }
Ejemplo n.º 3
0
 object Surface.IExprVisitor <object> .Visit(Surface.Mul mul)
 {
     PrintBinaryOperator(mul, '*');
     return(null);
 }