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

Syntax errors w/die

But with the <die> rule, we can be more helpful:

rule if_statement {
  if [ <expression> | <PGE::Util::die: Expression expected> ]
     [ then         | <PGE::Util::die: "if" requires a "then"> ]
     [ <statement>  | <PGE::Util::die: statement expected after "then"> ]
}

This gives error messages like:

"if" requires a "then" at line 15, near "print 5;"
Copyright © 2006 Patrick Michaud