Hey Jim,

> It is a problem with the code generation templates for all the targets (well, 
> Java and C at least), someone did post a fix for it on the list, but it has 
> not been issued as any formal patch yet.

Definitely not for C# because this code was taken from a grammar that works 
well with C#.

>  
> privilege_level
> : privs -> ^(PRIVILEGE_LEVEL $privs)
> ;
> privs
> : (MULT|IDENTIFIER) (DOT^ (MULT|IDENTIFIER))?
> ;
>  
> Though in fact I would avoid the PRIVILEGE_LEVEL node altogether unless its 
> absence causes ambiguity issues in the tree grammar.

Hmm, in fact, what I want to achieve actually is a bit different. But I have 
some difficulties to formulate the grammar properly. These are the cases I want 
to handle:

id
id.     (error: missing id or star)
id.*
id.id
id.id.  (error: missing id or star)
id.id.*
id.id.id

I would be thankful for a hint to get my brain into the right direction. The 
best I could come up with is that I get a tree with an invalid node. Tho 
actually I would like the special node with the missing value (to ease their 
handling, e.g. for code completion). My current grammar is:

primary:
        parExpression
        | literal
        | number
        | { LA(2) != DOT }? identifier (INC | DEC)?
        | identifier DOT qualified_field
;

number:
        NUM
        | HEX_NUM
        | DIGITS
        | DECIMAL_NUM
;

qualified_field:
        MULT
        | { LA(2) != DOT }? identifier
        | identifier DOT qualified_field2
;

qualified_field2:
        MULT
        | { LA(2) != DOT }? identifier
;

Without the lookaheads the matching process stops for cases like "id." 
returning only the id without error.

Mike
-- 
www.soft-gems.net

_______________________________________________
antlr-dev mailing list
antlr-dev@antlr.org
http://www.antlr.org/mailman/listinfo/antlr-dev

Reply via email to