Class: DBC::Cache

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

Constant Summary

Constants included from CTokenizer

CTokenizer::EOF_TOKEN

Instance Attribute Summary

Attributes inherited from CTokenizer::LexerBase

#source

Instance Method Summary collapse

Methods inherited from CTokenizer::LexerBase

#empty?, #file, #line, #match?, #post_match

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) ⇒ Cache

Returns a new instance of Cache.



30
31
32
33
# File 'lib/dbc/dbc.rb', line 30

def initialize(str, file=nil, line=1)
	super(str, file, line)
	@token_cache = CTokenizer::Cache.new(super.file, super.line)
end

Instance Method Details

#resetObject



47
48
49
50
51
# File 'lib/dbc/dbc.rb', line 47

def reset
	cache = @token_cache
	@token_cache = CTokenizer::Cache.new(self.file, self.line)
	cache
end

#scan(re) ⇒ Object



35
36
37
38
39
# File 'lib/dbc/dbc.rb', line 35

def scan(re)
	str = super
	@token_cache << [:UNKNOWN, str.freeze].freeze
	str
end

#shiftObject



41
42
43
44
45
# File 'lib/dbc/dbc.rb', line 41

def shift
	t = super
	@token_cache << t
	t
end