[antlr-interest] what does .* match

Johannes Luber jaluber at gmx.de
Mon Jun 25 04:39:53 PDT 2007


Anders Hessellund wrote:
> Hi,
> 
> I just bought the new ANTLR book, but I can not find any good
> description of what the .* notation means. On p.85-6 there is an example
> of comments:
> 
>     ML_COMMENT : '/*' .* '*/';
> 
> 
> According to the book, this matches any character until it encounters */
> 
> In my implementation it does however complain about '*' with the 'no
> viable alternative' error. Does '.*' match everything except '*'?

Having not seen your grammar, I can't be sure why you receive your
complaint, but it shouldn't be because of ".*". The meaning of "." is 1.
Any character, 2. Any token, 3. Any subtree, depending on the position
of "." and kind of grammar you are using. In your case it is 1. For
further diagnostics please post your entire grammar.

Best regards,
Johannes Luber


More information about the antlr-interest mailing list