On 09/27/2009 07:22 AM, Юрушкин Михаил wrote: > good day. > I have some questions about an errors-processing alogirthm in Antlr: > > 1) Antlr generates strange code. If no alternatives are right, it does the > following: > > ... > default: > CONSTRUCTEX(); > EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; > EXCEPTION->message = (void *)""; > EXCEPTION->decisionNum = 34; > EXCEPTION->state = 0; > > > goto ruleattr_specEx; > } > > > - initializes exception... and CLEANS some information. Why? >
Error recovery. Read the docs for the exception handling and error recovery logic if you want to know more, but for error reporting and so on, you don't really need to know much - just use the pre-supplied error message display routine as a guide - I tried to make it access everything that one woudl need so you can see what to do. See displayRecognitionError. In release 3.2.1 I am going to fold that code into an internal function to reduce the line count of the output code and possibly the object code size. > 2) after the finishing of processing nonterminal > rec->state->errors_count = 0 Why?? It has detected an error already. > > I presume you mean errorCount? Is this from the lexer? I fixed a bug whereby the lexer would not count errors - fixed in release 3.2. However, lexers should really be written so they don't throw recognition errors, but detect anomalies and report them more directly (such as missing terminating quotes and illegal characters. FInally don;t use intenrals directly, use the api calls: getNumberOfSyntaxErrors Jim List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
