public virtual void InitFunction(ParseTreeNode treeNode)
        {
            int           num           = treeNode.ChildNodes.Count - 1;
            ParseTreeNode parseTreeNode = treeNode.ChildNodes[num - 2];

            if (parseTreeNode != null && parseTreeNode.Token != null && parseTreeNode.Token.KeyTerm != null)
            {
                NameNode = new LuaFunctionIdentifierNode().InitAnonymous();
            }
            else
            {
                NameNode = AddChild("Name", parseTreeNode);
            }
            Parameters = AddChild("Parameters", treeNode.ChildNodes[num - 1]);
            Body       = AddChild("Body", treeNode.ChildNodes[num]);
            AsString   = "<Function " + NameNode.AsString + ">";
            LuaParamListNode luaParmListNode = Parameters as LuaParamListNode;

            if (luaParmListNode != null)
            {
                BeginRegionToken = luaParmListNode.EndToken;
                return;
            }
            BeginRegionToken = treeNode.ChildNodes[num - 1].FindToken();
        }
Example #2
0
 private static void RecursiveChildTraversal(List <ParseTreeNode> leafNodes, ParseTreeNode node)
 {
     if (node.ChildNodes.Count == 0)
     {
         leafNodes.Add(node);
         return;
     }
     foreach (ParseTreeNode current in node.ChildNodes)
     {
         LuaParamListNode.RecursiveChildTraversal(leafNodes, current);
     }
 }
Example #3
0
        public override void Init(ParsingContext context, ParseTreeNode treeNode)
        {
            base.Init(context, treeNode);
            Node     = treeNode;
            EndToken = context.CurrentToken;
            List <ParseTreeNode> list = new List <ParseTreeNode>();

            if (treeNode.ChildNodes.Count > 0)
            {
                LuaParamListNode.RecursiveChildTraversal(list, treeNode);
            }
            AsString = " (";
            int num = 0;

            foreach (ParseTreeNode current in list)
            {
                AddChild("Parameter", current);
                AsString += ((num == 0) ? current.ToString() : (", " + current));
                num++;
            }
            AsString += ")";
        }