コード例 #1
0
ファイル: ReduceParserActions.cs プロジェクト: dbremner/irony
 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
ファイル: ReduceParserActions.cs プロジェクト: dbremner/irony
 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
ファイル: ReduceParserActions.cs プロジェクト: dbremner/irony
 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);
 }