[antlr-interest] Semantic analysis: implementation?
Bharath Sundararaman
bharath at starthis.com
Mon Aug 9 14:36:29 PDT 2004
Hi all,
Is there any example language for which there is complete semantic analysis
implemented in ANTLR? I looked at PASCAL's symbol table and I found it a
great starting point. However, a complete example for any language would be
most helpful. For example, I am having problems with checking types with a
particular range (eg. -10 to +10) and so on.
Thanks!
Bharath.
-----Original Message-----
From: Terence Parr [mailto:parrt at cs.usfca.edu]
Sent: Sunday, August 08, 2004 5:23 PM
To: antlr-interest at yahoogroups.com
Subject: Re: [antlr-interest] antlr.TokenWithIndex (and others) should be an
interface
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
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