[antlr-interest] RFE: warn if root rule is missing (no EOF)
Gavin Lambert
antlr at mirality.co.nz
Thu Feb 21 01:59:46 PST 2008
At 14:42 21/02/2008, Loring Craymer wrote:
>
>Usually, it is not the "not adding EOF" that is a beginner's
>mistake, it is the structuring of a grammar to require an
explicit
>EOF. That is, the top level rule depends on a stop marker, such
as
>"}", to terminate, and processing may stop before an EOF is
>reached. The only time your grammar needs an EOF is to consume
>tokens from such a stop marker to the end of file; I find that
>rare.
I think it's more commonly used in the "I want this to throw an
error if there's unrecognisable junk at the end of the input"
sense. Which you could actually do by checking for unconsumed
input afterwards, but adding the EOF is easier.
EOFs are sometimes useful elsewhere (eg. as a possible terminator
for a single-line-comment) as well.
More information about the antlr-interest
mailing list