Windowsの 1.9.1 で gem で racc
というわけで、Windows (XP SP3) で Ruby-1.9.1 で gem から Racc をインストールする。
C:\Program Files\Ruby-1.9.1\bin>gem update --system Updating RubyGems Nothing to update C:\Program Files\Ruby-1.9.1\bin>gem install racc Building native extensions. This could take a while... ERROR: Error installing racc: ERROR: Failed to build gem native extension. "C:/Program Files/Ruby-1.9.1/bin/ruby.exe" extconf.rb install racc extconf.rb:3:in ``': No such file or directory - uname -p (Errno::ENOENT) from extconf.rb:3:in `<main>' Gem files will remain installed in C:/Program Files/Ruby-1.9.1/lib/ruby/gems/1.9 .1/gems/racc-1.4.6 for inspection. Results logged to C:/Program Files/Ruby-1.9.1/lib/ruby/gems/1.9.1/gems/racc-1.4. 6/ext/racc/cparse/gem_make.out Updating class cache with 1261 classes... C:\Program Files\Ruby-1.9.1\bin>gem list -l *** LOCAL GEMS *** C:\Program Files\Ruby-1.9.1\bin>
エラーになる。なんだかなあ。
raccコマンドファイル
しかし、この時点で Racc自体は gemディレクトリに入っている(Gem files will remain)、それに Ruby-1.9.1\bin にはバッチファイルや raccコマンドファイルも入っている。
だから動かそうとすれば動く。ただ、gem からは見えないのでアンインストールは出来ないかも、アップデートも不安か。
C:\Program Files\Ruby-1.9.1\bin>ruby racc no input C:\Program Files\Ruby-1.9.1\bin>ruby racc --version racc version 1.4.6 C:\Program Files\Ruby-1.9.1\bin>ruby racc --runtime-version racc runtime version 1.4.6 (rev. $Id$); c core version 1.4.5 (rev. 1.8)
runtime のバージョンがずれてるのはちょっと気に掛かるかな。runtime 自体は ruby同梱でしたっけ。
racc.bat ファイル
しかし、そのバッチファイルが動かない。
C:\Program Files\Ruby-1.9.1\bin>racc ファイル名、ディレクトリ名、またはボリューム ラベルの構文が間違っています。 C:\Program Files\Ruby-1.9.1\bin>racc.bat ファイル名、ディレクトリ名、またはボリューム ラベルの構文が間違っています。
なんでだ
@ECHO OFF IF NOT "%~f0" == "~f0" GOTO :WinNT @"ruby.exe"" "C:/Program Files/Ruby-1.9.1/bin/racc" %1 %2 %3 %4 %5 %6 %7 %8 %9 GOTO :EOF :WinNT @"ruby.exe"" "%~dpn0" %*
行頭「@」がコマンドのエコーを抑制するし、ちょっと悩んでしまったけど、単純な事だった。そういえば前もそうだったよね。
最後の行、「"」が重複してる。これを一文字削除すればOK
@"ruby.exe" "%~dpn0" %*
これで racc 動く様になった。
C:\Program Files\Ruby-1.9.1\bin>racc no input C:\Program Files\Ruby-1.9.1\bin>racc.bat --runtime-version racc runtime version 1.4.6 (rev. $Id$); c core version 1.4.5 (rev. 1.8)
一応前掲の Helloworld言語とか、HQ9+言語とかのジェネレートは(それなりの 1.9対応の上で)成功した。