Hi,

Sorry if this is answered elsewhere, but I'm not really sure what to search
for.

I'm trying to parse a language that includes repeating groups. The problem
is that they don't include terminators, so you can't tell the difference
between the last item in the group, and the next section. Here's an example:

FIELD1
REPEATING_GROUP   <fields=2> <min=0, max=20>
    FIELD2
    FIELD3
FIELD4
...

"fields" specifies the number of fields contained in the group. At the
moment I've got the following rules, but the problem is that it means that
the repeating group rule doesn't get its fields associated with it:

recordDefinition
    :    RECORD (IDENTIFIER | repeatingGroup)+
    ;

repeatingGroup
    :    IDENTIFIER
        '<' NUMBER_OF_FIELDS '=' fieldCount=NUMBER '>'
        '<' NUMBER_OF_REPEATS '=' min=NUMBER ',' max=NUMBER '>'
    ;

Ideally I could do something like:

repeatingGroup
    :    IDENTIFIER
        '<' NUMBER_OF_FIELDS '=' fieldCount=NUMBER '>'
        '<' NUMBER_OF_REPEATS '=' min=NUMBER ',' max=NUMBER '>'
        IDENTIFIER{1, $fieldCount}
    ;

But I know you can't do that. What would the best way be to go about parsing
this? Can I build an AST then modify it to put the identifiers for the
repeating group in the right place.

Cheers,
Adam

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.

Reply via email to