Exemple #1
0
        public override int VisitLogic([NotNull] CBluntParser.LogicContext context)
        {
#if DEBUG
            Console.WriteLine("VisitLogic");
#endif

            // Get left-hand side
            SymbolTable.ExpressionStoreLinkedList.AddLast(new ExpressionStore());
            Visit(context.expression(0));
            var expr1Type = SymbolTable.ExpressionStoreLinkedList.Last.Value.Type;
            SymbolTable.ExpressionStoreLinkedList.RemoveLast();

            // Get right-hand side
            SymbolTable.ExpressionStoreLinkedList.AddLast(new ExpressionStore());
            Visit(context.expression(1));
            var expr2Type = SymbolTable.ExpressionStoreLinkedList.Last.Value.Type;
            SymbolTable.ExpressionStoreLinkedList.RemoveLast();

            if (expr1Type != "number")
            {
                SyntaxError(context, "Left-hand side must be of a type number");
                return(1);
            }

            if (expr2Type != "number")
            {
                SyntaxError(context, "Right-hand side must be of a type number");
                return(1);
            }

            return(0);
        }
Exemple #2
0
        public override int VisitLogic([NotNull] CBluntParser.LogicContext context)
        {
#if DEBUG
            Console.WriteLine("VisitLogic");
#endif
            for (int counter = 0; counter < context.children.Count(); ++counter)
            {
                Visit(context.GetChild(counter));
            }
            return(0);
        }
Exemple #3
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="CBluntParser.logic"/>.
 /// <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 VisitLogic([NotNull] CBluntParser.LogicContext context)
 {
     return(VisitChildren(context));
 }