MarpaX-ESLIF

 view release on metacpan or  search on metacpan

lib/MarpaX/ESLIF/BNF.pod  view on Meta::CPAN


=item Terminals

There are four types of explicit terminals.

=over

=item * Pseudo terminals

=over

=item :eof

A zero-length terminal that matches only at the of the stream.

=item :eol

A zero-length terminal that matches only before a newline.

=item :sol

A zero-length terminal that matches only after a newline.

=item :empty

A zero-length terminal that always match the empty string.

Note that the newline is hardcoded to be any unicode newline, i.e. C<(*BSR_UNICODE)\R> in PCRE2 terminology.

The presence of :eol or :sol pseudo-terminal anywhere in the grammar enforces the C<newlineb> flag in recognizers. On the contrary C<:eof> and C<:eol> work regardless of recognizer's C<newlineb> flag.

=back

=item * Strings

They can be single (C<'>), double-quoted (C<">), or LEFT DOUBLE QUOTATION MARK (C<“>) then RIGHT DOUBLE QUOTATION MARK (C<”>) enclosed. The content is any valid unicode character, and the C<\> character can be used to escape the expected right-si...

  'string'
  'string':i
  'string\'s'
  "string\"s\\"
  “str'"\”ing”:i

and the modifier C<c> to force unicode character mode. Internally a string is nothing else but a regular expression, so the exact implementation of the C<i> and C<c> modifiers correspond to the PCRE2 flags listed below in the I<Regular expression> se...
Please note this is really a I<quoted string>, B<not> a string terminal. I.e. everything inside the quote is taken as-is, with no interpretation.

=item * Character classes

They are always enclosed with left and right brackets C<[]>. Modifiers can start after a C<:> character. A character class class is nothing else but a lexically restricted regular expression.

=item * Regular expression

They are always enclosed within slashes C<//>, and the content must be valid as per the L<PCRE2 Perl Compatible Regular Expression|http://www.pcre.org/> library. Modifiers can start after the slash on the right. Regular expression patterns are by def...

Regular expressions must be used with care in the two following scenarios:

=over

=item Quantifiers at the end

If the regular expression ends with an unlimited quantifier at the end, i.e. C<*> or C<+>, it is very likely that the data will match partially until the whole input is read, effectively forcing ESLIF to read the entire input. This can break the I<st...

=item Negative lookahead at the end

If the regular expression ends with a negative lookahead, it can match when you think it should not. This is because negative lookahead does not trigger a partial match. In such a case, you should ensure that your regular expression forces a minimum ...

=back

=back

The PCRE2 syntax is supported in its entirety, this include any PCRE2 add-on. Character classes and regular expression share the same set of modifiers, executed in order of appearance, that are:

  ----------------------------------------------------------------
  Modifiers   Explanation
  ----------------------------------------------------------------
  e           Unset back-references in the pattern will match to empty strings
  i           Case-insensitive
  j           \u, \U and \x and unset back-references will act as JavaScript standard
  m           Multi-line regex
  n           Enable Unicode properties and extend meaning of meta-characters
  s           A dot meta-character in the pattern matches all characters, including newlines
  x           Enable comments. This has some limitation due MarpaX::ESLIF semantics
  D           A dollar meta-character matches only at the end of the subject string
  J           Allow duplicate names for sub-patterns
  U           Inverts the "greediness" of the quantifiers
  a           Meta-characters will be limited to their ASCII equivalent
  u           Forces support of large codepoints
  b           Could mean "forced binary" mode
  c           Could mean "forced unicode character" mode
  A           Remove the systematic anchoring
  ----------------------------------------------------------------

Internally this correspond to this set of options in PCRE2:

  ----------------------------------------------------------------
  Modifiers         PCRE2 flag unset   PCR2 flag set
  ----------------------------------------------------------------
  e                                    PCRE2_MATCH_UNSET_BACKREF
  i                                    PCRE2_CASELESS
  j                                    PCRE2_ALT_BSUX|PCRE2_MATCH_UNSET_BACKREF
  m                                    PCRE2_MULTILINE
  n                                    PCRE2_UCP
  s                                    PCRE2_DOTALL
  x                                    PCRE2_EXTENDED
  D                                    PCRE2_DOLLAR_ENDONLY
  J                                    PCRE2_DUPNAMES
  U                                    PCRE2_UNGREEDY
  a                 PCRE2_UTF
  N                 PCRE2_UCP
  u                                    PCRE2_UTF
  b                 PCRE2_UTF          PCRE2_NEVER_UTF
  c                 PCRE2_NEVER_UTF    PCRE2_UTF
  A                 PCRE2_ANCHORED
  ----------------------------------------------------------------

Substitution modifiers are:

  ----------------------------------------------------------------
  Modifiers   Explanation
  ----------------------------------------------------------------
  x           Extended substitution pattern



( run in 0.662 second using v1.01-cache-2.11-cpan-6aa56a78535 )