[antlr-interest] .* consuming all input
Bart Kiers
bkiers at gmail.com
Thu Jun 3 02:52:11 PDT 2010
On Thu, Jun 3, 2010 at 11:09 AM, Oliver Zeigermann <
oliver.zeigermann at gmail.com> wrote:
> Hi, I am pretty sure wildcards are *greedy* by default and ...
+ and * are normally greedy, except when preceded by a DOT. From "the
Definitive ANTLR reference":
*What you really want to type, though, and what you will see in other*
*systems, is the terse notation: ’.*’ and ’.+’. Unfortunately, following the
> *
*usual convention that all subrules are greedy makes this notation useless.*
*Such greedy subrules would match all characters until the end of*
*file. Instead, ANTLR considers them idioms for “Match any symbol until*
*you see what lies beyond the subrule.” ANTLR automatically makes*
*these two subrules nongreedy. So, you can use ’.*’ instead of manually*
*specifying the option.*
See chapter 4, *Extended BNF Subrules*, page 86.
Regards,
Bart.
More information about the antlr-interest
mailing list