Parrot/PGE, parsers Parsers, Perl 6 Rules, and the Parrot Grammar Engine #18

<PGE::Text::bracketed>

PGE provides a <PGE::Text::bracketed> subrule that parses a bracketed string, keeping track of nested and escaped brackets as it goes.

It's written as a plain Parrot subroutine (in runtime/parrot/library/PGE/Text.pir), and uses a simple stack to keep track of the current nesting.

By default PGE::Text::bracketed looks for matched sets of <>, (), {}, and [], but we can specify a parameter with "characters of interest":

<PGE::Text::bracketed>
<PGE::Text::bracketed: '">    # capture quoted strings
<PGE::Text::bracketed: ()>    # capture paren-delimited
Copyright © 2006 Patrick Michaud