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."); } }
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; }
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); } }