Parrot Parrot Compiler Toolkit #29

Another example

From the "Python Language Reference Manual" (Release 2.3):

identifier ::= (letter | "_") (letter | digit | "_")*
letter ::= lowercase | uppercase
lowercase ::= "a"..."z"
uppercase ::= "A"..."Z"
digit ::= "0"..."9"

In PGE, we write the above as:

token identifier { [ <alpha> | '_' ] \w* }

PGE already has built-in definitions for <alpha>, <upper>, <lower>, <digit>, etc.

continued...
Copyright © 2008 Patrick R. Michaud
http://www.pmichaud.com/2008/pres/