Matt S Trout > Rakudo-Star > PGE::Match

Download:
Rakudo-Star-2012.08_001.tar.gz

Annotate this POD

Source  

NAME ^

PGE::Match - implementation of PGE match objects

DESCRIPTION ^

This file implements match objects returned by the Parrot Grammar Engine.

Methods

new(PMC src, [ PMC adverbs :slurpy :named ])

Creates a new Match object based on src. If the grammar adverb is specified, then the new Match object is of the given grammar class, otherwise if src is an instance of Match (or a subclass) then that class is used to create the object, otherwise it uses the class of the invocant.

The pos, p, continue, or c adverbs specify where the match object should begin. If no starting position is given, the current position of src is used if it has one, otherwise the start position is at offset zero. The from adverb can be used to initialize the Match's $.from attribute to a value other than the starting position.

The rw adverb causes the invocant to be modified and returned instead of creating a new Match object.

The new method returns several values to the caller: the initialized match object, the target the object is matching against, a reference to its $.from attribute, a reference to its $.pos attribute, the value of pos/p/continue/c used to initialize the object, and whether or not a continue flag is set or implied.

next()

Tell a Match object to continue the previous match from where it left off.

from([int pos])

Returns or sets the offset in the target string of the first item this object matched.

to([int pos])

Returns or sets the offset at the end of this match.

chars()

Returns .to() - .from().

Str()

Returns the portion of the target string matched by this object.

orig()

Return the original item being matched.

!make(pmc obj)

Sets the "ast object" for the Match invocant.

ast([pmc obj])

Returns the "ast object" for the match object. If no ast object has been set, then it returns the string between .from and .to.

_failcut(int cutvalue)

Immediately "fail" this Match object, removing any captured entities and coroutine continuation. Set the position of the match object to cutvalue.

get_bool()

Returns 1 if this object successfully matched the target string, 0 otherwise.

get_integer()

Returns the integer value of this match.

get_number()

Returns the numeric value of this match.

get_string()

Returns the portion of the target string matched by this object.

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).

syntax highlighting: