Class: Metal::Generator::LiteralQuotedToken

Inherits:
Object
  • Object
show all
Defined in:
lib/metal/generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ LiteralQuotedToken

Returns a new instance of LiteralQuotedToken.



347
348
349
# File 'lib/metal/generator.rb', line 347

def initialize(str)
	@str = str
end

Instance Method Details

#generate(ctx, source) ⇒ Object



351
352
353
354
355
356
357
358
359
# File 'lib/metal/generator.rb', line 351

def generate(ctx, source)
	str, str_len = Generator.escape_quoated_string(@str)
	if str_len == 1
		# FIXME multibyte character optimize
		source << "ctx->act_char(\"#{str}\",#{str_len});\n"
	else
		source << "ctx->act_token(\"#{str}\",#{str_len});\n"
	end
end

#preprocess(ctx) ⇒ Object



350
# File 'lib/metal/generator.rb', line 350

def preprocess(ctx) end