Class: CTokenizer::Cache

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

Overview

LexerBase

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Returns a new instance of Cache.



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

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

Instance Attribute Details

#cacheObject (readonly)

Returns the value of attribute cache.



272
273
274
# File 'lib/dbc/ctokenizer.rb', line 272

def cache
  @cache
end

#fileObject (readonly)

Returns the value of attribute file.



272
273
274
# File 'lib/dbc/ctokenizer.rb', line 272

def file
  @file
end

#lineObject (readonly)

Returns the value of attribute line.



272
273
274
# File 'lib/dbc/ctokenizer.rb', line 272

def line
  @line
end

Instance Method Details

#<<(t) ⇒ Object



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

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

#empty?Boolean

Returns:

  • (Boolean)


286
287
288
# File 'lib/dbc/ctokenizer.rb', line 286

def empty?
	@cache.empty?
end

#reset(file, line) ⇒ Object



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

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

#shiftObject



280
281
282
283
284
285
# File 'lib/dbc/ctokenizer.rb', line 280

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