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


Annotate this POD



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


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


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.


Returns a unique integer on every call.


Returns a PIR string for a given string contents.

NOTE: this does NOT securely escape strings.


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

syntax highlighting: