Beispiel #1
0
        public override int VisitLog_arit([NotNull] CoolParser.Log_aritContext context)
        {
            int s = Visit(context.expr());

            if (context.op.Type == CoolLexer.SUB)
            {
                return(-s);
            }
            return(~s);
        }
 /// <summary>
 /// Visit a parse tree produced by the <c>log_arit</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 VisitLog_arit([NotNull] CoolParser.Log_aritContext context)
 {
     return(VisitChildren(context));
 }
Beispiel #3
0
        public override AST_Node VisitLog_arit([NotNull] CoolParser.Log_aritContext context)
        {
            AST_Expresion l = (AST_Expresion)Visit(context.expr());

            return(new AST_UnaryOp(context, l, context.op));
        }