Class: Attentive::Token
- Inherits:
-
Object
show all
- Defined in:
- lib/attentive/token.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(pos = nil) ⇒ Token
Returns a new instance of Token.
5
6
7
|
# File 'lib/attentive/token.rb', line 5
def initialize(pos=nil)
@begin = pos
end
|
Instance Attribute Details
#begin ⇒ Object
Returns the value of attribute begin.
3
4
5
|
# File 'lib/attentive/token.rb', line 3
def begin
@begin
end
|
Instance Method Details
#==(other) ⇒ Object
13
14
15
|
# File 'lib/attentive/token.rb', line 13
def ==(other)
self.class == other.class
end
|
#ambiguous? ⇒ Boolean
17
18
19
|
# File 'lib/attentive/token.rb', line 17
def ambiguous?
false
end
|
#end ⇒ Object
9
10
11
|
# File 'lib/attentive/token.rb', line 9
def end
self.begin + to_s.length
end
|
#entity? ⇒ Boolean
21
22
23
|
# File 'lib/attentive/token.rb', line 21
def entity?
false
end
|
#eof? ⇒ Boolean
33
34
35
|
# File 'lib/attentive/token.rb', line 33
def eof?
false
end
|
#inspect ⇒ Object
46
47
48
|
# File 'lib/attentive/token.rb', line 46
def inspect
"<#{self.class.name ? self.class.name.split("::").last : "Entity"} #{to_s.inspect}#{" #{self.begin}" if self.begin}>"
end
|
#matches?(cursor) ⇒ Boolean
37
38
39
40
41
42
43
44
|
# File 'lib/attentive/token.rb', line 37
def matches?(cursor)
if self == cursor.peek
cursor.pop
return true
end
false
end
|
#skippable? ⇒ Boolean
29
30
31
|
# File 'lib/attentive/token.rb', line 29
def skippable?
false
end
|
#whitespace? ⇒ Boolean
25
26
27
|
# File 'lib/attentive/token.rb', line 25
def whitespace?
false
end
|