Skip to content

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

Open
@scharf

Description

@scharf

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'|'"'|"'"|'\\')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions