1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/racc/assets/error_recovery.y

35 lines
545 B
Text
Raw Normal View History

2019-05-13 08:25:22 -04:00
# Regression test case for the bug discussed here:
# https://github.com/whitequark/parser/issues/93
# In short, a Racc-generated parser could go into an infinite loop when
# attempting error recovery at EOF
class InfiniteLoop
rule
stmts: stmt
| error stmt
stmt: '%' stmt
end
---- inner
def parse
@errors = []
do_parse
end
def next_token
nil
end
def on_error(error_token, error_value, value_stack)
# oh my, an error
@errors << [error_token, error_value]
end
---- footer
InfiniteLoop.new.parse