1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
yugui 2008-07-26 14:19:50 +00:00
parent 1f9fce063f
commit 232e659214
2 changed files with 21 additions and 17 deletions

View file

@ -1,3 +1,9 @@
Sat Jul 26 22:45:18 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
* 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@nifty.ne.jp> Sat Jul 26 21:17:18 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (Init_win32ole): add * ext/win32ole/win32ole.c (Init_win32ole): add

View file

@ -2,21 +2,19 @@
# usage: exyacc.rb [yaccfiles] # usage: exyacc.rb [yaccfiles]
# this is coverted from exyacc.pl in the camel book # this is coverted from exyacc.pl in the camel book
$/ = nil ARGF.each(nil) do |source|
sbeg = source.index("\n%%") + 1
while gets() send = source.rindex("\n%%") + 1
sbeg = $_.index("\n%%") + 1 grammer = source[sbeg, send-sbeg]
send = $_.rindex("\n%%") + 1 grammer.sub!(/.*\n/, "")
$_ = $_[sbeg, send-sbeg] grammer.gsub!(/'\{'/, "'\001'")
sub!(/.*\n/, "") grammer.gsub!(/'\}'/, "'\002'")
gsub!(/'\{'/, "'\001'") grammer.gsub!(%r{\*/}, "\003\003")
gsub!(/'\}'/, "'\002'") grammer.gsub!(%r{/\*[^\003]*\003\003}, '')
gsub!(%r{\*/}, "\003\003") while grammer.gsub!(/\{[^{}]*\}/, ''); end
gsub!(%r{/\*[^\003]*\003\003}, '') grammer.gsub!(/'\001'/, "'{'")
while gsub!(/\{[^{}]*\}/, ''); end grammer.gsub!(/'\002'/, "'}'")
gsub!(/'\001'/, "'{'") while grammer.gsub!(/^[ \t]*\n(\s)/, '\1'); end
gsub!(/'\002'/, "'}'") grammer.gsub!(/([:|])[ \t\n]+(\w)/, '\1 \2')
while gsub!(/^[ \t]*\n(\s)/, '\1'); end print grammer
gsub!(/([:|])[ \t\n]+(\w)/, '\1 \2')
print $_
end end