[antlr-interest] Re: Use each token Once -- All required
Sergey Bogdanov
serge.bogdanov at intel.com
Tue Sep 21 09:51:11 PDT 2004
There is one idea that works for c++ generator:
XXX {int set=0}:
({(set & 1)==0}? TokenType1 {set |= 1;}
|{(set & (1<<1))==0}? TokenType2 {set |= (1<<1);}
|{(set & (1<<2))==0}? TokenType2 {set |= (1<<2);}
...
)+;
--- In antlr-interest at yahoogroups.com, "georgehernando"
<georgehernando at h...> 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
<*> 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