ruby-changes:6711
From: yugui <ko1@a...>
Date: Sat, 26 Jul 2008 23:20:13 +0900 (JST)
Subject: [ruby-changes:6711] Ruby:r18227 (trunk): * sample/exyacc.rb: fixed NoMethodError(Kernel#sub!).
yugui 2008-07-26 23:19:50 +0900 (Sat, 26 Jul 2008) New Revision: 18227 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18227 Log: * sample/exyacc.rb: fixed NoMethodError(Kernel#sub!). replaced use of special variables with explicit IO operations. Modified files: trunk/ChangeLog trunk/sample/exyacc.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 18226) +++ ChangeLog (revision 18227) @@ -1,3 +1,9 @@ +Sat Jul 26 22:45:18 2008 Yuki Sonoda (Yugui) <yugui@y...> + + * sample/exyacc.rb: fixed NoMethodError(Kernel#sub!). + replaced use of special variables with explicit IO + operations. + Sat Jul 26 21:17:18 2008 Masaki Suketa <masaki.suketa@n...> * ext/win32ole/win32ole.c (Init_win32ole): add Index: sample/exyacc.rb =================================================================== --- sample/exyacc.rb (revision 18226) +++ sample/exyacc.rb (revision 18227) @@ -2,21 +2,19 @@ # usage: exyacc.rb [yaccfiles] # this is coverted from exyacc.pl in the camel book -$/ = nil - -while gets() - sbeg = $_.index("\n%%") + 1 - send = $_.rindex("\n%%") + 1 - $_ = $_[sbeg, send-sbeg] - sub!(/.*\n/, "") - gsub!(/'\{'/, "'\001'") - gsub!(/'\}'/, "'\002'") - gsub!(%r{\*/}, "\003\003") - gsub!(%r{/\*[^\003]*\003\003}, '') - while gsub!(/\{[^{}]*\}/, ''); end - gsub!(/'\001'/, "'{'") - gsub!(/'\002'/, "'}'") - while gsub!(/^[ \t]*\n(\s)/, '\1'); end - gsub!(/([:|])[ \t\n]+(\w)/, '\1 \2') - print $_ +ARGF.each(nil) do |source| + sbeg = source.index("\n%%") + 1 + send = source.rindex("\n%%") + 1 + grammer = source[sbeg, send-sbeg] + grammer.sub!(/.*\n/, "") + grammer.gsub!(/'\{'/, "'\001'") + grammer.gsub!(/'\}'/, "'\002'") + grammer.gsub!(%r{\*/}, "\003\003") + grammer.gsub!(%r{/\*[^\003]*\003\003}, '') + while grammer.gsub!(/\{[^{}]*\}/, ''); end + grammer.gsub!(/'\001'/, "'{'") + grammer.gsub!(/'\002'/, "'}'") + while grammer.gsub!(/^[ \t]*\n(\s)/, '\1'); end + grammer.gsub!(/([:|])[ \t\n]+(\w)/, '\1 \2') + print grammer end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/