public override AST_Node VisitCompar([NotNull] CoolParser.ComparContext context) { AST_Expresion l = (AST_Expresion)Visit(context.expr(0)); AST_Expresion r = (AST_Expresion)Visit(context.expr(1)); return(new AST_BinaryOp(context, l, r, context.op)); }
public override int VisitCompar([NotNull] CoolParser.ComparContext context) { int s = Visit(context.expr(0)); int t = Visit(context.expr(1)); if (context.op.Type == CoolLexer.EQUAL_CM) { return((s == t)?1:0); } if (context.op.Type == CoolLexer.LESS) { return((s < t)?1:0); } return((s <= t) ? 1 : 0); }
/// <summary> /// Visit a parse tree produced by the <c>compar</c> /// labeled alternative in <see cref="CoolParser.expr"/>. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/> /// on <paramref name="context"/>. /// </para> /// </summary> /// <param name="context">The parse tree.</param> /// <return>The visitor result.</return> public virtual Result VisitCompar([NotNull] CoolParser.ComparContext context) { return(VisitChildren(context)); }