[antlr-interest] Fwd: rulecatch C runtime
Gavin Lambert
antlr at mirality.co.nz
Wed Jan 21 01:58:41 PST 2009
At 21:42 21/01/2009, Bot Tiger wrote:
>I wanted to know how I can change the error handler so it can
>quit on the first error.
>
>I tried doing @rulecatch {}, but antlr 3.1.1 says:
>
>"error(100): C:\Users\admin\Desktop\SimpleCalc.g:12:1: syntax
>error: antlr: C:\Users\admin\Desktop\SimpleCalc.g:12:1:
>unexpected token: tokens {"
I'm not sure about @rulecatch itself (and whether or not it'll do
what you want), but the error you're getting there is because
you've put it in the wrong place :)
The first thing in the grammar file is the intro line ("grammar
foo;"). Following that must be the options block and the tokens
block, in that order. (You don't have to specify either one, but
if you do, then that's where they have to be.) Only after that
can you define action blocks (such as @rulecatch), and finally the
actual rules appear at the end.
So move the @rulecatch block underneath your tokens block and then
the error should go away. Whether it actually works after that,
though, I don't know :)
More information about the antlr-interest
mailing list