[antlr-interest] Trouble with the multiline comment example from FAQ

Bart Kiers bkiers at gmail.com
Mon Jul 18 12:48:33 PDT 2011


Hi,

This ought to work:

NESTED_ML_COMMENT
  :  '[' (~('[' | ']') | NESTED_ML_COMMENT)* ']'
  ;


Regards,

Bart.


On Mon, Jul 18, 2011 at 9:44 PM, Dejas Ninethousand <dejas9000 at gmail.com>wrote:

> I've modified the multiline comment example from the FAQ (
> http://www.antlr.org/wiki/pages/viewpage.action?pageId=1573) to be:
>
> NESTED_ML_COMMENT
>    :   '['
>        (options {greedy=false;} : NESTED_ML_COMMENT | . )*
>        ']' {$channel=HIDDEN;}
>    ;
>
> However, it is not behaving as expected in the ANLTRWorks interpreter.
>  When
> I ask the interpreter to match on:
>
> []
>
> there is no problem, but when I ask it to match on:
>
> [j]
>
> I get a mismatched token exception.  Any thoughts as to why?
>
> Thanks.
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>


More information about the antlr-interest mailing list