Example #1
0
        public virtual void Reset(string text)
        {
            int length;

            if (text == null)
            {
                length = 0;
                _text  = new char[length + 1];
            }
            else
            {
                length = text.Length;
                _text  = new char[length + 1];
                text.CopyTo(0, _text, 0, length);
            }
            _text[length] = '\0';

            _pos            = 0;
            _start          = 0;
            _end            = 0;
            _lastTokenStart = 0;
            _lastTokenEnd   = 0;
            _line           = 0;
            _column         = 0;
            _lineStart      = 0;

            _token = new Token(null, TokenTypeInfo.GetTokenTypeInfo(TokenType.EOF), _pos, _pos, new Location(this.CurrentPosition(), this.CurrentPosition()));

            // The context stack is used to superficially track syntactic
            // context to predict whether a regular expression is allowed in a
            // given position.
            _contexts = new Stack <TokenContext>();
            _contexts.Push(TokenContext.BraceStatement);
            _exprAllowed = true;
        }
Example #2
0
        protected void FinishToken(TokenType type, string value)
        {
            _end = _pos;
            var preToken = this._token;

            _token = new Token(value, TokenTypeInfo.GetTokenTypeInfo(type), _start, _end, new Location(this._startPos, this.CurrentPosition()));
            this.UpdateContext(preToken);
        }