Class: Antlr4::Runtime::CommonTokenFactory
- Inherits:
-
Object
- Object
- Antlr4::Runtime::CommonTokenFactory
- Includes:
- Singleton
- Defined in:
- lib/antlr4/runtime/common_token_factory.rb
Instance Method Summary collapse
- #create(source, type, text, channel, start, stop, line, char_position_in_line) ⇒ Object
- #create_simple(type, text) ⇒ Object
-
#initialize(copy_text = false) ⇒ CommonTokenFactory
constructor
A new instance of CommonTokenFactory.
Constructor Details
#initialize(copy_text = false) ⇒ CommonTokenFactory
Returns a new instance of CommonTokenFactory.
6 7 8 9 |
# File 'lib/antlr4/runtime/common_token_factory.rb', line 6 def initialize(copy_text = false) @copy_text = false @copy_text = copy_text end |
Instance Method Details
#create(source, type, text, channel, start, stop, line, char_position_in_line) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/antlr4/runtime/common_token_factory.rb', line 11 def create(source, type, text, channel, start, stop, line, char_position_in_line) t = CommonToken.create1(source, type, channel, start, stop) t.line = line t.char_position_in_line = char_position_in_line if !text.nil? t._text = text elsif @copy_text && !source.b.nil? t.set_text(source.b.text(Interval.of(start, stop))) end t end |
#create_simple(type, text) ⇒ Object
24 25 26 |
# File 'lib/antlr4/runtime/common_token_factory.rb', line 24 def create_simple(type, text) CommonToken.create2(type, text) end |