[TCS]unescaped text in ANTLR3LocationTokens [message #19467] |
Thu, 07 August 2008 12:54 |
T Kruse Messages: 73 Registered: July 2009 |
Member |
|
|
Hi,
I think I may have found a bug with the parsing of Strings.
usually the lexerString for DSLs in TCS includes
STRING
: '\"'!
( ESC
| '\\n' {newline();}
| ~('\\\\'|'\"'|'\\n')
)*
'\"'!
%v3 {ei.setText(ei.unescapeString(getText(), 1));}
;
The emit() method generated in the .g file looks like this:
public Token emit() {
org.eclipse.gmt.tcs.injector.wrappers.antlr3.ANTLR3LocationT oken ret =
null;
ret = new
org.eclipse.gmt.tcs.injector.wrappers.antlr3.ANTLR3LocationT oken(input,
type, channel, tokenStartCharIndex, getCharIndex()-1);
...
ret.setText(text);
...
}
Now for a String in the parsed DSL fragment like "\\r"
the emit method will first create an ANTLR3LocationToken with start and
stop indexes that would suit the escaped version of the string, while
ret.setText(Text) will then in this token set the text to something of a
different length (the unescaped String).
I am not sure whether this is a bug or intentional, it looks odd to me in
any case. It may be harmless for the whole injection process itself, but
for certain changes to TCS this can harm.
|
|
|
Powered by
FUDForum. Page generated in 0.03979 seconds