Hi, My grammar needs to handle the following situation: A line can have multiple fields, separated by a delimiter. A field can have multiple components, separated by another delimiter. If a field or component is blank, it should be counted as a blank field or blank component. For example with field delimiter '+' and component delimiter ':' : UNB++::+123 is a 'UNB' line with 3 fields. The first field is blank, the second field has 3 blank components, and the last field has a single component with the value '123'.
Here is my grammar so far: line : TEXT fields ; fields : field* terminator! ; field : SEP t=fieldText? -> ^(FIELD $t?) ; fieldText : comp (CSEP comp)* ; comp : t=TEXT -> ^(COMP $t) ; When a field is blank, e.g. '++', this correctly generates a ^(FIELD) with no children. However, I don't know how to get similar behaviour for the components, because whereas a field starts with a SEP and optional TEXT, the component may or may not have a leading CSEP. When the input is '+::+', there are three components, but the first is entirely blank, an empty string. What I would like is that '+::+' creates ^(FIELD ^(COMP) ^(COMP) ^(COMP)). How can I accomplish this? Thanks, Rob _________________________________________________________________ Windows Live helps you keep up with all your friends, in one place. http://go.microsoft.com/?linkid=9660826 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com 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