[antlr-interest] antlr.TokenWithIndex (and others) should be an interface

Terence Parr parrt at cs.usfca.edu
Sun Aug 8 15:22:40 PDT 2004


On Aug 8, 2004, at 3:09 PM, charlweed wrote:

> Hi,
> I love TokenStreamRewriteEngine but it uses antlr.TokenWithIndex, and
> TokenWithIndex is neither an interface nor an Adbstract class. I
> already use a token that is a subclass of CommonHiddenStreamToken, but
> I want to also use it in TokenStreamRewriteEngine.
>
> The only solution was to re-implement TokenStreamRewriteEngine , and
> replace all the references to antlr.TokenWithIndex with a reference to
> an iterface with the same signature.

Ack...you're right...for existing token definitions this would be hard; 
well, ones that subclass the hidden stream stuff.

I might ask, however, if it's necessary to use both the rewrite engine 
and the hidden channel stuff.

> So it seems to me that almost all the Token classes should be
> interfaces, and there should be a handful of default implementations.
> That way we can easily extend tokens without the hassle of re-coding
> other classes in antlr.

In many cases this makes sense.  I wonder how many people add 
properties to the token object.  I ask this because I'm thinking of 
(germane to our discussions of antlr common actions) making it easy 
within a grammar to specify both AST and token properties.  ANTLR would 
generate a specific impl of AST or Token (interfaces) that had all your 
goodies.  In this way, ANTLR actions would know if there was in fact a 
xxx property in the AST they are accessing etc...

Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
Cofounder, http://www.knowspam.net enjoy email again!





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

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



More information about the antlr-interest mailing list