Method: RPEG#B

Defined in:
lib/rpeg/rpeg.rb

#B(patt) ⇒ Object

Returns a pattern that matches only if the input string at the current position is preceded by patt. Pattern patt must match only strings with some fixed length, and it cannot contain captures.



324
325
326
327
328
329
330
331
332
333
# File 'lib/rpeg/rpeg.rb', line 324

def B(patt)
  patt = P(patt)
  len = patt.fixed_len
  raise "Behind match: pattern may not have fixed length" unless len
  raise "Behind match: pattern has captures" if patt.has_captures?

  # LPEG puts an upper bound of MAXBEHIND = 255 on how large the match can be here. I think it is because the value is packed
  # into a byte of memory. We don't care about that
  Pattern.new(Pattern::BEHIND, patt, data: len)
end