[antlr-interest] Lists. Lexer or Parser?

Dave Pawson dave.pawson at gmail.com
Sat Sep 13 05:35:16 PDT 2008


2008/9/13 Johannes Luber <jaluber at gmx.de>:
> 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?
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.


I guess I can leave this one till I've read more about navigating trees.

regards


-- 
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk


More information about the antlr-interest mailing list