diff --git a/bin/racc b/bin/racc index 8a162777..a1b3c040 100755 --- a/bin/racc +++ b/bin/racc @@ -92,45 +92,40 @@ def main #} parser.on('--version', 'Prints version and quit.') { puts "racc version #{Racc::Version}" - exit 0 + exit } parser.on('--runtime-version', 'Prints runtime version and quit.') { - printf "racc runtime version %s; %s\n", + printf "racc runtime version %s; %s core version %s\n", Racc::Parser::Racc_Runtime_Version, + Racc::Parser.racc_runtime_type, if Racc::Parser.racc_runtime_type == 'ruby' - sprintf('ruby core version %s', - Racc::Parser::Racc_Runtime_Core_Version_R) + Racc::Parser::Racc_Runtime_Core_Version_R else - sprintf('c core version %s', - Racc::Parser::Racc_Runtime_Core_Version_C) + Racc::Parser::Racc_Runtime_Core_Version_C end - exit 0 + exit } parser.on('--copyright', 'Prints copyright and quit.') { puts Racc::Copyright - exit 0 + exit } parser.on('--help', 'Prints this message and quit.') { puts parser.help - exit 1 + exit } begin parser.parse! rescue OptionParser::ParseError => err - $stderr.puts err.message - $stderr.puts parser.help - exit 1 + abort [err.message, parser.help].join("\n") end if ARGV.size > 1 - $stderr.puts 'too many input' - exit 1 + abort 'too many input' end input = ARGV[0] || "stdin" if input == "stdin" && !output then - $stderr.puts 'You must specify a path to read or use -o for output.' - exit 1 + abort 'You must specify a path to read or use -o for output.' end begin @@ -142,7 +137,7 @@ def main } if check_only $stderr.puts 'syntax ok' - exit 0 + exit end $stderr.puts 'Generating LALR states...' if verbose @@ -201,8 +196,7 @@ def main rescue Racc::Error, Errno::ENOENT, Errno::EPERM => err raise if $DEBUG or debug_flags.any? lineno = err.message.slice(/\A\d+:/).to_s - $stderr.puts "#{File.basename $0}: #{input}:#{lineno} #{err.message.strip}" - exit 1 + abort "#{File.basename $0}: #{input}:#{lineno} #{err.message.strip}" end end