Example #1
0
	void Imperative_ArgDecl(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
		ProtoCore.AST.ImperativeAST.IdentifierNode tNode = null; 
		ProtoCore.AST.ImperativeAST.VarDeclNode varDeclNode = new ProtoCore.AST.ImperativeAST.VarDeclNode(); 
		NodeUtils.SetNodeLocation(varDeclNode, la);
		varDeclNode.memregion = ProtoCore.DSASM.MemoryRegion.MemStack;
		
		Expect(1);
		if (IsKeyWord(t.val, true))
		{
		   errors.SemErr(t.line, t.col, String.Format(Resources.keywordCantBeUsedAsIdentifier, t.val));
		}
		tNode = BuildImperativeIdentifier(t.val);
		NodeUtils.SetNodeLocation(tNode, t);
		
		varDeclNode.NameNode = tNode;
		NodeUtils.CopyNodeLocation(varDeclNode, tNode);
		
		ProtoCore.Type argtype = new ProtoCore.Type(); argtype.Name = "var"; argtype.rank = 0; argtype.UID = 0; 
		if (la.kind == 47) {
			Get();
			Expect(1);
			argtype.Name = t.val; 
			if (la.kind == 10) {
				Get();
				Expect(11);
				argtype.rank = 1; 
				if (la.kind == 10 || la.kind == 24) {
					if (la.kind == 24) {
						Get();
						Expect(10);
						Expect(11);
						argtype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank; 
					} else {
						while (la.kind == 10) {
							Get();
							Expect(11);
							argtype.rank++; 
						}
					}
				}
			}
		}
		varDeclNode.ArgumentType = argtype; 
		node = varDeclNode; 
		if(!isGlobalScope) {
		   localVarCount++;
		}
		
	}
Example #2
0
        void Imperative_ArgDecl(out ProtoCore.AST.ImperativeAST.ImperativeNode node)
        {
            ProtoCore.AST.ImperativeAST.IdentifierNode tNode = null;
            ProtoCore.AST.ImperativeAST.VarDeclNode varDeclNode = new ProtoCore.AST.ImperativeAST.VarDeclNode();
            NodeUtils.SetNodeLocation(varDeclNode, la);
            varDeclNode.memregion = ProtoCore.DSASM.MemoryRegion.kMemStack;

            if (la.kind == 28) {
            Get();
            varDeclNode.memregion = ProtoCore.DSASM.MemoryRegion.kMemHeap;
            }
            Expect(1);
            if (IsKeyWord(t.val, true))
            {
               errors.SemErr(t.line, t.col, String.Format("\"{0}\" is a keyword, identifier expected", t.val));
            }
            tNode = BuildImperativeIdentifier(t.val);
            NodeUtils.SetNodeLocation(tNode, t);

            varDeclNode.NameNode = tNode;
            NodeUtils.CopyNodeLocation(varDeclNode, tNode);

            ProtoCore.Type argtype = new ProtoCore.Type(); argtype.Name = "var"; argtype.rank = 0; argtype.UID = 0;
            if (la.kind == 48) {
            Get();
            Expect(1);
            argtype.Name = t.val;
            if (la.kind == 7) {
                argtype.IsIndexable = true;
                Get();
                Expect(8);
                argtype.rank = 1;
                if (la.kind == 7 || la.kind == 21) {
                    if (la.kind == 21) {
                        Get();
                        Expect(7);
                        Expect(8);
                        argtype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank;
                    } else {
                        while (la.kind == 7) {
                            Get();
                            Expect(8);
                            argtype.rank++;
                        }
                    }
                }
            }
            }
            varDeclNode.ArgumentType = argtype;
            node = varDeclNode;
            if(!isGlobalScope) {
               localVarCount++;
            }
        }