[antlr-interest] newbie, need help!

anteusz at freemail.hu anteusz at freemail.hu
Tue May 11 06:14:49 PDT 2010


5/11/2010 11:37 AM keltezéssel, Terry Ma írta:
> hello, everyone.
>
> I want to parse the statement like following:
>
> any character<#if expression>  any character</#if>  any character
>
> I want to consume any character until find<#if ...>,
> and then consume any character until find next</#if>,
> and so on.
>
> can i use antlr to do this?
> i don't know how to write the grammar to parse the above statement.
>
>
> Terry.
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
>    
Do you mean something like this:

grammar if;


start_rule    : anythingbefore anythinguntilclosingif;

anythingbefore:  ( options {greedy=false;} : . )* '<#if';


anythinguntilclosingif
     :    ( options {greedy=false;} : . )* '</#if>';


Marton



More information about the antlr-interest mailing list