[antlr-interest] Rule automation

Sam Barnett-Cormack s.barnett-cormack at lancaster.ac.uk
Wed Sep 9 02:24:06 PDT 2009


Hi,

Rule templatisation might be a funky feature to be added, but it doesn't 
exist at present, AFAIK.

Sam

Martin Potier wrote:
> Hi all,
> 
> I've got something on my mind that the Definitive ANTLR Reference
> couldn't solve (yet, I'm not tottally through it).
> Is there a way with ANTLR v3 to automate some rule ?
> 
> Id est, while building a small wiki language I wrote this kind of rule :
> text
>     : (PURETEXT ( inlinenv | PURETEXT )*)
>     | (inlinenv (PURETEXT | inlinenv)*)
>     ;
> 
> In fact, I use the same sort of rule every time  I introduce text in a
> inlinenv.
> 
> I'd like to know if there's a way to create a generic rule like the
> following :
> generic altern ((ARG1, ARG2))
>     : (ARG1 (ARG2 | ARG1)*)
>     | (ARG2 (ARG1 | ARG2)*)
>     ;
> 
> And then reuse it, like an operator ?
> 
> 
> Cheers,
> Martin
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address


-- 
Sam Barnett-Cormack


More information about the antlr-interest mailing list