示例#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);
        }
示例#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 }));
 }
示例#3
0
文件: Printer.cs 项目: junehwi/school
 object Surface.IExprVisitor <object> .Visit(Surface.Div div)
 {
     PrintBinaryOperator(div, '/');
     return(null);
 }