Method: Lexer#initialize
- Defined in:
- lib/antlr4/Lexer.rb
#initialize(_input) ⇒ Lexer
Returns a new instance of Lexer.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/antlr4/Lexer.rb', line 21 def initialize(_input) super() @input = _input @factory = CommonTokenFactory.DEFAULT @tokenFactorySourcePair = [self, _input] @interp = nil # child classes must populate this # The goal of all lexer rules/methods is to create a token object. # self is an instance variable as multiple rules may collaborate to # create a single token. nextToken will return self object after # matching lexer rule(s). If you subclass to allow multiple token # emissions, then set self to the last token to be matched or # something nonnull so that the auto token emit mechanism will not # emit another token. @token = nil # What character index in the stream did the current token start at? # Needed, for example, to get the text for current token. Set at # the start of nextToken. @tokenStartCharIndex = -1 # The line on which the first character of the token resides#/ @tokenStartLine = -1 # The character position of first character within the line#/ @tokenStartColumn = -1 # Once we see EOF on char stream, next token will be EOF. # If you have DONE : EOF ; then you see DONE EOF. @hitEOF = false # The channel number for the current token#/ @channel = Token::DEFAULT_CHANNEL # The token type for the current token#/ @type = Token::INVALID_TYPE @modeStack = Array.new @mode = Lexer::DEFAULT_MODE # You can set the text for the current token to override what is in # the input char buffer. Use setText() or can set self instance var. #/ @text = nil end |