mame/quine-relay · error · Grass::IllegalState

illegal final machine state

Error message

illegal final machine state

What it means

Error "illegal final machine state" thrown in mame/quine-relay.

Source

Thrown at vendor/grass.rb:161

    end
  end

  private

  def eval(m)
    while true
      insn = m.code.shift
      if insn then
        insn.eval m
      else
        break if m.dump.empty?
        ret = m.env.last
        raise IllegalState, "no return value" unless ret
        m.code, m.env = m.dump.pop
        m.env.push ret
      end
    end
    raise IllegalState, "illegal final machine state" unless m.env.size == 1
    m.env.first
  end

  InitialEnv = [In.new, CharFn.new(?w.ord), Succ.new, Out.new]
  InitialDump = [[[], []], [[App.new(1, 1)], []]]

  def start(code)
    eval Machine.new(code, InitialEnv, InitialDump)
  end

  def parse(src)
    code = []
    src = src.sub(/\A[^ww]*/, '').gsub(/[^wwWWvv]/, '')
    src.split(/[vv]+/).each { |s|
      a = s.scan(/[ww]+|[WW]+/).map { |i| i.split(//).size }
      arity = 0
      arity = a.shift if /\A[ww]/ =~ s
      raise "parse error at app" unless a.size % 2 == 0

View on GitHub (pinned to c2aa5098d3)

When it happens

Trigger: Thrown at vendor/grass.rb:161 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of mame/quine-relay@c2aa5098d3 (2026-08-21). Data as JSON: /api/errors/abc80561cd9aa37b. Report an issue: GitHub.