|
|
|
|
|
|
|
Re: Illegal escape character in json grammar for character that is in the grammar [message #1075371 is a reply to message #1073136] |
Mon, 29 July 2013 10:07 |
Claudio Heeg Messages: 75 Registered: April 2013 |
Member |
|
|
Hello,
sorry for reviving this thread again - I have now tried to work with the ValueConverter - Strings containing '\_' can be parsed now - however, Strings only containing a \, i.e. '\', still do not work and won't even lead to Illegal Escape Character Issues - the parsing will just break completely and there will be lots of syntactic errors as the String can't be read correctly.
However, shouldn't defining "'\\'" in my String terminal explicity allow such a String to exist?
Model:
assign+=STRING;
terminal STRING :
("\'\\\'") | ("'" ( '\\' ('b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\') | !('\\'|"'") )* "'")
;
Entering '\' leads to an error message - the error message states "1". Which is quite confusing.
--
Further edit:
Defining STRING as "\\", i.e. only the escape character, and then trying it out, leads to "String Index out of Range: -1" - seems to be a problem in the ValueConverter anyway, then?
---
More Editing:
Defining Strings as "\' \\ \'" also works as expected, with ' \ ' being parsed correctly as a String. Without the second space, it stops working - the \ seems to be seen as an escape for ' in any case, then.
-
Attachment: 1.png
(Size: 31.52KB, Downloaded 210 times)
[Updated on: Mon, 29 July 2013 10:41] Report message to a moderator
|
|
|
Re: Illegal escape character in json grammar for character that is in the grammar [message #1075400 is a reply to message #1075371] |
Mon, 29 July 2013 11:06 |
Claudio Heeg Messages: 75 Registered: April 2013 |
Member |
|
|
How i solved the issue:
First I explicitly disallowed the \' escaping.
Doing that led to the "1" error message, which still strikes me as a bug.
Following that I edited my ValueConverter (convertFromJavaString) so that it doesn't enter its further conversion on reading \ if the length of the read String is 1, i.e. adding the second clause in the following code if (aChar == '\\' && len>1)
Possibly not clean, but it seems to get the job done.
However, as mentioned, I still believe the "1" error message and the String Index out of Range message are bugs.
[Updated on: Mon, 29 July 2013 11:07] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.05094 seconds