[antlr-interest] wildcard isn't?

Kay Roepke kroepke at classdump.org
Thu Aug 2 09:36:50 PDT 2007


On Aug 2, 2007, at 6:26 PM, Jack Tanner wrote:

> It works fine then, but it seems bizarre that the . wildcard  
> doesn't consume the
> slash. Is that a bug, or am I misunderstanding the wildcard?

There's a distinction between what happens in lexer vs. parser rules  
(rules starting with a lowercase
letter are always parser rules).

The . in parser rules consumes tokens and not individual characters,  
so what happens in

line	:	comment? EOL ;
comment	:	'#' .* ;
EOL	:	'\r' | '\n' | '\r\n' ;

is that ANTLR consumes any number of any token in comment. What  
tokens does you lexer emit?
In lexer grammars the . means any character.

Surely this is not the entire grammar, right?

HTH,
-k

-- 
Kay Röpke
http://classdump.org/






More information about the antlr-interest mailing list