[antlr-interest] How to know if parse successfully
Nigel Sheridan-Smith
nbsherid at secsme.org.au
Mon Feb 7 01:43:00 PST 2005
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of niry
> Sent: Monday, 7 February 2005 6:18 PM
> To: antlr-interest
> Subject: [antlr-interest] How to know if parse successfully
>
> Is there a flag, that indicates the parse is succcessful, which I can
> access from my main method(Cpp)?
> Maybe simple to you but not to me:(
>
>
Antlr attempts to recover from errors and continue to parse the input. I
believe it then throws an exception when the input is fully parsed to
indicate that the parsing was not successful.
You need to catch the antlr::SemanticException exception... alternatively,
sub-class antlr::ANTLRParser and override reportError() or reportWarning().
Maybe you are trying to do line-by-line parsing? Add the EOF token to the
end of your main production/rule. That will force matching of only one
expression at a time.
Nigel
--
Nigel Sheridan-Smith
PhD research student
Faculty of Engineering
University of Technology, Sydney
Phone: 02 9514 7946
Fax: 02 9514 2435
More information about the antlr-interest
mailing list