Parrot Perl6Grammar compiler and parsers #26

Rules

The 'rule' keyword says that whitespace in the regex corresponds to whitespace in the input

rule TOP { <integer> <addop> <integer> {*} }

is the same as

token TOP { <.ws> <integer> <.ws> <addop> <.ws> <integer> <.ws> {*} }

The default <.ws> makes this act like

token TOP { \s* <integer> \s* <addop> \s* <integer> \s* {*} }

except the default <.ws> subrule won't match zero spaces between two word characters in the input.

Copyright © 2009
http://www.pmichaud.com/2009/pres/