Class: CTokenizer::Splitter

Inherits:
LexerBase show all
Defined in:
lib/caphir/ctokenizer.rb

Overview

TODO: what is this for ?

Constant Summary

Constants included from CTokenizer

CP_RESERVED, C_RESERVED, EOF_TOKEN

Instance Attribute Summary collapse

Attributes included from Sourced

#source

Instance Method Summary collapse

Methods included from Sourced

#empty?, #file, #file=, #line, #line=, #match?

Methods included from CTokenizer

#collect, #each, #error, error, line_count, #parse_error, #to_a, #token_error, #unmatched_error, #warning

Constructor Details

#initialize(out, source, file = nil, line = 1) ⇒ Splitter

Returns a new instance of Splitter.



301
302
303
304
305
# File 'lib/caphir/ctokenizer.rb', line 301

def initialize(out, source, file=nil, line=1)
	super(source, file, line)
	@out = out
	@last_line = line
end

Instance Attribute Details

#last_lineObject (readonly)

Returns the value of attribute last_line.



307
308
309
# File 'lib/caphir/ctokenizer.rb', line 307

def last_line
  @last_line
end

Instance Method Details

#reset(new_out) ⇒ Object



321
322
323
324
325
326
# File 'lib/caphir/ctokenizer.rb', line 321

def reset(new_out)
	old_out = @out
	@out = new_out
	@last_line = self.line
	old_out
end

#scan(regexp) ⇒ Object



315
316
317
318
319
# File 'lib/caphir/ctokenizer.rb', line 315

def scan(regexp)
	s = @source.scan(regexp)
	@out << [:UNKNOWN, s]
	s
end

#shiftObject



309
310
311
312
313
# File 'lib/caphir/ctokenizer.rb', line 309

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