[antlr-interest] How does one refer to the char matching '.'?

Vaclav Barta vbar at comp.cz
Sun Jul 15 11:00:43 PDT 2007


On Sunday 15 July 2007 19:07, Randall R Schulz wrote:
> On Sunday 15 July 2007 09:59, Vaclav Barta wrote:
> > I'd like to have a lexer rule for string characters:
> >
> > StringChar
> >
> > 	: .
> >
> > 	;
> You might want to consider consolidating these characters, if that would
> work for your purposes:
Well, I don't know - I'm planning to have ${name} variables interpolated 
inside double-quoted strings (like in Unix shells), so a parser rule for 
strings seemed more natural to me than doing everything in the lexer... 
What's the usual way of implementing interpolated strings in ANTLR?

> Call the method "getText()" in the lexical rule's action.
Ah yes, there's actually no problem calling $StringChar.getText() in the 
parser rules using the token - thanks.

	Bye
		Vasek


More information about the antlr-interest mailing list