diff options
-rwxr-xr-x | common.mk | 1 | ||||
-rw-r--r-- | parse.y | 2 | ||||
-rwxr-xr-x | tool/pure_parser.rb | 15 |
3 files changed, 17 insertions, 1 deletions
@@ -851,6 +851,7 @@ PHONY: {$(srcdir)}.y.c: $(ECHO) generating $@ $(Q)$(BASERUBY) $(srcdir)/tool/id2token.rb --path-separator=.$(PATH_SEPARATOR)./ --vpath=$(VPATH) id.h $(SRC_FILE) > parse.tmp.y + $(Q)$(BASERUBY) $(srcdir)/tool/pure_parser.rb parse.tmp.y $(YACC) $(Q)$(YACC) -d $(YFLAGS) -o y.tab.c parse.tmp.y $(Q)$(RM) parse.tmp.y $(Q)sed -f $(srcdir)/tool/ytab.sed -e "/^#/s|parse\.tmp\.[iy]|$(SRC_FILE)|" -e "/^#/s!y\.tab\.c!$@!" y.tab.c > [email protected] @@ -910,7 +910,7 @@ static void token_info_warn(struct parser_params *p, const char *token, token_in %} %expect 0 -%pure-parser +%define api.pure %lex-param {struct parser_params *p} %parse-param {struct parser_params *p} %initial-action 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') |