summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-17 03:09:52 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-17 03:09:52 +0900
commita064e46762ec0bfd40e6a04242d9e62fdd21e1f0 (patch)
treeaaeca83e2bd8175641978f24d520a2f9b10bde8e /tool
parent53e9908d8afc7f03109b0aafd1698ab35f512b05 (diff)
Support Bison 3
Diffstat (limited to 'tool')
-rwxr-xr-xtool/pure_parser.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/tool/pure_parser.rb b/tool/pure_parser.rb
new file mode 100755
index 0000000000..20d71079a0
--- /dev/null
+++ b/tool/pure_parser.rb
@@ -0,0 +1,15 @@
+#!/usr/bin/ruby -pi
+BEGIN {
+ require_relative 'colorize'
+
+ colorize = Colorize.new
+ file = ARGV.shift
+ unless /\Abison .* (\d+)\.\d+/ =~ IO.popen(ARGV+%w[--version], &:read)
+ puts colorize.fail("not bison")
+ exit
+ end
+ exit if $1.to_i >= 3
+ ARGV.clear
+ ARGV.push(file)
+}
+$_.sub!(/^%define\s+api\.pure/, '%pure-parser')