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); }
Core.Expr Surface.IExprVisitor <Core.Expr> .Visit(Surface.Sub sub) { Core.Expr left = sub.Left.Accept(this); Core.Expr right = sub.Right.Accept(this); return(new Core.FunApp("sub", new Core.Expr[] { left, right })); }
object Surface.IExprVisitor <object> .Visit(Surface.Sub sub) { PrintBinaryOperator(sub, '-'); return(null); }