Class: Preprocessor::Tokens
- Inherits:
-
Object
- Object
- Preprocessor::Tokens
show all
- Includes:
- CTokenizer
- Defined in:
- lib/dbc/preprocessor.rb
Constant Summary
Constants included
from CTokenizer
CTokenizer::EOF_TOKEN
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from CTokenizer
check_token, #collect, #each, #error, error, line_count, #parse_error, #to_a, #token_error, #warning, whitespace?
Constructor Details
#initialize(source) ⇒ Tokens
Returns a new instance of Tokens.
22
23
24
25
|
# File 'lib/dbc/preprocessor.rb', line 22
def initialize(source)
@tokens = []
self.add_source(source)
end
|
Instance Attribute Details
#start_line ⇒ Object
Returns the value of attribute start_line.
27
28
29
|
# File 'lib/dbc/preprocessor.rb', line 27
def start_line
@start_line
end
|
Instance Method Details
#add_source(source) ⇒ Object
29
30
31
32
|
# File 'lib/dbc/preprocessor.rb', line 29
def add_source(source)
@tokens.push(source)
@start_line = true end
|
#base? ⇒ Boolean
46
47
48
|
# File 'lib/dbc/preprocessor.rb', line 46
def base?
@tokens.length == 1
end
|
#empty? ⇒ Boolean
50
51
52
|
# File 'lib/dbc/preprocessor.rb', line 50
def empty?
@tokens.length == 1 and @tokens.last.empty?
end
|
#file ⇒ Object
54
55
56
|
# File 'lib/dbc/preprocessor.rb', line 54
def file
@tokens.last.file
end
|
#line ⇒ Object
58
59
60
|
# File 'lib/dbc/preprocessor.rb', line 58
def line
@tokens.last.line
end
|
#match?(rexp) ⇒ Boolean
34
35
36
|
# File 'lib/dbc/preprocessor.rb', line 34
def match?(rexp)
@tokens.last.match?(rexp)
end
|
#post_match ⇒ Object
42
43
44
|
# File 'lib/dbc/preprocessor.rb', line 42
def post_match
@tokens.last.post_match
end
|
#scan(rexp) ⇒ Object
38
39
40
|
# File 'lib/dbc/preprocessor.rb', line 38
def scan(rexp)
@tokens.last.scan(rexp)
end
|
#shift ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/dbc/preprocessor.rb', line 62
def shift
t = @tokens.last.shift
while !t[0] and @tokens.length > 1
@tokens.pop
t = @tokens.last.shift
end case t[0]
when :NEWLINE
@start_line = true
when :SPACE, :COMMENT, false
else
@start_line = false
end t
end
|