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 <[email protected]> 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 :) > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
