From d781183f420b9fd144d877994cd4d4851fb520fd Mon Sep 17 00:00:00 2001 From: aamine Date: Mon, 20 Sep 2004 06:18:28 +0000 Subject: [PATCH] * ext/ripper/lib/ripper/tokenizer.rb: new file. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ ext/ripper/lib/ripper/tokenizer.rb | 35 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 ext/ripper/lib/ripper/tokenizer.rb diff --git a/ChangeLog b/ChangeLog index 086f48f092..b6ccfb21ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Sep 20 15:17:47 2004 Minero Aoki + + * ext/ripper/lib/ripper/tokenizer.rb: new file. + Mon Sep 20 15:13:52 2004 Minero Aoki * test/ripper/test_scanner_events.rb: test #lineno and #column. diff --git a/ext/ripper/lib/ripper/tokenizer.rb b/ext/ripper/lib/ripper/tokenizer.rb new file mode 100644 index 0000000000..0bd966ea51 --- /dev/null +++ b/ext/ripper/lib/ripper/tokenizer.rb @@ -0,0 +1,35 @@ +# +# ripper/tokenizer.rb +# +# Copyright (C) 2004 Minero Aoki +# +# This program is free software. +# You can distribute and/or modify this program under the Ruby License. +# For details of Ruby License, see ruby/COPYING. +# + +require 'ripper' + +class Ripper + + def Ripper.tokenize(str) + Tokenizer.tokenize(str) + end + + class Tokenizer < ::Ripper + def Tokenizer.tokenize(str) + new(str).tokenize + end + + def tokenize + @tokens = [] + parse + @tokens + end + + def on__scan(type, tok) + @tokens.push tok + end + end + +end