2008/9/13 Johannes Luber <[EMAIL PROTECTED]>:
> 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.
I can't, that's where I startedQ
Tweaking the above to let it compile I get
grammar Test;
tokens {
STAR='*';
}
WHITESPACE: ('\t' | ' ') ;
CONTENT: ~(NEWLINE)+;
NEWLINE: '\r' | '\n';
start: line* ;
line: (c=CONTENT NEWLINE ) {
System.out.println("<para>"+ $c.text +"</para>\n" );}|
STAR c=CONTENT+ NEWLINE+ {
System.out.println("<list>"+ $c.text );} ;
Test input
content only
* LIST list content
* LIST list content more
The output is
<para>content only</para>
<para>* LIST list content</para>
<para>* LIST list content more</para>
regards
--
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk
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
-~----------~----~----~----~------~----~------~--~---