mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
b1e943f465
commit
d781183f42
2 changed files with 39 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
|||
Mon Sep 20 15:17:47 2004 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* ext/ripper/lib/ripper/tokenizer.rb: new file.
|
||||
|
||||
Mon Sep 20 15:13:52 2004 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* test/ripper/test_scanner_events.rb: test #lineno and #column.
|
||||
|
|
35
ext/ripper/lib/ripper/tokenizer.rb
Normal file
35
ext/ripper/lib/ripper/tokenizer.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue