Catching Exceptions in antlr4

15 views
Skip to first unread message

Andrea Turbati

unread,
Dec 1, 2017, 6:40:52 AM12/1/17
to antlr-discussion
Hello everyone, I've a problem regarding Catching Exceptions. In https://github.com/antlr/antlr4/blob/master/doc/parser-rules.md it says that it should be possibile to write something like this:
r : a b c
 
;
 
catch[RecognitionException e] { throw e; }
(where 'a', 'b' and 'c' are rules defined after) but if I try I get an error, in particular it says that the rule 'a' 'b' and 'c' cannot be found. I'm using Eclipse with the Antlr4 plugin to generate the java code from the g4 file.
Apart from this error (maybe I need to specify something in some option, but I really do not know how or where), will it be possible to throw my own exception from a method enterXYZ of the class which extends a baseListener. I need to throw specific errors, but since the enterXYZ @Override the method from the baseListener class I cannot just put a throws SomeError in the signature.
Thank you for any asnwer you will give me

Andrea Turbati



Reply all
Reply to author
Forward
0 new messages