Matt S Trout > Rakudo-Star-2012.08_001 > Regex

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

Annotate this POD

Source  

NAME ^

Regex - Regex library

DESCRIPTION ^

This file brings together the various Regex modules needed for Regex.pbc .

NAME ^

Regex::Cursor - Regex Cursor nodes

DESCRIPTION ^

This file implements the Regex::Cursor class, used for managing regular expression control flow. Regex::Cursor is also a base class for grammars.

Methods

new_match()

A method that creates an empty Match object, by default of type Regex::Match. This method can be overridden for generating HLL-specific Match objects.

new_array()

A method that creates an empty array object, by default of type ResizablePMCArray. This method can be overridden for generating HLL-specific arrays for usage within Match objects.

MATCH()

Return this cursor's current Match object, generating a new one for the Cursor if one hasn't been created yet.

parse(target [, 'rule'=>regex])

Parse target in the current grammar starting with regex. If regex is omitted, then use the TOP rule for the grammar.

next()

Return the next match from a successful Cursor.

pos()

Return the cursor's current position.

from()

Return the cursor's from position.

Private methods

!cursor_init(target)

Create a new cursor for matching target.

!cursor_start([lang])

Create and initialize a new cursor from self. If lang is provided, then the new cursor has the same type as lang.

!cursor_fail(pos)

Permanently fail this cursor.

!cursor_pass(pos, name)

Set the Cursor as passing at pos; calling any reduction action name associated with the cursor. This method simply sets $!match to a boolean true value to indicate the regex was successful; the MATCH method above replaces this boolean true with a "real" Match object when requested.

!cursor_backtrack()

Configure this cursor for backtracking via !cursor_next.

!cursor_next()

Continue a regex match from where the current cursor left off.

!cursor_caparray(caparray :slurpy)

Set the list of subcaptures that produce arrays to caparray.

!cursor_names(names)

Set the Cursor's name (for binding) to names.

!cursor_pos(pos)

Set the cursor's position to pos.

!cursor_debug(args :slurpy)

Log a debug message.

!mark_push(rep, pos, mark)

Push a new backtracking point onto the cursor with the given rep, pos, and backtracking mark. (The mark is typically the address of a label to branch to when backtracking occurs.)

!mark_peek(mark)

Return information about the latest frame for mark. If mark is zero, return information about the latest frame.

!mark_fail(tomark)

Remove the most recent mark and backtrack the cursor to the point given by that mark. If mark is zero, then backtracks the most recent mark. Returns the backtracked values of repetition count, cursor position, and mark (address).

!mark_commit(mark)

Like !mark_fail above this backtracks the cursor to mark (releasing any intermediate marks), but preserves the current capture states.

!reduce(name [, key] [, match])

Perform any action associated with the current regex match.

!BACKREF(name)

Match the backreference given by name.

!INTERPOLATE(var [, convert])

Perform regex interpolation on var. If var is a regex (sub), it is used directly, otherwise it is used for a string literal match. If var is an array, then all of the elements of var are considered, and the longest match is returned.

!INTERPOLATE_REGEX(var)

Same as !INTERPOLATE above, except that any non-regex values are first compiled to regexes prior to being matched.

Vtable functions

get_bool

AUTHORS ^

Patrick Michaud <pmichaud@pobox.com> is the author and maintainer.

NAME ^

Regex::Cursor-builtins - builtin regexes for Cursor objects

AUTHORS ^

Patrick Michaud <pmichaud@pobox.com> is the author and maintainer.

NAME ^

Regex::Cursor-protoregex-peek - simple protoregex implementation

DESCRIPTION ^

!protoregex(name)

Perform a match for protoregex name.

!protoregex_generation()

Reset the $!generation flag to indicate that protoregexes need to be recalculated (because new protoregexes have been added).

!protoregex_tokrx(name)

Return the token list for protoregex name. If the list doesn't already exist, or if the existing list is stale, create a new one and return it.

!protoregex_gen_table(parrotclass)

Generate a new protoregex table for parrotclass. This involves creating a hash keyed with method names containing ':sym<' from parrotclass and all of its superclasses. This new hash is then given the current $!generate property so we can avoid recreating it on future calls.

!PREFIX__!protoregex(name)

Return the set of initial tokens for protoregex name. These are conveniently available as the keys of the tokrx hash.

NAME ^

Regex::Match - Regex Match objects

DESCRIPTION ^

This file implements Match objects for the regex engine.

Methods

CURSOR()

Returns the Cursor associated with this match object.

from()

Returns the offset in the target string of the beginning of the match.

to()

Returns the offset in the target string of the end of the match.

chars()

Returns .to() - .from()

orig()

Return the original item that was matched against.

Str()

Returns the portion of the target corresponding to this match.

ast()

Returns the "abstract object" for the Match; if no abstract object has been set then returns Str above.

Vtable functions

get_bool()

Returns 1 (true) if this is the result of a successful match, otherwise returns 0 (false).

get_integer()

Returns the integer value of the matched text.

get_number()

Returns the numeric value of this match

get_string()

Returns the string value of the match

!make(obj)

Set the "ast object" for the invocant.

AUTHORS ^

Patrick Michaud <pmichaud@pobox.com> is the author and maintainer.

NAME ^

Regex::Regex, Regex::Method - Regex subs

DESCRIPTION ^

This file implements the Regex::Method and Regex::Regex types, used as containers for Regex subs that need .ACCEPTS and other regex attributes.

Methods

new(sub)

Create a new Regex::Regex object from sub.

ACCEPTS(target)

Perform a match against target, return the result.

AUTHORS ^

Patrick Michaud <pmichaud@pobox.com> is the author and maintainer.

TITLE ^

Regex::Dumper - various methods for displaying Match structures

Regex::Match Methods

__dump(PMC dumper, STR label)

This method enables Data::Dumper to work on Regex::Match objects.

dump_str()

An alternate dump output for a Match object and all of its subcaptures.

NAME ^

PAST::Regex - Regex nodes for PAST

DESCRIPTION ^

This file implements the various abstract syntax tree nodes for regular expressions.

prefix()

Returns the prefixes associated with the regex tree rooted at this node.

AUTHOR ^

Patrick Michaud <pmichaud@pobox.com> is the author and maintainer. Please send patches and suggestions to the Parrot porters or Perl 6 compilers mailing lists.

COPYRIGHT ^

Copyright (C) 2009, The Perl Foundation.

NAME ^

PAST::Compiler-Regex - Compiler for PAST::Regex nodes

DESCRIPTION ^

PAST::Compiler-Regex implements the transformations to convert PAST::Regex nodes into POST. It's still a part of PAST::Compiler; we've separated out the regex-specific transformations here for better code management and debugging.

Compiler methods

PAST::Regex

as_post(PAST::Regex node)

Return the POST representation of the regex AST rooted by node.

!cursorop(ops, func, retelems, arg :slurpy)

Helper function to push POST nodes onto ops that perform func on the regex's current cursor. By default this ends up being a method call on the cursor, but some values of func can result in inlined code to perform the equivalent operation without using the method call.

The retelems argument is the number of elements in arg that represent return values from the function; any remaining elements in arg are passed to the function as input arguments.

!rxregs(keystr)

Helper function -- looks up the current regex register table in the dynamic scope and returns a slice based on the keys given in keystr.

post_regex(PAST::Regex node)

Return the POST representation of the regex component given by node. Normally this is handled by redispatching to a method corresponding to the node's "pasttype" and "backtrack" attributes. If no "pasttype" is given, then "concat" is assumed.

alt(PAST::Regex node)
alt_longest(PAST::Regex node)

Same as 'alt' above, but use declarative/LTM semantics. (Currently we cheat and just use 'alt' above.)

anchor(PAST::Regex node)

Match various anchor points, including ^, ^^, $, $$.

charclass(PAST::Regex node)

Match something in a character class, such as \w, \d, \s, dot, etc.

!charclass_init(PAST::Regex node)

Return the subtype, cclass value, and negation for a charclass node.

charclass_q(PAST::Regex node)

Optimize certain quantified character class shortcuts, if it makes sense to do so. If not, return a null PMC and the standard quantifier code will handle it.

concat(PAST::Regex node)

Handle a concatenation of regexes.

conj(PAST::Regex node)
cut(PAST::Regex node)

Generate POST for the cut-group and cut-rule operators.

enumcharlist(PAST::Regex node)

Generate POST for matching a character from an enumerated character list.

literal(PAST::Regex node)

Generate POST for matching a literal string provided as the second child of this node.

'pastnode'(PAST::Regex node)
pass(PAST::Regex node)
reduce
quant(PAST::Regex node)
scan(POST::Regex)

Code for initial regex scan.

subcapture(PAST::Regex node)

Perform a subcapture (capture of a portion of a regex).

subrule(PAST::Regex node)

Perform a subrule call.

post_new(type, args :slurpy, options :slurpy :named)

Helper method to create a new POST node of type.

??!!(test, trueval, falseval)

Helper method to perform ternary operation -- returns trueval if test is true, falseval otherwise.

AUTHOR ^

Patrick Michaud <pmichaud@pobox.com> is the author and maintainer.

COPYRIGHT ^

Copyright (C) 2009, The Perl Foundation.

AUTHOR ^

Patrick Michaud <pmichaud@pobox.com> is the author and maintainer.

COPYRIGHT ^

Copyright (C) 2009, The Perl Foundation.

syntax highlighting: