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 )); }
private void PushChildIndex() { if (_log != null) { _log.WriteLine("PushChildIndex 0"); } this.Stack = this.Stack.StartChildCount(); }
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()); } }
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); }
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); }
private StatefullStackNode(StatefullStackNode prev, int childsCount, ParserNode.RecursiveParserNode source) { this.Prev = prev; this.ChildsCount = childsCount; this.RecursionSource = source; }