Class: Dhaka::Lexeme
- Inherits:
-
Object
- Object
- Dhaka::Lexeme
- Defined in:
- lib/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
readonly
Returns the value of attribute characters.
-
#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:
11 12 13 14 |
# File 'lib/lexer/lexeme.rb', line 11 def initialize(input_position) #:nodoc: @input_position = input_position @characters = [] end |
Instance Attribute Details
#characters ⇒ Object (readonly)
Returns the value of attribute characters.
9 10 11 |
# File 'lib/lexer/lexeme.rb', line 9 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/lexer/lexeme.rb', line 8 def input_position @input_position end |
#pattern ⇒ Object
The pattern matched by this lexeme.
5 6 7 |
# File 'lib/lexer/lexeme.rb', line 5 def pattern @pattern end |
Instance Method Details
#<<(char) ⇒ Object
:nodoc:
25 26 27 |
# File 'lib/lexer/lexeme.rb', line 25 def << char #:nodoc: @characters << char end |
#accepted? ⇒ Boolean
:nodoc:
21 22 23 |
# File 'lib/lexer/lexeme.rb', line 21 def accepted? #:nodoc: pattern end |
#concat(chars) ⇒ Object
:nodoc:
29 30 31 |
# File 'lib/lexer/lexeme.rb', line 29 def concat chars #:nodoc: @characters.concat chars end |
#value ⇒ Object
The substring of the input stream that this lexeme is comprised of.
17 18 19 |
# File 'lib/lexer/lexeme.rb', line 17 def value characters.join end |