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.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 })); }
object Surface.IExprVisitor <object> .Visit(Surface.Add add) { PrintBinaryOperator(add, '+'); return(null); }