Method: Paco::Combinators::Char#string
- Defined in:
- lib/paco/combinators/char.rb
#string(matcher) ⇒ Paco::Parser
Returns a parser that looks for a passed ‘matcher` string and returns its value on success.
34 35 36 37 38 39 40 41 42 |
# File 'lib/paco/combinators/char.rb', line 34 def string(matcher) Parser.new("string(#{matcher.inspect})") do |ctx, parser| src = ctx.read(matcher.length) parser.failure(ctx) if src != matcher ctx.pos += matcher.length src end end |