mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Support Bison 3
This commit is contained in:
parent
53e9908d8a
commit
a064e46762
3 changed files with 17 additions and 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 > $@.new
|
||||
|
|
2
parse.y
2
parse.y
|
@ -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
|
||||
|
|
15
tool/pure_parser.rb
Executable file
15
tool/pure_parser.rb
Executable file
|
@ -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')
|
Loading…
Add table
Reference in a new issue