Class: DBC::Parser

Inherits:
CTokenizer::LexerBase show all
Includes:
CTokenizer::Scoped
Defined in:
lib/dbc/dbc.rb

Direct Known Subclasses

OCLParser

Constant Summary

Constants included from CTokenizer

CTokenizer::EOF_TOKEN

Instance Attribute Summary

Attributes included from CTokenizer::Scoped

#scope

Attributes inherited from CTokenizer::LexerBase

#source

Instance Method Summary collapse

Methods included from CTokenizer::Scoped

#macro?, #process_scope, #start_of_line?

Methods inherited from CTokenizer::LexerBase

#match?, #post_match, #scan

Methods included from CTokenizer

check_token, #collect, #each, #error, error, line_count, #parse_error, #to_a, #token_error, #warning, whitespace?

Constructor Details

#initialize(str, file = nil, line = 1) ⇒ Parser

Returns a new instance of Parser.



156
157
158
159
160
161
162
# File 'lib/dbc/dbc.rb', line 156

def initialize(str, file=nil, line=1)
	super(str, file, line)
	@token_cache = CTokenizer::Cache.new(super.file, super.line)
	@scope = 0
	@macro = false
	@start_line = true # begining of file
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


168
169
170
# File 'lib/dbc/dbc.rb', line 168

def empty?
	@token_cache.empty? and super
end

#fileObject



172
173
174
175
176
177
178
# File 'lib/dbc/dbc.rb', line 172

def file
	if @token_cache.empty?
		super
	else
		@token_cache.file
	end
end

#lineObject



180
181
182
183
184
185
186
# File 'lib/dbc/dbc.rb', line 180

def line
	if @token_cache.empty?
		super
	else
		@token_cache.line
	end
end

#shiftObject



164
165
166
# File 'lib/dbc/dbc.rb', line 164

def shift
	process_scope(@token_cache.empty? ? super : @token_cache.shift)
end