Class: DBC::Cache

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

Constant Summary

Constants included from CTokenizer

CTokenizer::CP_RESERVED, CTokenizer::C_RESERVED, 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.



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

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



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

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

#scan(re) ⇒ Object



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

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

#shiftObject



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

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