[antlr-interest] Unquoting strings
ddr1975 at gmail.com
Wed May 14 12:29:12 PDT 2008
Browsing through some tutorials, I was left with the impression that
appending an exclamation mark to a character would remove that character
from the parsed token, e.g.:
'\''! // or single quoted string
( '\\'! '\''
Would cause the enclosing quotes to be removed. This seems to not be
happening in the Java generated code, so I had to resort to the following
ugly hack, which manually removes the quotes:
: (DoubleQuotedString | SingleQuotedString)
// Strip the surrounding quotes
String txt = getText();
setText(txt.substring(1, txt.length() -1));
This works, but it's not nice. Does anybody know what I might be doing wrong
in the SingleQotedString rule?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the antlr-interest