Class: Preprocessor::SourceTokens
- Inherits:
-
Object
- Object
- Preprocessor::SourceTokens
show all
- Includes:
- CTokenizer
- Defined in:
- lib/caphir/define.rb
Constant Summary
Constants included
from CTokenizer
CTokenizer::CP_RESERVED, CTokenizer::C_RESERVED, CTokenizer::EOF_TOKEN
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from CTokenizer
#collect, #each, #error, error, line_count, #parse_error, #to_a, #token_error, #unmatched_error, #warning
Constructor Details
Returns a new instance of SourceTokens.
69
70
71
72
|
# File 'lib/caphir/define.rb', line 69
def initialize(source)
@tokens = []
self.add_source(source)
end
|
Instance Attribute Details
#start_line ⇒ Object
Returns the value of attribute start_line.
74
75
76
|
# File 'lib/caphir/define.rb', line 74
def start_line
@start_line
end
|
Instance Method Details
#add_source(source) ⇒ Object
76
77
78
79
|
# File 'lib/caphir/define.rb', line 76
def add_source(source)
@tokens.push(source)
@start_line = true end
|
#base? ⇒ Boolean
89
90
91
|
# File 'lib/caphir/define.rb', line 89
def base?
@tokens.length == 1
end
|
#empty? ⇒ Boolean
93
94
95
|
# File 'lib/caphir/define.rb', line 93
def empty?
@tokens.length == 1 and @tokens.last.empty?
end
|
#file ⇒ Object
97
98
99
|
# File 'lib/caphir/define.rb', line 97
def file
@tokens.last.file
end
|
#file=(val) ⇒ Object
100
101
102
|
# File 'lib/caphir/define.rb', line 100
def file=(val)
@tokens.last.file = val
end
|
#line ⇒ Object
104
105
106
|
# File 'lib/caphir/define.rb', line 104
def line
@tokens.last.line
end
|
#line=(val) ⇒ Object
107
108
109
|
# File 'lib/caphir/define.rb', line 107
def line=(val)
@tokens.last.line = val
end
|
#match?(regexp) ⇒ Boolean
85
86
87
|
# File 'lib/caphir/define.rb', line 85
def match?(regexp)
@tokens.last.match?(regexp)
end
|
#scan(regexp) ⇒ Object
81
82
83
|
# File 'lib/caphir/define.rb', line 81
def scan(regexp)
@tokens.last.scan(regexp)
end
|
#shift ⇒ Object
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/caphir/define.rb', line 111
def shift
t = @tokens.last.shift
while !t[0] and @tokens.length > 1
@tokens.pop
t = @tokens.last.shift
end t_sym = t[0]
unless t_sym == :SPACE or t_sym == :COMMENT
@start_line = (t_sym == :NEWLINE)
end
t
end
|