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
- split(regex, string [, count]) Split the string where the regex matches, returning an array. Optionally limit the number of splits.
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'.