A few months ago, Peter Stuifzand, in his pioneering with Marpa, tried
error rules. An error rule is where you detect errors by including a
rule for something that you do *NOT* want the application to do. For
example, if you don't want to allow an assignment in a conditional, you
might try this rule:
<bad if statement> ::= 'if' '(' <assignment
expression ')' <block or statement> action => admonish_user
This was another of Peter's good ideas, but I was forced to tell him
that this was not the easiest way to detect errors. Marpa did not
quite have all the hooks needed to make this technique convenient.
With completion events, I think that situation has changed. You could
define a completion event for the above
event assignment_in_conditional = completed <bad if
statement>
and throw a fatal error with a nice targeted error message when it you
see the event. This could do a lot to take the mystery out of error
reports.
-- jeffrey