Dave Pawson schrieb:
> 2008/9/13 Johannes Luber <[EMAIL PROTECTED]>:
>> Dave Pawson schrieb:
>
>>> The input is
>>>
>>> blah
>>> blah
>>>
>>> *list item 1
>>> * list content 2
>> There is one. I'd define a grammar like:
>>
>> grammar Test;
>>
>> tokens {
>> LIST='LIST';
>> STAR=''*';
>> }
>>
>> CONTENT: ('a'..'z' | 'A'..'Z')+;
>> NEWLINE: '\r' | '\n';
>> WHITESPACE: ('\t' | ' ')+ {$channel = HIDDEN;};
>>
>> start: line*;
>>
>> line: content+ NEWLINE+
>> | STAR LIST content+ NEWLINE+
>> ;
>
>
> That requires the string 'LIST' on each list element?
'LIST' can be removed, if that bothers you.
> My input is line based plain text.
>
> A list starts from the first occurrence of
> * Any string content to end of line
>
> and ends on the last
> * Any string content up to end of line.
grammar Test;
tokens {
STAR=''*';
}
CONTENT: ~NEWLINE+; // possibly ~(NEWLINE|WHITESPACE)+
NEWLINE: '\r' | '\n';
WHITESPACE: ('\t' | ' ')+ {$channel = HIDDEN;};
start: line*;
line: content+ NEWLINE+
| STAR content+ NEWLINE+
;
You can add actions which determine the beginning and the end of the list.
Johannes
>
> I guess I can leave this one till I've read more about navigating trees.
>
> regards
>
>
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org:8080/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
-~----------~----~----~----~------~----~------~--~---