[antlr-interest] Order independent keywords
Indhu Bharathi
indhu.b at s7software.com
Sun Mar 22 04:44:48 PDT 2009
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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090322/99385422/attachment.html
More information about the antlr-interest
mailing list