Maybe you are looking for something like this:

    attributes
        :    attribute+
        ;

    attribute
        :    typeAttr
        |    lengthAttr
        |    pathAttr
        ;

Here is a complete sample:

    grammar Test;

    attributes
        :    attribute+
        ;

    attribute
        :    typeAttr
        |    lengthAttr
        |    pathAttr
        ;

    typeAttr    :    'TYPE' ID ';'
        ;
       
    lengthAttr
        :    'LENGTH' NUMBER ';'
        ;
       
    pathAttr    :    'PATH' ID ';'
        ;
       
    ID    :    'a'..'z'+
        ;
       
    NUMBER    :    '0'..'9'+
        ;
       
    WS    :    (' ' | '\t' | '\n')+ {$channel = HIDDEN;}
        ;
       


- Indhu


register reg.ini wrote:
> Hi everybody,
> I am trying to parse a custom configuration file format using antlr.
> This file format describes properties of several Paramaters using C 
> like structs, for example:
>
> Record
> {
>        TYPE typeid;
>        LENGHT 80;
>        PATH= pathtofile
> }
>
> . The order of the attributes is irrelevant but some of them are 
> required other are simply optional. Is it possible to embody the 
> requirement of order independent attributes directly in the parser 
> grammar, without using actions?
> Thanks in advance,
> Luca
>
> ------------------------------------------------------------------------
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to