[antlr-interest] Fwd: rulecatch C runtime
Bot Tiger
bottiger1 at gmail.com
Wed Jan 21 19:32:29 PST 2009
Ahh thank you Gavin.
I am still trying to figure out how to exit on the first error though. I
just realized all the @rulecatch examples I have are in Java and use an
exception handler, while C does not have exceptions.
Any suggestions?
On Wed, Jan 21, 2009 at 1:58 AM, Gavin Lambert <antlr at mirality.co.nz> wrote:
> 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 :)
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090121/0b3c5cf5/attachment.html
More information about the antlr-interest
mailing list