Example #1
0
        public static ParserState <Result> ForStart(ParserNode root, ISourceTextReader reader, bool enableLog)
        {
            IndentedWriter w;

            if (enableLog)
            {
                w = new IndentedWriter("  ");
                w.Push().WriteLine("Start @{0} {1}", reader.GetPosition(), root).Push();
            }
            else
            {
                w = null;
            }

            if (root.Parent != null)
            {
                throw new ArgumentException();
            }

            return(new LinearParserState(
                       w,
                       root,
                       null,
                       new ParserStep.EnterNode(null, root, reader.Location),
                       StatefullStackNode.ForRoot(),
                       null,
                       reader
                       ));
        }
Example #2
0
        private void PushChildIndex()
        {
            if (_log != null)
            {
                _log.WriteLine("PushChildIndex 0");
            }

            this.Stack = this.Stack.StartChildCount();
        }
Example #3
0
        private LinearParserState(IndentedWriter w, ParserNode currNode, ParserNode prevNode, ParserStep lastStep, StatefullStackNode stack, bool?lastTerminalFailed, ISourceTextReader reader, ISourceTextReaderHolder holder = null)
            : base(w, currNode, prevNode, lastTerminalFailed, reader, holder)
        {
            this.LastStep = lastStep;
            this.Stack    = stack;

            if (_log != null)
            {
                _log.WriteLine(this.Stack.ToString());
            }
        }
Example #4
0
        private int IncChildIndex()
        {
            if (this.Stack.RecursionSource != null)
            {
                throw new InvalidOperationException();
            }

            this.Stack = this.Stack.CountNextChild();
            if (_log != null)
            {
                _log.WriteLine("IncChildIndex {0}", this.Stack.ChildsCount);
            }

            return(this.Stack.ChildsCount);
        }
Example #5
0
        private int PopChildIndex()
        {
            if (this.Stack.RecursionSource != null)
            {
                throw new InvalidOperationException();
            }

            var value = this.Stack.ChildsCount;

            this.Stack = this.Stack.EndChildCount();
            if (_log != null)
            {
                _log.WriteLine("PopChildIndex {0}", value);
            }

            return(value);
        }
Example #6
0
 private StatefullStackNode(StatefullStackNode prev, int childsCount, ParserNode.RecursiveParserNode source)
 {
     this.Prev            = prev;
     this.ChildsCount     = childsCount;
     this.RecursionSource = source;
 }