[antlr-interest] Re: circular token buffer and overriding nextToken()

Terence Parr parrt at cs.usfca.edu
Sun Oct 12 10:08:21 PDT 2003


Howdy.  I intend TokenStream to be an interface to any object that can 
return Token objects.  Since a class does not result in objects, in my 
opinion, unless dynamic binding is involved, I pretty much make 
everything virtual.  In this particular case, it's pretty hard to 
switch out the token stream (w/o recompiling everything) on the fly to 
get a new stream without dynamic binding. :)

A good on-the-fly compiler will inline lots of stuff so that dynamic 
calls are not something you should worry about from an efficiency point 
of view.  In C++, I still wouldn't worry about it.  Better to be 
flexible.

Terence

On Sunday, October 12, 2003, at 12:08  AM, lgcraymer wrote:

> --- In antlr-interest at yahoogroups.com, "micheal_jor" <open.zone at v...>
> wrote:
>> The TokenStream interface itself has a single method - nextToken().
> It
>> is called repeatedly until it returns an EOF token. Simple enough.
> The
>> implementation of nextToken() in generated lexers is non-virtual for
>> C++ & C# (also for Java I think). Which suggests it isn't [really]
>
> No, not for Java.  In Java, all methods are "virtual" (see 8.6.4.1 in
> the language spec).
>
>> intended/expected to be overridden.
>
> In ANTLR 1, all generated C++ methods were virtual so that they could
> be overridden.  I think that's more the expectation still.
>
> Ter--maybe you want to comment?
>
>
>
>
>
>
> Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/
>
>
>
--
Professor Comp. Sci., University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Co-founder, http://www.jguru.com
Co-founder, http://www.knowspam.net enjoy email again!
Co-founder, http://www.peerscope.com link sharing, pure-n-simple




 

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




More information about the antlr-interest mailing list