Esempio n. 1
0
        public virtual int Mark()
        {
            if (markers == null)
            {
                markers = new List <CharStreamState>();
                markers.Add(null);   // depth 0 means no backtracking, leave blank
            }
            markDepth++;
            CharStreamState state = null;

            if (markDepth >= markers.Count)
            {
                state = new CharStreamState();
                markers.Add(state);
            }
            else
            {
                state = markers[markDepth];
            }
            state.p    = p;
            state.line = line;
            state.charPositionInLine = charPositionInLine;
            lastMarker = markDepth;
            return(markDepth);
        }
Esempio n. 2
0
        public virtual void Rewind(int m)
        {
            if (m < 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            //if (m > markDepth)
            //    throw new ArgumentException();

            CharStreamState state = markers[m];

            // restore stream state
            Seek(state.p);
            line = state.line;
            charPositionInLine = state.charPositionInLine;
            Release(m);
        }