Class: ANTLR3::ChainedToken
- Inherits:
-
Struct
- Object
- Struct
- ANTLR3::ChainedToken
show all
- Includes:
- Token
- Defined in:
- lib/antlr3/token/linked.rb,
lib/antlr3/token/linked.rb
Constant Summary
Constant Summary
Constants included
from Constants
ANTLR3::Constants::BUILT_IN_TOKEN_NAMES, ANTLR3::Constants::DEFAULT, ANTLR3::Constants::DOWN, ANTLR3::Constants::EOF, ANTLR3::Constants::EOF_TOKEN, ANTLR3::Constants::EOR_TOKEN_TYPE, ANTLR3::Constants::HIDDEN, ANTLR3::Constants::INVALID_TOKEN, ANTLR3::Constants::INVALID_TOKEN_TYPE, ANTLR3::Constants::MEMO_RULE_FAILED, ANTLR3::Constants::MEMO_RULE_UNKNOWN, ANTLR3::Constants::MIN_TOKEN_TYPE, ANTLR3::Constants::SKIP_TOKEN, ANTLR3::Constants::UP
Instance Attribute Summary
Attributes included from Token
#channel, #column, #index, #input, #line, #start, #stop, #text, #type
Class Method Summary
(collapse)
Instance Method Summary
(collapse)
-
- (Object) <<(general_token)
-
- (Object) connect_to(token)
-
- (Object) delete
-
- (Boolean) eof?
-
- (Boolean) head?
-
- (ChainedToken) initialize(type = nil, channel = DEFAULT_CHANNEL, text = nil, input = nil, start = nil, stop = nil, index = 0, line = 0, column = 1, pred = nil, succ = nil)
constructor
A new instance of ChainedToken.
-
- (Boolean) tail?
-
- (Object) walk
-
- (Object) walk_backward
Methods included from Token
#<=>, #=~, #concrete?, #hidden?, #hide!, #imaginary?, #initialize_copy, #inspect, #name, #pretty_print, #range, #source_name, #source_text, #to_i, #to_s
Constructor Details
- (ChainedToken) initialize(type = nil, channel = DEFAULT_CHANNEL, text = nil, input = nil, start = nil, stop = nil, index = 0, line = 0, column = 1, pred = nil, succ = nil)
A new instance of ChainedToken
22
23
24
25
26
27
28
29
|
# File 'lib/antlr3/token/linked.rb', line 22
def initialize( type = nil, channel = DEFAULT_CHANNEL, text = nil,
input = nil, start = nil, stop = nil, index = 0,
line = 0, column = -1, pred = nil, succ = nil )
super
block_given? and yield( self )
self.text.nil? && self.start && self.stop and
self.text = self.input.substring( self.start, self.stop )
end
|
Class Method Details
+ (Object) create_eof(tail_token, channel)
18
19
20
|
# File 'lib/antlr3/token/linked.rb', line 18
def self.create_eof( tail_token, channel )
tail_token.connect_to( new( EOF, channel ) )
end
|
+ (Object) from_token(general_token, prev = nil)
11
12
13
14
15
16
|
# File 'lib/antlr3/token/linked.rb', line 11
def self.from_token( general_token, prev = nil )
new( token.type, token.channel,
token.text ? token.text.clone : nil,
token.input, token.start, token.stop,
-1, token.line, token.column, prev )
end
|
Instance Method Details
- (Object) <<(general_token)
53
54
55
56
57
|
# File 'lib/antlr3/token/linked.rb', line 53
def <<( general_token )
t = self.class.from_token( general_token, self )
t.index = index + 1
self.succ = t
end
|
- (Object) connect_to(token)
59
60
61
62
63
|
# File 'lib/antlr3/token/linked.rb', line 59
def connect_to( token )
token.prev = self
token.index = index + 1
self.succ = token
end
|
- (Object) delete
65
66
67
68
69
70
71
|
# File 'lib/antlr3/token/linked.rb', line 65
def delete
a, b = self.pred, self.succ
self.succ = self.pred = nil
a.succ = b if a
b.prev = a if b
return b
end
|
- (Boolean) eof?
49
50
51
|
# File 'lib/antlr3/token/linked.rb', line 49
def eof?
type == EOF
end
|
- (Boolean) head?
73
74
75
|
# File 'lib/antlr3/token/linked.rb', line 73
def head?
pred.nil?
end
|
- (Boolean) tail?
77
78
79
|
# File 'lib/antlr3/token/linked.rb', line 77
def tail?
succ.nil?
end
|
- (Object) walk
31
32
33
34
35
36
37
38
|
# File 'lib/antlr3/token/linked.rb', line 31
def walk
block_given? or return enum_for( __method__ )
ptr = self
begin
yield( ptr )
ptr = succ
end while ptr
end
|
- (Object) walk_backward
40
41
42
43
44
45
46
47
|
# File 'lib/antlr3/token/linked.rb', line 40
def walk_backward
block_given? or return enum_for( __method__ )
ptr = self
begin
yield( ptr )
ptr = pred
end while ptr
end
|