Пример #1
0
 protected override ParseTreeNode GetResultNode(ParsingContext context)
 {
     int childCount = Production.RValues.Count;
       int firstChildIndex = context.ParserStack.Count - childCount;
       var span = context.ComputeStackRangeSpan(childCount);
       var newNode = new ParseTreeNode(Production.LValue, span);
       if (childCount > 0) { //if it is not empty production - might happen for MakeStarRule
     var listNode = context.ParserStack[firstChildIndex]; //get the transient list with all members - it is the first child node
     newNode.ChildNodes.AddRange(listNode.ChildNodes);    //copy all list members
       }
       return newNode;
 }
Пример #2
0
 protected virtual ParseTreeNode GetResultNode(ParsingContext context) {
   var childCount = Production.RValues.Count;
   int firstChildIndex = context.ParserStack.Count - childCount;
   var span = context.ComputeStackRangeSpan(childCount);
   var newNode = new ParseTreeNode(Production.LValue, span);
   for (int i = 0; i < childCount; i++) {
     var childNode = context.ParserStack[firstChildIndex + i];
     if (childNode.IsPunctuationOrEmptyTransient()) continue; //skip punctuation or empty transient nodes
     newNode.ChildNodes.Add(childNode);
   }//for i
   return newNode;
 }
Пример #3
0
 protected override ParseTreeNode GetResultNode(ParsingContext context)
 {
     int childCount = Production.RValues.Count;
       int firstChildIndex = context.ParserStack.Count - childCount;
       var listNode = context.ParserStack[firstChildIndex]; //get the list already created - it is the first child node
       listNode.Span = context.ComputeStackRangeSpan(childCount);
       var listMember = context.ParserStack.Top; //next list member is the last child - at the top of the stack
       if (listMember.IsPunctuationOrEmptyTransient())
     return listNode;
       listNode.ChildNodes.Add(listMember);
       return listNode;
 }
Пример #4
0
        protected override ParseTreeNode GetResultNode(ParsingContext context)
        {
            int childCount      = Production.RValues.Count;
            int firstChildIndex = context.ParserStack.Count - childCount;
            var span            = context.ComputeStackRangeSpan(childCount);
            var newNode         = new ParseTreeNode(Production.LValue, span);

            if (childCount > 0)                                      //if it is not empty production - might happen for MakeStarRule
            {
                var listNode = context.ParserStack[firstChildIndex]; //get the transient list with all members - it is the first child node
                newNode.ChildNodes.AddRange(listNode.ChildNodes);    //copy all list members
            }
            return(newNode);
        }
Пример #5
0
        protected override ParseTreeNode GetResultNode(ParsingContext context)
        {
            int childCount      = Production.RValues.Count;
            int firstChildIndex = context.ParserStack.Count - childCount;
            var listNode        = context.ParserStack[firstChildIndex]; //get the list already created - it is the first child node

            listNode.Span = context.ComputeStackRangeSpan(childCount);
            var listMember = context.ParserStack.Top; //next list member is the last child - at the top of the stack

            if (listMember.IsPunctuationOrEmptyTransient())
            {
                return(listNode);
            }
            listNode.ChildNodes.Add(listMember);
            return(listNode);
        }
Пример #6
0
        protected virtual ParseTreeNode GetResultNode(ParsingContext context)
        {
            var childCount      = Production.RValues.Count;
            int firstChildIndex = context.ParserStack.Count - childCount;
            var span            = context.ComputeStackRangeSpan(childCount);
            var newNode         = new ParseTreeNode(Production.LValue, span);

            for (int i = 0; i < childCount; i++)
            {
                var childNode = context.ParserStack[firstChildIndex + i];
                if (childNode.IsPunctuationOrEmptyTransient())
                {
                    continue;                                    //skip punctuation or empty transient nodes
                }
                newNode.ChildNodes.Add(childNode);
            }//for i
            return(newNode);
        }
Пример #7
0
        protected override ParseTreeNode GetResultNode(ParsingContext context)
        {
            var topIndex   = context.ParserStack.Count - 1;
            var childCount = Production.RValues.Count;

            for (int i = 0; i < childCount; i++)
            {
                var child = context.ParserStack[topIndex - i];
                if (child.IsPunctuationOrEmptyTransient())
                {
                    continue;
                }
                return(child);
            }
            //Otherwise return an empty transient node; if it is part of the list, the list will skip it
            var span = context.ComputeStackRangeSpan(childCount);

            return(new ParseTreeNode(Production.LValue, span));
        }
Пример #8
0
 protected override ParseTreeNode GetResultNode(ParsingContext context)
 {
     var topIndex = context.ParserStack.Count - 1;
       var childCount = Production.RValues.Count;
       for (int i = 0; i < childCount; i++) {
     var child = context.ParserStack[topIndex - i];
     if (child.IsPunctuationOrEmptyTransient()) continue;
     return child;
       }
       //Otherwise return an empty transient node; if it is part of the list, the list will skip it
       var span = context.ComputeStackRangeSpan(childCount);
       return new ParseTreeNode(Production.LValue, span);
 }