Class: RParsec::Token

Inherits:
Object
  • Object
show all
Extended by:
DefHelper
Defined in:
lib/rparsec/token.rb

Overview

Represents a token during lexical analysis.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DefHelper

def_ctor, def_mutable, def_readable

Instance Attribute Details

#indexObject (readonly)

The starting index of the matched range



26
27
28
# File 'lib/rparsec/token.rb', line 26

def index
  @index
end

#kindObject (readonly)

The type of the token



16
17
18
# File 'lib/rparsec/token.rb', line 16

def kind
  @kind
end

#textObject (readonly)

The text of the matched range



21
22
23
# File 'lib/rparsec/token.rb', line 21

def text
  @text
end

Instance Method Details

#lengthObject

The length of the token.



31
32
33
# File 'lib/rparsec/token.rb', line 31

def length
  @text.length
end

#to_sObject

String representation of the token.



38
39
40
# File 'lib/rparsec/token.rb', line 38

def to_s
  "#{@kind}: #{@text}"
end