Beispiel #1
0
        public override AbstractNode VisitSingleObjectDcl([NotNull] GiraphParser.SingleObjectDclContext context)
        {
            DeclarationNode DclNode = new DeclarationNode(context.Start.Line, context.Start.Column);

            DclNode.Type = context.objects().GetText();
            DclNode.Name = context.variable().GetText();
            if (context.boolCompOrExp() != null)
            {
                DclNode.Assignment = Visit(context.boolCompOrExp());
            }
            return(DclNode);
        }
 public override void Visit(DeclarationNode node)
 {
     if (node.CollectionDcl)
     {
         ProgramCode.Append("COLLECTION ");
     }
     ProgramCode.Append(node.Type + " " + node.Name);
     if (node.Assignment != null)
     {
         ProgramCode.Append(" = " + node.Assignment.Name);
     }
     ProgramCode.Append(";\n");
 }
Beispiel #3
0
        public override AbstractNode VisitCollectionDcl([NotNull] GiraphParser.CollectionDclContext context)
        {
            DeclarationNode dclNode = new DeclarationNode(context.Start.Line, context.Start.Column);

            dclNode.CollectionDcl = true;
            dclNode.Type          = context.allType().GetText();
            dclNode.Name          = context.variable().GetText();
            var test = context.collectionAssignment();

            if (context.collectionAssignment() != null)
            {
                dclNode.Assignment        = Visit(context.collectionAssignment());
                dclNode.Assignment.Parent = dclNode;
            }
            return(dclNode);
        }
Beispiel #4
0
        public override void Visit(DeclarationNode node)
        {
            VisitChildren(node);
            _symbolTable.SetCurrentNode(node);
            if (node.Assignment != null)
            {
                node.Assignment.Parent = node;
                node.Assignment.Accept(this);

                VisitChildren(node);
                AllType      typeOfVariable = _symbolTable.RetrieveSymbol(node.Name) ?? AllType.UNKNOWNTYPE;
                AbstractNode abNode         = node.Assignment;
                if (!(abNode is RunQueryNode))
                {
                    AllType typeOfRetreiveVariable = _symbolTable.RetrieveSymbol(abNode.Name, out bool isCollectionRetrieve) ?? AllType.UNKNOWNTYPE;
                }
                CheckAllowedCast(typeOfVariable, abNode.Type_enum);
            }
        }
 DeclarationType GetDeclarationType(DeclarationNode declaration)
 {
     if (declaration is CallableDeclarationNode)
     {
         return(DeclarationType.CALLABLE);
     }
     else if (declaration is VarDeclarationNode)
     {
         return(DeclarationType.VARIABLE);
     }
     else if (declaration is TypeDeclarationNode)
     {
         return(DeclarationType.TYPE);
     }
     else
     {
         throw new InvalidOperationException("Nodo no válido");
     }
 }
 public abstract void Visit(DeclarationNode node);