[antlr-interest] Lexer and Java keywords
marcin.rzeznicki at gmail.com
Sun Dec 13 08:16:01 PST 2009
2009/12/10 Sam Harwell <sharwell at pixelminegames.com>:
> You're making this too complicated. Parse the identifier as loosely as absolutely possible. Many improper identifiers actually don't cause any problems in parsing, so you can treat them as valid and provide compiler error messages like semantics problems in post-AST analysis - the identifiers are just string literal keys to reference code constructs. After you perform semantic analysis check each identifier (variable and method names, etc.) by calling the Character class methods. Log the errors, but you don't have to stop the analysis from just that.
Right, but isn't it that ANTLR tries to, kind of, 'sync' the parser on
an error? So that it does not stop actually the analysis but catches
> The general rule is don't engineer your parser to fail until you can no longer provide useful error messages. You can always manually stop early - for example sometimes I throw an OperationCancelledException in an error listener to stop a background parse for IDE IntelliSense after a user-specified number of errors are logged.
Good idea, but isn't that what ANTLR automatically does? I mean - it
does not fail when it doesn't absolutely have to?
More information about the antlr-interest