mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
232e659214
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
20 lines
648 B
Ruby
20 lines
648 B
Ruby
#! /usr/local/bin/ruby -Kn
|
|
# usage: exyacc.rb [yaccfiles]
|
|
# this is coverted from exyacc.pl in the camel book
|
|
|
|
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
|