summaryrefslogtreecommitdiff
path: root/demo/demo_scanner.rb
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2006-10-17 09:44:47 +0000
committermurphy <murphy@rubychan.de>2006-10-17 09:44:47 +0000
commit70690604e7ea6fd6b89c256a52d65a308ad0fe77 (patch)
tree8f681315abf127e16019b3de92e16899517e3db4 /demo/demo_scanner.rb
parent3078dddb4cb2c5f09ff92bcd56401f75b79a13d1 (diff)
downloadcoderay-70690604e7ea6fd6b89c256a52d65a308ad0fe77.tar.gz
Moved demos to sample/.
Diffstat (limited to 'demo/demo_scanner.rb')
-rw-r--r--demo/demo_scanner.rb36
1 files changed, 0 insertions, 36 deletions
diff --git a/demo/demo_scanner.rb b/demo/demo_scanner.rb
deleted file mode 100644
index 6a0245e..0000000
--- a/demo/demo_scanner.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-require 'coderay'
-
-c_code = "if (*p == '{') nest++;"
-puts 'C Code: ' + c_code
-puts
-
-c_scanner = CodeRay::Scanners[:c].new c_code
-
-puts '> print only operators:'
-for text, kind in c_scanner
- print text if kind == :operator
-end
-puts
-puts '-' * 30
-puts
-
-ruby_code = %q!ruby_code(:can, BE, %r[q[ui]te #{ /comple/x },] => $-s, &?\xee)!
-puts 'Ruby Code: ' + ruby_code
-puts
-
-ruby_scanner = CodeRay::Scanners[:ruby].new ruby_code
-
-puts '> has a string?'
-puts ruby_scanner.
- any? { |text, kind| kind == :string }
-puts
-
-puts '> number of regexps?'
-puts ruby_scanner.
- select { |token| token == [:open, :regexp] }.size
-puts
-
-puts '> has a string?'
-puts ruby_scanner.
- reject { |text, kind| not text.is_a? String }.
- map { |text, kind| %("#{text}" (#{kind})) }.join(', ')