From 232e6592149d8fae60b148797fcb5d315472f7e5 Mon Sep 17 00:00:00 2001 From: yugui Date: Sat, 26 Jul 2008 14:19:50 +0000 Subject: [PATCH] * sample/exyacc.rb: fixed NoMethodError(Kernel#sub!). replaced use of special variables with explicit IO operations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ sample/exyacc.rb | 32 +++++++++++++++----------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index c8c6b804fd..0ec75bbdef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Jul 26 22:45:18 2008 Yuki Sonoda (Yugui) + + * 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 * ext/win32ole/win32ole.c (Init_win32ole): add diff --git a/sample/exyacc.rb b/sample/exyacc.rb index 5818825e25..c96ebfd676 100644 --- a/sample/exyacc.rb +++ b/sample/exyacc.rb @@ -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