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

            int type = lookahead.Type;

            switch (type)
            {
            case SchoolLexer.ADD:
            case SchoolLexer.SUB:
                Consume();
                break;

            default:
                return(left);
            }

            Surface.Expr right = Expr();

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

            case SchoolLexer.SUB:
                expr = new Surface.Sub(left, right);
                break;

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