[antlr-interest] Custom error recovery

Jim Idle jimi at temporal-wave.com
Thu Feb 3 07:59:53 PST 2011


http://www.antlr.org/wiki/display/ANTLR3/Custom+Syntax+Error+Recovery
http://antlr.markmail.org

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Daisy
> Sent: Thursday, February 03, 2011 2:08 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Custom error recovery
>
>
> Hi,
>
> I am a newbie to ANTLR. I am trying to generate a parser based on the
> Lua
> 5.1 grammar given in the ANTLR grammar list. My query is regarding
> error handling.
>
> This is the rule in the grammar that I am concerned about :
> functioncall:
> varOrExp nameAndArgs+;
> A sample input : SampleFunctionCall {errorVal, testParam1=10,
> testParam2 = 20} When this input is given, everything works fine and
> the "SampleFunctionCall"
> will get correctly mapped to "functioncall".
>
> Error scenario input : SampleFunctionCall {errorVal testParam1=10,
> testParam2 = 20}
>
> Here, I removed the ',' after 'errorVal' which is used to separate the
> function parameters.
> For the above input, I get errors in 3 locations : 1) for errorVal 2)
> for
> testParam1 3) for = in testParam2=20
> Also, it no longer detects the input as a function call. From an end-
> user perspective, when such an entry is given, I would expect an error
> "missing , after errorVal". When I debugged the code, I was able to see
> that the predict function of "field" (the sample functioncall input is
> made up of -> var tableconstructor. For more details, see attached
> image files that shows the parsed tree) fails to identify "errorVal"
> and it returns state.failed = true. This results in coming out of the
> "functioncall" rule. Rest of the statements are being considered as
> normal statements.
>
> My requirement is to stay inside the "functioncall" and show error
> message "missing , after errorVal" only for "errorVal". Is this
> possible?
>
> Please let me know if I havent made myself clear.
>
> Thanks,
> Daisy. http://antlr.1301665.n2.nabble.com/file/n5988216/ParseTree.jpg
> http://antlr.1301665.n2.nabble.com/file/n5988216/ParseTreeErrorScenario
> .jpg
> --
> View this message in context:
> http://antlr.1301665.n2.nabble.com/Custom-error-recovery-
> tp5988216p5988216.html
> Sent from the ANTLR mailing list archive at Nabble.com.
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address


More information about the antlr-interest mailing list