Jim Idle wrote: > Err, the point of consuming the tokens is to suppress spurious errors > so you can sync back to a decent restart point. Any syntax error in the > previous subrule will be caught and displayed because the exception will > throw in that rule and you will be back in the class rule, where you want > to resync to a good point so you don't drop out of the loop.
I may be misunderstanding somthing, but it doesn't look to me as though
syntax errors due to spurious tokens will cause exceptions or be displayed.
For example, suppose that '=' is not a valid starting token for a
declaration. Then for the input
class Foo {
=
int validDeclaration;
}
syncToSet will skip the '=' token without reporting an error, even though
a syntax error should have been reported.
> Now, if you want to be more clever, then you can see if there were any
> errors in the previous rule, then if there are spurious tokens after the
> class member
... or before the first class member ...
> then you can show an error about them.
Well, then I suppose my point is that you should always do this -- it's
not a matter of being clever, but of being minimally correct.
--
David-Sarah Hopwood ⚥ http://davidsarah.livejournal.com
signature.asc
Description: OpenPGP digital signature
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
