Nodeclipse / coffeescript-eclipse

CoffeeScript plugin for Eclipse using XText (moved to Nodeclipse; looking for new owner)
http://www.nodeclipse.org/coffeescript/
20 stars 9 forks source link

strings are parsed incorrectly when an unexpected character after a \ is used #12

Open scharf opened 11 years ago

scharf commented 11 years ago

the following strings are valid coffeesctipt (and javascript string):


s="\W"
s="\z"
s="\="

Javascript ignores any \ that is used for characters that are not expected.

Here is my proposal for a better string rule in xtext:


terminal STRING:
    "'''" -> "'''" |
    "'" ( (!("'"|'\\') | ('\\' !('\n' | '\r'))) ('\\' !('\n' | '\r') | !('\\'|"'"))*)? "'" |
    '"""' -> '"""' |
    '"' ( (!('"'|'\\') | ('\\' !('\n' | '\r'))) ('\\' !('\n' | '\r')  | !('\\'|'"'))*)? '"';

It would be nice to get a warning if an unexpected character is used in a string. But is should not fail to parse the rest of the file....

It would be nice to issue an (optional) warning if the character after a \ is not in the list of meaningful characters:

('b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\')