You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the Definitive ANTLR 4 Reference: An ANTLR lexer creates a Token object after matching a lexical rule. Each request for a token starts in Lexer.nextToken(), which calls emit() once it has identified a token. emit() collects information from the current state of the lexer to build the token. It accesses fields _type, _text, _channel, _tokenStartCharIndex, _tokenStartLine, and _tokenStartCharPositionInLine. You can set the state of these with the various setter methods such as setType(). For example, the following rule turns enum into an identifier if enumIsKeyword is false: ENUM : 'enum' {if (!enumIsKeyword) setType(Identifier);} ;
Unfortunately, for the TypeScript target, some of the setters and getters are missing. We really need these.
channel
Note, some of the fields are directly accessible rather than through getters and setters, some with leading underscore, some not.
If I want to override emit(), I'll need a token factory. Otherwise, I will be making an assumption that the token implementation is always CommonToken.
The text was updated successfully, but these errors were encountered:
According to the Definitive ANTLR 4 Reference:
An ANTLR lexer creates a Token object after matching a lexical rule. Each request for a token starts in Lexer.nextToken(), which calls emit() once it has identified a token. emit() collects information from the current state of the lexer to build the token. It accesses fields _type, _text, _channel, _tokenStartCharIndex, _tokenStartLine, and _tokenStartCharPositionInLine. You can set the state of these with the various setter methods such as setType(). For example, the following rule turns enum into an identifier if enumIsKeyword is false: ENUM : 'enum' {if (!enumIsKeyword) setType(Identifier);} ;
Unfortunately, for the TypeScript target, some of the setters and getters are missing. We really need these.
Note, some of the fields are directly accessible rather than through getters and setters, some with leading underscore, some not.
If I want to override
emit()
, I'll need a token factory. Otherwise, I will be making an assumption that the token implementation is always CommonToken.The text was updated successfully, but these errors were encountered: