[antlr-interest] Re: ANTLR 3.0 question about common actions

Terence Parr parrt at cs.usfca.edu
Wed Jul 28 16:55:58 PDT 2004


On Jul 28, 2004, at 3:13 PM, thrutchy wrote:
> I would kind of like the ability to go in the complete opposite
> direction: express the complete grammar directly in the target
> language in a nice concise manner.

That is called JavaCC :)

> I haven't thought through this all the way, but
> here's what I was thinking:
>
> * Parser/lexer rules/sub-rules would be objects.  All of these would
> belong to a superclass (or interface) - I'll call it "Syntax" for now.
>
> * Some of the more generic Syntax sub-classes might be LoopSyntax:()*,
> AlterationSyntax:(|), ConditionalSyntax:()?, IgnoreSyntax:()!,
> CodeSyntax:{}, SequenceSyntax:() (),  etc.
>
> * You'd just use new to create a new Syntax object:
>
> Syntax mexpr = new SequenceSyntax( atom, new LoopSyntax( new
> SequenceSyntax( STAR, atom) ) );
>
> ...

> One of the disadvantages I see immediately is ANTLR's ability to
> detect ambiguities at compile time.  I'm not sure how that would be
> best handled.

Yup...and why build a parse tree manually for a grammar when you can 
just type the grammar? ;)  Grammars are damn hard to beat as far as I 
can tell for specifying language syntax.

> What do you think?

Interesting thoughts, Eric.  Thanks!

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!
Cofounder, http://www.peerscope.com pure link sharing





 
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