[antlr-interest] Use each token Once -- All required

Terence Parr parrt at cs.usfca.edu
Tue Sep 21 11:05:32 PDT 2004

Hi.  Restriction on number can be encoded in syntax but as you point 
out combinations are combinatorial in size ;)

I suggest simply using the first XXX rule and then an action at the end 
that asks if everything is covered exactly once.  Perhaps a bitset 
updated in each alt and then simply checked at the end.

The distinction between syntax and semantics is very often blurred. :)


On Sep 21, 2004, at 8:15 AM, georgehernando wrote:

> How can I specify a compact syntax for the parser that will define a
> list of token types from the lexer where each type must appear, but
> only one time?
> XXX :  (TokenType1 | TokenType2 | TokenType3 | TokenType4)+;
> doesn't limit the token types to appearing only one time.
> Do I have to specify all permutations?
> XXX :  ( (TokenType1 TokenType2 TokenType3 TokenType4) |
>          (TokenType1 TokenType2 TokenType4 TokenType3) |
>          (TokenType1 TokenType4 TokenType3 TokenType2) |
>          (TokenType4 TokenType2 TokenType3 TokenType1) |
>          (TokenType2 TokenType1 TokenType3 TokenType4) |
>          ....
>         )
> Yahoo! Groups Links
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:

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

<*> Your use of Yahoo! Groups is subject to:

More information about the antlr-interest mailing list