Class: DBC::Parser

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

Direct Known Subclasses

OCLParser

Instance Attribute Summary

Attributes included from CTokenizer::Scoped

#scope

Instance Method Summary collapse

Methods included from CTokenizer::Scoped

#macro?, #process_scope, #start_of_line?

Methods inherited from CTokenizer::LexerBase

#peek_nonspace

Methods included from CTokenizer

check_string, check_token, #collect, create_newlines, #each, error, #error, join, line_count, #parse_error, split, split_token, #to_a, #token_error, #warning, whitespace?

Constructor Details

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

Returns a new instance of Parser.



150
151
152
153
154
155
156
# File 'lib/dbc/dbc.rb', line 150

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)


162
163
164
# File 'lib/dbc/dbc.rb', line 162

def empty?
	@token_cache.empty? and super
end

#fileObject



166
167
168
169
170
171
172
# File 'lib/dbc/dbc.rb', line 166

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

#lineObject



174
175
176
177
178
179
180
# File 'lib/dbc/dbc.rb', line 174

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

#shiftObject



158
159
160
# File 'lib/dbc/dbc.rb', line 158

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