Class: Dhaka::Lexeme
- Inherits:
-
Object
- Object
- Dhaka::Lexeme
- Defined in:
- lib/dhaka/lexer/lexeme.rb
Overview
Represents a portion of the input string that has been recognized as matching a given lexer pattern.
Instance Attribute Summary collapse
-
#characters ⇒ Object
The pattern matched by this lexeme.
-
#input_position ⇒ Object
readonly
input_position
is the index in the input stream that this lexeme starts at. -
#pattern ⇒ Object
The pattern matched by this lexeme.
Instance Method Summary collapse
-
#<<(char) ⇒ Object
:nodoc:.
-
#accepted? ⇒ Boolean
:nodoc:.
-
#concat(chars) ⇒ Object
:nodoc:.
-
#initialize(input_position) ⇒ Lexeme
constructor
:nodoc:.
-
#value ⇒ Object
The substring of the input stream that this lexeme is comprised of.
Constructor Details
#initialize(input_position) ⇒ Lexeme
:nodoc:
10 11 12 13 |
# File 'lib/dhaka/lexer/lexeme.rb', line 10 def initialize(input_position) #:nodoc: @input_position = input_position @characters = [] end |
Instance Attribute Details
#characters ⇒ Object
The pattern matched by this lexeme.
5 6 7 |
# File 'lib/dhaka/lexer/lexeme.rb', line 5 def characters @characters end |
#input_position ⇒ Object (readonly)
input_position
is the index in the input stream that this lexeme starts at.
8 9 10 |
# File 'lib/dhaka/lexer/lexeme.rb', line 8 def input_position @input_position end |
#pattern ⇒ Object
The pattern matched by this lexeme.
5 6 7 |
# File 'lib/dhaka/lexer/lexeme.rb', line 5 def pattern @pattern end |
Instance Method Details
#<<(char) ⇒ Object
:nodoc:
24 25 26 |
# File 'lib/dhaka/lexer/lexeme.rb', line 24 def << char #:nodoc: characters << char end |
#accepted? ⇒ Boolean
:nodoc:
20 21 22 |
# File 'lib/dhaka/lexer/lexeme.rb', line 20 def accepted? #:nodoc: pattern end |
#concat(chars) ⇒ Object
:nodoc:
28 29 30 |
# File 'lib/dhaka/lexer/lexeme.rb', line 28 def concat chars #:nodoc: characters.concat chars end |
#value ⇒ Object
The substring of the input stream that this lexeme is comprised of.
16 17 18 |
# File 'lib/dhaka/lexer/lexeme.rb', line 16 def value characters.join end |