register reg.ini wrote:
The java parser has a general notion of parser exceptions. The C runtime simulates this by checking some attributes in the base-recognizer structure thanks to the HASEXCEPTION macro. Anyway it happens that recovered lexer errors are not propagated to the parser so in this case an HASEXCEPTION check does not return true . Starting from a parser rule invocation, how to detect if one has an error in the lexer? Another way to formulate the same question is how to get a reference to the lexer starting from the invocation of a parser rule? How to customize error handling for the lexer?
Regards,
Luca
 
That isn't how it works.

First the lexer is called to create all the tokens, then the parser runs. However, you can call the lexer on it's own (see C examples) then just check the error count member of the recognizer before invoking the parser.

However, you should not program a lexer that can raise errors. Always cover all the bases with at least a final rule: ANY : . {error ...}; and left factor the other rules so that they cannot error out on their own. Then you can leave errors to the parser.

Jim

--~--~---------~--~----~------------~-------~--~----~
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

Reply via email to