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; }
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); }
public Token(string value, TokenTypeInfo info, int start, int end, Location loc) { Value = value; Info = info; Start = start; End = end; SourceLocation = loc; }
private static void SetTokenTypeInfo(TokenType tokenType, TokenTypeInfo info) { info.Type = tokenType; TokenTypes.Add(tokenType, info); }
private static void SetBinop(TokenType tokenType, TokenTypeInfo info) { info.BeforeExpr = true; SetTokenTypeInfo(tokenType, info); }
private static void SetKeyword(TokenType tokenType, TokenTypeInfo info) { info.Keyword = info.Label; Keywords.Add(info.Keyword, tokenType); SetTokenTypeInfo(tokenType, info); }