예제 #1
0
        public ISourceTextReaderHolder Clone()
        {
            if (_holder == null)
            {
                _holder = new StringSourceTextReader(this);
            }

            return(_holder);
        }
예제 #2
0
        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;
        }
예제 #3
0
        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);
        }
예제 #4
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());
            }
        }
예제 #5
0
 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;
 }