Greetings!
On Wed, 2009-09-09 at 10:45 +0200, Martin Potier wrote:
> 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 ?
>
>
As earlier replies have stated ANTLR does not do that (at the moment
anyway).
But I just wanted to point out to you that any rule of the form:
any_rule
: ( arg1 ( arg2 | arg1 )* )
| ( arg2 ( arg1 | arg2 )* )
;
is the same as:
any_rule : ( arg1 | arg2 )+ ;
might save you some keyboarding in your .g file....
Not much value added, but hope this helps.
-jbb
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/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
-~----------~----~----~----~------~----~------~--~---