Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » STRINGValueConverter(Parser fails when strings contain escape sequences)
STRINGValueConverter [message #1697216] Tue, 02 June 2015 13:29 Go to next message
Anakreontas Mentis is currently offline Anakreontas MentisFriend
Messages: 85
Registered: October 2014
Member
I have the following rule for matching a String:
terminal STRING : '"' !'"'* '"';

The rule does not support escape sequences; only double quotes have a special meaning.

However, when a parser rule refers to the STRING rule I get an exception with the message:
Invalid escape sequence (valid ones are \b \t ....
defined by the method getInvalidEscapeSequenceMessage of class org.eclipse.xtext.conversion.impl.STRINGValueConverter.

I discovered that if a parser invokes instead a data rule, it works fine. e.g.:
myRule : val = STRING;
fails for input "\_String"
while
myRule2 : val = fstr;
fstr : STRING;
succeeds.

I find this behavior surprising. Why does xtext enforces the lexing rules of Java on the strings and secondly how come a data rule solves the problem?
Re: STRINGValueConverter [message #1697228 is a reply to message #1697216] Tue, 02 June 2015 14:48 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3109
Registered: July 2009
Senior Member
The STRINGValueConverter is just the default impl for the default
terminal rule. Feel free to register a custom subtype of the
STRINGValueConverter and bind it in your runtime module.

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Find help at http://xtext.itemis.com or xtext(@)itemis.com
Blog: zarnekow.blogspot.com
Twitter: @szarnekow
Google+: https://www.google.com/+SebastianZarnekow
Previous Topic:Xtext & Xtend 2.8.3 released
Next Topic:Runnin Xtext in a no-display environment
Goto Forum:
  


Current Time: Sun Apr 18 09:51:53 GMT 2021

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

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

Back to the top