public ISourceTextReaderHolder Clone() { if (_holder == null) { _holder = new StringSourceTextReader(this); } return(_holder); }
internal ParserState(IndentedWriter log, ParserNode curr, ParserNode prev, bool?lastTerminalFailed, ISourceTextReader reader, ISourceTextReaderHolder holder = null) { this.CurrNode = curr; this.PrevNode = prev; this.ResultReconstructed = false; _log = log; this.LastTerminalFailed = lastTerminalFailed; _reader = reader; _readerHolder = holder; }
public bool Move(int offset) { if (offset == 0) { return(true); } int i, j; int step = Math.Sign(offset); int count = Math.Abs(offset); var line = _line; var column = _column; for (i = _pos, j = 0; i < _text.Length && i >= 0 && j < count; i += step, j++, column += step) { var c = _text[i]; if (c == _newLine) { line += step; column = step > 0 ? -step : this.FindLineStart(i - 1); } } if (column < 0) { throw new NotImplementedException(""); } bool ok; if (i <= _text.Length && i >= 0) { ok = true; _holder = null; _pos = i; _line = line; _column = column; } else { ok = false; } return(ok); }
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()); } }
protected ParserTreeState(IndentedWriter log, ParserNode prev, ParsingTreeNode.TemporaryGroup treeNode, bool?lastTerminalFailed, ISourceTextReader reader, ISourceTextReaderHolder holder = null) : base(log, treeNode.GrammarNode, prev, lastTerminalFailed, reader, holder) { this.TreeNode = treeNode; }