From 90c5c9161f53ee6e8400b3af2e967820ba0addd9 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Sun, 14 Feb 2016 19:25:35 +0100 Subject: remove templates, yay! --- lib/coderay/scanners/json5.rb | 38 +++----------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) (limited to 'lib/coderay/scanners/json5.rb') diff --git a/lib/coderay/scanners/json5.rb b/lib/coderay/scanners/json5.rb index dcfdd3f..8b0a8bd 100644 --- a/lib/coderay/scanners/json5.rb +++ b/lib/coderay/scanners/json5.rb @@ -41,43 +41,11 @@ module Scanners on %r/ \\ /x, :error, pop end - protected - - scan_tokens_code = <<-"RUBY" - def scan_tokens encoder, options#{ def_line = __LINE__; nil } - state = options[:state] || @state - - if [:string, :key].include? state - encoder.begin_group state - end - - states = [state] - - until eos? - case state -#{ @code.chomp.gsub(/^/, ' ') } - else - raise_inspect 'Unknown state: %p' % [state], encoder - end - end - - if options[:keep_state] - @state = state - end - - if [:string, :key].include? state - encoder.end_group state + def close_groups encoder, states + if [:string, :key].include? states.last + encoder.end_group states.last end - - encoder - end - RUBY - - if ENV['PUTS'] - puts CodeRay.scan(scan_tokens_code, :ruby).terminal - puts "callbacks: #{callbacks.size}" end - class_eval scan_tokens_code, __FILE__, def_line end -- cgit v1.2.1