Class: CTokenizer::Cache

Inherits:
Object
  • Object
show all
Includes:
CTokenizer
Defined in:
lib/dbc/ctokenizer.rb

Overview

LexerBase

Constant Summary

Constants included from 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(file = nil, line = 1) ⇒ Cache

Returns a new instance of Cache.



260
261
262
263
264
# File 'lib/dbc/ctokenizer.rb', line 260

def initialize(file=nil, line=1)
	@cache = []
	@file = file
	@line = line
end

Instance Attribute Details

#cacheObject (readonly)

Returns the value of attribute cache.



265
266
267
# File 'lib/dbc/ctokenizer.rb', line 265

def cache
  @cache
end

#fileObject (readonly)

Returns the value of attribute file.



265
266
267
# File 'lib/dbc/ctokenizer.rb', line 265

def file
  @file
end

#lineObject (readonly)

Returns the value of attribute line.



265
266
267
# File 'lib/dbc/ctokenizer.rb', line 265

def line
  @line
end

Instance Method Details

#<<(t) ⇒ Object



270
271
272
# File 'lib/dbc/ctokenizer.rb', line 270

def <<(t)
	@cache << t
end

#empty?Boolean

Returns:

  • (Boolean)


278
279
280
# File 'lib/dbc/ctokenizer.rb', line 278

def empty?
	@cache.empty?
end

#reset(file, line) ⇒ Object



266
267
268
269
# File 'lib/dbc/ctokenizer.rb', line 266

def reset(file, line)
	@file = file
	@line = line
end

#shiftObject



273
274
275
276
277
# File 'lib/dbc/ctokenizer.rb', line 273

def shift
	t = @cache.shift
	@line += CTokenizer.line_count(t[1])
	t
end