isStringLiteral

Checks if a string literal input has correct start/end sequences (quotes) to be any kind of D string literal.

Bugs

doesn't check for validity of token strings.

Examples

assert(isStringLiteral(`"hello"`));
assert(isStringLiteral(`"hello world!"`));
assert(isStringLiteral(`r"hello world!"c`));
assert(isStringLiteral(`r"hello world!"d`));
assert(isStringLiteral(`q{cool}`));
assert(isStringLiteral(`q{cool\}`));
assert(isStringLiteral(`"\\"`));
assert(!isStringLiteral(`"\\\"`));
assert(isStringLiteral(`"\\\\"`));
assert(isStringLiteral(`"a\\\\"`));
assert(isStringLiteral(`""`));
assert(isStringLiteral(`q""`));
assert(isStringLiteral(`x""`));
assert(!isStringLiteral(``));
assert(!isStringLiteral(`"`));
assert(!isStringLiteral(`w""`));
assert(!isStringLiteral(`hello"`));
assert(!isStringLiteral(`"hello`));
assert(!isStringLiteral(`"hello world`));
assert(!isStringLiteral(`hello world`));
assert(!isStringLiteral(`r"`));
assert(!isStringLiteral(`rr"ok"`));
assert(!isStringLiteral(`x"`));
assert(!isStringLiteral(`x" `));
assert(!isStringLiteral(`qqqq`));

Meta