Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [TCS]unescaped text in ANTLR3LocationTokens
[TCS]unescaped text in ANTLR3LocationTokens [message #19467] Thu, 07 August 2008 12:54
T Kruse is currently offline T KruseFriend
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.
Previous Topic:Re: right newsgroup for XText questions
Next Topic:[xText] Error in the generated PartitionScanner
Goto Forum:
  


Current Time: Sat Dec 21 16:57:43 GMT 2024

Powered by FUDForum. Page generated in 0.03979 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top