diff options
author | Kornelius Kalnbach <murphy@rubychan.de> | 2017-04-09 18:38:53 +0200 |
---|---|---|
committer | Kornelius Kalnbach <murphy@rubychan.de> | 2017-04-09 18:38:53 +0200 |
commit | 1bdaeef6c43436e4984f5b96cb17618f82832225 (patch) | |
tree | 5189302c0749660870d079898ce090e41b92f8fb /lib/coderay/simple_scanner.rb | |
parent | 7a02cdded08dd232319eae17998abc877efb58cb (diff) | |
download | coderay-1bdaeef6c43436e4984f5b96cb17618f82832225.tar.gz |
starting with SimpleScanner
Diffstat (limited to 'lib/coderay/simple_scanner.rb')
-rw-r--r-- | lib/coderay/simple_scanner.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/coderay/simple_scanner.rb b/lib/coderay/simple_scanner.rb new file mode 100644 index 0000000..6873f88 --- /dev/null +++ b/lib/coderay/simple_scanner.rb @@ -0,0 +1,40 @@ +require 'set' + +module CodeRay + module Scanners + class SimpleScanner < Scanner + extend SimpleScannerDSL + + class << self + def define_scan_tokens! + if ENV['PUTS'] + puts CodeRay.scan(scan_tokens_code, :ruby).terminal + puts "callbacks: #{callbacks.size}" + end + + class_eval <<-RUBY +def scan_tokens encoder, options +#{ scan_tokens_code.chomp.gsub(/^/, ' ' * 2) } +end + RUBY + end + end + + def scan_tokens tokens, options + self.class.define_scan_tokens! + + scan_tokens tokens, options + end + + protected + + def setup + @state = :initial + end + + def close_groups encoder, states + # TODO + end + end + end +end
\ No newline at end of file |