Parrot Perl6Grammar compiler and parsers #23

Backtracking control -- tokens

regex TOP     { <integer> <addop> <integer> {*} }
regex integer { \d+ {*} }
regex addop   { [ '+' | '-' ] {*} }

The use of \d+ can be very inefficient

Consider "1873649872934897234009x42" as an input string

A colon after an expression prevents backtracking into the expression

regex integer { \d+: {*} }
Copyright © 2009
http://www.pmichaud.com/2009/pres/