[antlr-interest] similar constructs using '[' ']'
Raphael Reitzig
r_reitzi at cs.uni-kl.de
Fri Jul 11 00:32:51 PDT 2008
Hi Marc!
EXT_EXPR is a lexer rule while sequence is a parser rule. Since lexer
output serves as parser input, lexer has to process your input first.
There, your rule EXT_EXPR will match anything with [, ] arouund it. Then,
your parser will receive an EXT_EXPR token, no arbitrary string. That is,
if I got ANTLR way of parsing right ;)
Greets
List.Raphael
On Fri, 11 Jul 2008 08:52:32 +0200, Marc Bischof <atlan at gmx.li> wrote:
> Hej List,
>
> I'am confused about the following, may be you can give me a hint.
>
> I have two similar constructs using '[' ']'.
> One which represents an extended expression (using nongreedy wildcard)
and
> one
> which contain some other stuff.
>
> Now every time I want to use the sequence rule the EXT_EXPR is invoked.
> Is it possible to keep that modelling?
>
> sequence
> : ('[' j+=join? s+=signal* ']')? b=body ;
>
> join
> : 'join' '(' k+=ID (',' k+=ID)* (',' expr)? ')' -> ^(JOIN $k+ expr?);
>
> expr
> : s_expr | EXT_EXPR | funct_call;
>
> EXT_EXPR
> : '[' (options {greedy=false;} : .)* ']';
>
> Cheers Marc
More information about the antlr-interest
mailing list