Matt S Trout > Rakudo-Star-2012.08_001 > rakudo-star/parrot/runtime/parrot/library/PGE/Util.pir

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

Annotate this POD

Source  

TITLE ^

PGE/Util.pir - useful rules for working with PGE grammars

DESCRIPTION ^

This module defines a number of useful rules for various parsing tasks using PGE.

Functions

die(match, [, message [, ...]] )

Throws an exception at the current point in the match. If message doesn't end with a newline, also produces the line number and offset of the match.

warn(match, [, message [, ...]] )

Emits the list of messages to stderr.

line_number(match [, pos])

Return the line number and offset of the of the line corresponding to offset pos in the string targeted by match. If pos isn't supplied, then use the from value of match as the offset. For this function the line number for the first line in the string is treated as '0'.

split(regex, string [, count])

Split the string where the regex matches, returning an array. Optionally limit the number of splits.

unique()

Returns a unique integer on every call.

pir_str_escape(string)

Returns a PIR string for a given string contents.

NOTE: this does NOT securely escape strings.

pir_key_escape(args)

Constructs a PIR key using the strings passed as arguments. For example, pir_key_escape('Foo', 'Bar') returns ["Foo";"Bar"].

syntax highlighting: