示例#1
0
        public override void Init(ParsingContext context, ParseTreeNode treeNode)
        {
            base.Init(context, treeNode);

            ParseTreeNode declNode = treeNode.ChildNodes[1].FirstChild;

            if (declNode.ToString() == "TypedFunction")
            {
                declNode = declNode.FirstChild;
            }

            TypeToken = declNode.FirstChild.Token;

            Name       = declNode.LastChild.Token;
            DeclNode   = (ScopedNode)declNode.AstNode;
            Parameters = (ParametersNode)treeNode.ChildNodes[2].AstNode;

            if (TypeToken != null)
            {
                AsString = Label + TypeToken.ValueString + " " + Name.ValueString;
            }

            ChildNodes.Add(DeclNode);
            DeclNode.Parent = this;
            ChildNodes.Add(Parameters);
            Parameters.Parent = this;

            if (UoTypeToken == Types.List && !(this is UoCoreFunctionNode))
            {
                context.AddParserMessage(ParserErrorLevel.Warning, new SourceSpan(TypeToken.Location, TypeToken.Length), "Function may not return a list.");
            }
        }
示例#2
0
        protected virtual void LoadNodes(ParsingContext context, ParseTreeNode treeNode)
        {
            ChanceNode = treeNode.ChildNodes[1].ChildNodes.Count > 0 ? (EventParamNode <UoToken.UoTypeName_int>)treeNode.ChildNodes[1].FirstChild.AstNode : null;

            ParseTreeNode declNode = treeNode.ChildNodes[2];

            Name           = declNode.FirstChild.Token;
            EventParameter = declNode.ChildNodes.Count > 1 ? (ScopedNode)declNode.LastChild.AstNode : null;

            DeclNode   = (EventDecNode)declNode.AstNode;
            Parameters = (ParametersNode)treeNode.ChildNodes[3].AstNode;
            Body       = (ScopedNode)treeNode.ChildNodes[4].AstNode;
        }
示例#3
0
        public static void CreateFromExtern(ParsingContext context, ParseTreeNode parseNode)
        {
            ParametersNode node = new ParametersNode();

            node.Init(context, parseNode);
            parseNode.AstNode = node;
            node.ChildNodes.Clear();
            foreach (ParseTreeNode cnode in parseNode.ChildNodes)
            {
                DeclarationNode param = new ProtoParamDeclaration();
                param.Init(context, cnode);
                param.Parent = node;
                node.ChildNodes.Add(param);
            }
        }