Andrew McKinlay's post The Software Life: Antlr Frustrations on "no start rule" warnings gives a succinct explanation of a problem that can be somewhat evasive. The ANTLR warning "no start rule (no rule can obviously be followed by EOF)" may come and go as other issues with the grammar are resolved. One answer is to always start the grammar with a rule like:
prog : expr ;The prog rule doesn't change anything about the language that can be parsed. It can be used as an entry point by the code calling the parser, like an interface that can be stable even as the grammar changes underneath.
No comments:
Post a Comment