TITLE ^

Regex - base class for grammars and built-in rules

DESCRIPTION ^

This implements the base classes for forming grammars, and provides a number of built-in rules.

Built-in regex ^

ident()

Match an identifier.

null()

Match a null string (always returns true on first match).

fail()

Force a backtrack. (Taken from A05.)

upper()

Match a single uppercase character.

lower()

Match a single lowercase character.

alpha()

Match a single alphabetic character.

digit()

Match a single digit.

xdigit()

Match a single alphanumeric character.

space()

Match a single whitespace character.

print()

Match a single printable character.

graph()

Match a single "graphical" character.

blank()

Match a single "blank" character.

cntrl()

Match a single "control" character.

punct()

Match a single punctuation character.

alnum()

Match a single alphanumeric character.

sp()

Match a single space character. (Taken from E05.)

lt()

Match a single left angle bracket. (Taken from E05.)

gt()

Match a single right angle bracket. (Taken from E05.)

dot()

Match a single dot ('.'). (Taken from E05.)

ws()

Match whitespace between tokens.

wb(PMC mob)

Returns true if we're at a word boundary (as defined by Perl 5's \b regex).

before(PMC mob, STR pattern)

Perform lookahead -- i.e., check if we're at a position where pattern matches. Returns a zero-width Match object on success.

after(PMC mob, STR pattern)

Perform lookbehind -- i.e., check if the string before the current position matches <pattern> (anchored at the end). Returns a zero-width Match object on success.

XXX: Note that this implementation cheats in a big way. S05 says that after is implemented by reversing the syntax tree and looking for things in opposite order going to the left. This implementation just grabs the (sub)string up to the current match position and tests that, anchoring the pattern to the end of the substring. It's cheap and potentially very inefficient, but it "works" for now.

AUTHOR ^

Patrick Michaud (pmichaud@pobox.com) is the author and maintainer. Patches and suggestions should be sent to the Perl 6 compiler list (perl6-compiler@perl.org).


parrot