Class: RParsec::Token
- Inherits:
-
Object
- Object
- RParsec::Token
- Extended by:
- DefHelper
- Defined in:
- lib/rparsec/token.rb
Overview
Represents a token during lexical analysis.
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
The starting index of the matched range.
-
#kind ⇒ Object
readonly
The type of the token.
-
#text ⇒ Object
readonly
The text of the matched range.
Instance Method Summary collapse
-
#length ⇒ Object
The length of the token.
-
#to_s ⇒ Object
String representation of the token.
Methods included from DefHelper
def_ctor, def_mutable, def_readable
Instance Attribute Details
#index ⇒ Object (readonly)
The starting index of the matched range
26 27 28 |
# File 'lib/rparsec/token.rb', line 26 def index @index end |
#kind ⇒ Object (readonly)
The type of the token
16 17 18 |
# File 'lib/rparsec/token.rb', line 16 def kind @kind end |
#text ⇒ Object (readonly)
The text of the matched range
21 22 23 |
# File 'lib/rparsec/token.rb', line 21 def text @text end |
Instance Method Details
#length ⇒ Object
The length of the token.
31 32 33 |
# File 'lib/rparsec/token.rb', line 31 def length @text.length end |
#to_s ⇒ Object
String representation of the token.
38 39 40 |
# File 'lib/rparsec/token.rb', line 38 def to_s "#{@kind}: #{@text}" end |