[antlr-interest] Why ANTLR doesn't check existence of lexical symbols?

Greg Lindholm glindholm at yahoo.com
Wed Jun 11 13:24:31 PDT 2003


Hi Ter,

It seems to me that there are 2 case;
1) the lexer is in the same file or
2) the parser does an import of the token symbols

In either case if Antlr encounters undefined tokens in a parser and has
to generate new symbols I think you got a problem that at the very
least deserves a warning message.

Cause if the lexer doesn't know about the symbol it's never going to
create a token of that type.

Or am I missing something?


--- Terence Parr <parrt at jguru.com> wrote:
> 
> On Wednesday, June 11, 2003, at 02:11  AM, Hrvoje Nezic wrote:
> 
> > Hi,
> >
> > If some lexical symbol is referenced in parser grammar,
> > but is not actually defined in lexer, ANTLR doesn't
> > generate error or warning messages, so this can be detected
> > only at runtime on parser testing.
> > I find it very inconvenient, because you have to check
> > existence of token symbols manually.
> > Is there any reason why ANTLR behaves like this, and
> > is there any workaround?
> 
> The problem is that ANTLR can be hooked up to any TokenStream object.
>  
> Further, the lexer may not be defined in the same grammar file. 
> ANTLR 
> cannot answer this question, I guess is the answer (though not the
> one 
> you are hoping for) ;)
> 
> Terence
> --
> Co-founder, http://www.jguru.com
> Creator, ANTLR Parser Generator: http://www.antlr.org
> Co-founder, http://www.peerscope.com link sharing, pure-n-simple
> Lecturer in Comp. Sci., University of San Francisco
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/ 
> 
> 


__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list