rouge-ruby/rouge · error · RuntimeError

please pass a token to yield, or use a callback

Error message

please pass a token to yield, or use a callback

What it means

Error "please pass a token to yield, or use a callback" thrown in rouge-ruby/rouge.

Source

Thrown at lib/rouge/regex_lexer.rb:82

    # to perform if the test succeeds.
    #
    # @see StateDSL#rule
    class Rule
      attr_reader :callback
      attr_reader :re
      def initialize(lexer_class, re, callback)
        @lexer_class = lexer_class
        @re = re
        @callback = callback
      end

      def inspect
        "#<Rule #{@re.inspect}>"
      end

      def self.make_action(re, tok=nil, next_state=nil)
        if tok.nil?
          raise "please pass a token to yield, or use a callback"
        end

        matches_empty = re.match?('')

        case next_state
        when :pop!
          proc do |stream|
            puts "    yielding: #{tok.qualname}, #{stream[0].inspect}" if @debug
            @output_stream.call(tok, stream[0])
            puts "    popping stack: 1" if @debug
            @stack.pop or raise 'empty stack!'
          end
        when :push
          proc do |stream|
            puts "    yielding: #{tok.qualname}, #{stream[0].inspect}" if @debug
            @output_stream.call(tok, stream[0])
            puts "    pushing :#{@stack.last.name}" if @debug
            @stack.push(@stack.last)

View on GitHub (pinned to bd7dad7b09)

When it happens

Trigger: Thrown at lib/rouge/regex_lexer.rb:82 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of rouge-ruby/rouge@bd7dad7b09 (2026-08-23). Data as JSON: /api/errors/321a6469c9fc97f1. Report an issue: GitHub.