Exemple #1
0
        public override AST_Node VisitSumsub([NotNull] CoolParser.SumsubContext 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));
        }
Exemple #2
0
        public override int VisitSumsub([NotNull] CoolParser.SumsubContext context)
        {
            int s = Visit(context.expr(0));
            int t = Visit(context.expr(1));

            if (context.op.Type == CoolLexer.ADD)
            {
                return(s + t);
            }
            return(s - t);
        }