Class: CTokenizer::LexerBase

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

Overview

wraps a lexer and uses that to produce new tokens

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

Constructor Details

#initialize(str, file = nil, line = 1) ⇒ LexerBase

Returns a new instance of LexerBase.



216
217
218
219
220
221
222
# File 'lib/dbc/ctokenizer.rb', line 216

def initialize(str, file=nil, line=1)
	if (str.class <= String)
		@source = Lexer.new(str, file, line)
	else
		@source = str
	end
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


237
238
239
# File 'lib/dbc/ctokenizer.rb', line 237

def empty?
	@source.empty?
end

#fileObject



224
225
226
# File 'lib/dbc/ctokenizer.rb', line 224

def file
	@source.file
end

#lineObject



227
228
229
# File 'lib/dbc/ctokenizer.rb', line 227

def line
	@source.line
end

#shiftObject



231
232
233
234
235
# File 'lib/dbc/ctokenizer.rb', line 231

def shift
	t = @source.shift
	CTokenizer.check_token(t)
	t
end