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

Token vs. rule

Thus,

rule { if <expression> then <statement> }

ends up acting somewhat like

token { \s* if \s* <expression> \s* then \s* <statement> \s* }

except that the \s* wont match zero whitespace characters if it occurs between two word characters in the input.

A grammar can define a custom "ws" rule to skip other things besides whitespace (e.g., comments).

Copyright © 2006 Patrick Michaud