Class: Metal::Generator::LiteralToken
- Inherits:
-
Object
- Object
- Metal::Generator::LiteralToken
- Defined in:
- lib/metal/generator.rb
Instance Method Summary collapse
- #generate(ctx, source) ⇒ Object
-
#initialize(str) ⇒ LiteralToken
constructor
A new instance of LiteralToken.
- #preprocess(ctx) ⇒ Object
Constructor Details
#initialize(str) ⇒ LiteralToken
Returns a new instance of LiteralToken.
363 364 365 |
# File 'lib/metal/generator.rb', line 363 def initialize(str) @str = str end |
Instance Method Details
#generate(ctx, source) ⇒ Object
367 368 369 370 371 372 373 374 375 376 |
# File 'lib/metal/generator.rb', line 367 def generate(ctx, source) str = @str str_len = Generator.string_length(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
366 |
# File 'lib/metal/generator.rb', line 366 def preprocess(ctx) end |