Module: L43Peg::Combinators::Sel

Extended by:
Sel
Includes:
Helper
Included in:
Sel
Defined in:
lib/l43_peg/combinators/sel.rb

Instance Method Summary collapse

Methods included from Helper

#fail_parser, #succeed_parser

Instance Method Details

#sel(input:, cache:, name:, parsers:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/l43_peg/combinators/sel.rb', line 9

def sel(input:, cache:, name:, parsers:)
  parsers.each do |parser|
    case parser.(input, cache:)
    in L43Peg::Success => success
      return success
    else
    end
  end

  fail_parser("sel #{name} could not match any option", input:)
end