I've just checked in changes to PGE that enable it to support grammars, as well as some more built-in rules (<alpha>, <digit>, <alnum>, <ident>, etc.). To create a new grammar, just create a subclass of "PGE::Rule" and install new rules into the new grammar's namespace:
.sub main @MAIN load_bytecode "PGE.pbc" .local pmc p6rule p6rule = find_global "PGE", "p6rule" $P0 = getclass "PGE::Rule" $P1 = subclass $P0, "MyClass" # create a custom MyClass::alpha rule $P0 = p6rule("<[abcde]>") store_global "MyClass", "alpha", $P0 $P0 = p6rule("^ <MyClass::ident>") $P1 = $P0("ab23") # matches "ab23" $I0 = $P1.__get_bool() print $I0 print "\n" $P1 = $P0("zz23") # doesn't match zz23 $I0 = $P1.__get_bool() print $I0 print "\n" .end I've added some more tests for the above, but many many more are needed. If anyone wants to request (or better yet, submit patches for) other of the default built-in rules, I'll be glad to add them. Pm