PN_PREFIX top-level property

Parser<List> PN_PREFIX
final

167s PN_PREFIX ::= PN_CHARS_BASE ((PN_CHARS | '.')* PN_CHARS)?

Note:

  1. '?' zero or one time
  2. Using starGreedy() to avoid greedy matching all. E.g, (PN_CHARS | '.')* will consume the following PN_CHARS if not careful.
  3. In normal regex, a $ will be enough, with petitparser, need to use starGreedy/plusGreedy to make it work.

Implementation

final PN_PREFIX = PN_CHARS_BASE &
    ((PN_CHARS | string('.')).starGreedy(PN_CHARS) & PN_CHARS).repeat(0, 1);