[antlr-interest] getText()
Tim Poole
tim at poole.co.uk
Fri Oct 21 09:39:23 PDT 2011
Hi,
I have just had to use this to change the single quotes around a string
to double quotes:
STRINGLITERAL
: (QUOTE (ESCAPEQUOTE | CHARNOQUOTE)* QUOTE)
| (APOS (ESCAPEAPOS | CHARNOAPOS)* APOS)
{setText(getText().replace('\'','\"'));}
;
It's an adaptation of:
http://antlr.org/grammar/1264460091565/XPath2.g
I tried to do the following, without success:
STRINGLITERAL
: (QUOTE (ESCAPEQUOTE | CHARNOQUOTE)* QUOTE)
| (APOS st=(ESCAPEAPOS | CHARNOAPOS)* APOS) {setText("\"" +
$st.text + "\"");}
;
Any ideas on how I can implement something along the lines of the second
one? It was easy to rewrite this time, but next time might not be so easy!
Thanks in advance,
Tim.
More information about the antlr-interest
mailing list