HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/src/ruby-3.0.2/test/racc/assets/error_recovery.y
# 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