in src/language/semantics/xpLexer.ts [934:968]
public static checkExitStringLiteralEnd(
lastToken: BaseToken,
result: BaseToken[]
) {
let followsEntityRef = false
let followsString = false
if (result.length > 1) {
const nextLastToken = result[result.length - 2]
followsEntityRef = nextLastToken.tokenType === TokenLevelState.entityRef
followsString = nextLastToken.tokenType === TokenLevelState.string
}
if (followsEntityRef) {
let lastChar = lastToken.value.charAt(lastToken.value.length - 1)
const lastCharIsSingleQuote = lastChar === "'"
if (
lastChar !== '"' &&
!lastCharIsSingleQuote &&
!lastToken.value.endsWith('"') &&
!lastToken.value.startsWith(''')
) {
lastToken['error'] = ErrorType.XPathStringLiteral
} else if (
lastChar === '"' ||
(lastChar === "'" && lastToken.length > 1)
) {
const mod2Chars =
[...lastToken.value].filter((l) => l === lastChar).length % 2
if (mod2Chars === 0) {
lastToken['error'] = ErrorType.XPathStringLiteral
}
}
} else if (!followsString) {
this.checkStringLiteralEnd(lastToken)
}
}