コード例 #1
0
        public override void Visit(ForeachLoopNode node)
        {
            _symbolTable.SetCurrentNode(node);
            AllType?collectionType = _symbolTable.RetrieveSymbol(node.InVariableName, out bool isCollectionInForeach, false);

            if (node.VariableType_enum == collectionType)
            {
                //collection type and variable type is the same.
            }
            else
            {
                _symbolTable.WrongTypeError(node.VariableName, node.InVariableName);
            }
            _symbolTable.OpenScope(BlockType.ForEachLoop);
            VisitChildren(node);
            _symbolTable.CloseScope();
        }
コード例 #2
0
 public override void Visit(ForeachLoopNode node)
 {
     SymbolTable.SetCurrentNode(node);
     SymbolTable.OpenScope(BlockType.ForEachLoop);
     // Check the new declared variable
     if (SymbolTable.DeclaredLocally(node.VariableName))
     {
         SymbolTable.AlreadyDeclaredError(node.VariableName);
     }
     else
     {
         SymbolTable.EnterSymbol(node.VariableName, node.VariableType_enum);
         SymbolTable.SetAssigned(node.VariableName);
     }
     // CHeck if the variable (collection) to loop though, is defined!
     SymbolTable.CheckIfDefined(node.InVariableName);
     // Visit all children (codeBlock items)
     VisitChildren(node);
     // Close the scope again
     SymbolTable.CloseScope();
 }
コード例 #3
0
        public override AbstractNode VisitForeachLoop([NotNull] GiraphParser.ForeachLoopContext context)
        {
            ForeachLoopNode ForeachNode = new ForeachLoopNode(context.Start.Line, context.Start.Column);

            ForeachNode.VariableName   = context.foreachCondition().variable(0).GetText();
            ForeachNode.VariableType   = context.foreachCondition().allType().GetText();
            ForeachNode.InVariableName = context.foreachCondition().variable(1).GetText();
            // Check the where condition
            if (context.where () != null && context.where ().GetText().Length > 0)
            {
                ForeachNode.WhereCondition = Visit(context.where ());
            }
            // Visit the children of the codeblock
            foreach (var Child in context.codeBlock().children)
            {
                if (Child.GetChild(0) != null)
                {
                    ForeachNode.AdoptChildren(Visit(Child.GetChild(0)));
                }
            }
            return(ForeachNode);
        }
コード例 #4
0
 public virtual XzaarExpression Visit(ForeachLoopNode loop)
 {
     return(null);
 }
コード例 #5
0
 public override void Visit(ForeachLoopNode node)
 {
 }
コード例 #6
0
 public abstract void Visit(ForeachLoopNode node);
コード例 #7
0
 public virtual ForeachLoopNode Visit(ForeachLoopNode loop)
 {
     return(loop);
 }