[antlr-interest] RFE: warn if root rule is missing (no EOF)

Loring Craymer lgcraymer at yahoo.com
Wed Feb 20 17:42:24 PST 2008


Troy--

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.

--Loring


----- Original Message ----
> From: "Daniels, Troy (US SSA)" <troy.daniels at baesystems.com>
> To: Loring Craymer <lgcraymer at yahoo.com>; Guntis Ozols <guntiso at latnet.lv>; antlr-interest at antlr.org
> Sent: Wednesday, February 20, 2008 4:27:08 PM
> Subject: RE: [antlr-interest] RFE: warn if root rule is missing (no EOF)
> 
> Both of you are right.  You're making different points.
> 
> 1.  Not every grammar needs to reference EOF.  If your grammar does not
> reference EOF and does exactly what you want it to do, it should not
> generate a warning.
> 
> 2.  Not adding EOF is a common beginner mistake and generates many,
> similar messages to the email list.  Something should be done so that
> beginners are aware that (almost always) you want to end your base rule
> with EOF.
> 
> 
> A reasonable solution to both points is a command line option that
> prints an warning if no rule references EOF.  The warning should be
> worded with the expectation that most users who see it will be new to
> the tool.
> 
> "New" users will see the warning and add an EOF to their main rule,
> rather than spending an hour trying to figure out why it doesn't work,
> then bothering all of us with an email.
> 
> "Advanced" users who know that their grammar does not reference EOF and
> why this is correct will be able to disable the option and suppress the
> warning.  
> 
> Troy
> 
>  
> 
> > -----Original Message-----
> > From: antlr-interest-bounces at antlr.org 
> > [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Loring Craymer
> > Sent: Wednesday, February 20, 2008 6:39 PM
> > To: Guntis Ozols; antlr-interest at antlr.org
> > Subject: Re: [antlr-interest] RFE: warn if root rule is 
> > missing (no EOF)
> > 
> > I think that you miss Jim's point.  It is not necessary for a 
> > grammar to have a rule that references EOF.  For that matter, 
> > it is possible to have rules reference EOF without being root 
> > rules (I have to admit, though, that I have never seen an 
> > instance where this would make sense).  All that the EOF does 
> > is force a rule to read to end-of-file or throw a 
> > "NoViableAlt" exception.
> > 
> > --Loring
> > 
> > ----- Original Message ----
> > > From: Guntis Ozols 
> > > To: antlr-interest at antlr.org
> > > Sent: Wednesday, February 20, 2008 2:58:42 PM
> > > Subject: Re: [antlr-interest] RFE: warn if root rule is missing (no 
> > > EOF)
> > > 
> > > This is not a valid thing to do.
> > > > Not everyone WANTs a rule to end in EOF.
> > > >
> > > > Jim
> > > 
> > > Of course this is not a valid thing to do if you want to 
> > boost trafic 
> > > for this list, keep newbies puzzled and everyone else on this list 
> > > busy.
> > > 
> > > I am subscribed to this list only for few months, and seen this EOF 
> > > issue (and other issues) pop up numerous times.
> > > 
> > > To keep everyone happy, there could be command line option 
> > > 'help-dummies', which could enable this and other warnings.
> > > Hopefully it can be 'on' by default.
> > > 
> > > Guntis
> > > 
> > > 
> > 
> > 
> > 
> > 
> >       
> > ______________________________________________________________
> > ______________________
> > Looking for last minute shopping deals?  
> > Find them fast with Yahoo! Search.  
> > http://tools.search.yahoo.com/newsearch/category.php?category=shopping
> > 
> 




      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping


More information about the antlr-interest mailing list