Lexer: Lex escaped identifier tokens.

Lex a backtick-enclosed `[:identifier_start:][:identifier_cont:]+` as an identifier, even if it's a Swift keyword. For now, require that the escaped name still be a valid identifier, keyword collisions notwithstanding. (We could in theory allow an arbitrary string, but we'd have to invent a mangling for non-identifier characters and do other tooling which doesn't seem productive.)

Swift SVN r14671
This commit is contained in:
Joe Groff
2014-03-05 03:47:12 +00:00
parent 9c5dfd61df
commit 424187e482
5 changed files with 106 additions and 3 deletions

View File

@@ -216,7 +216,11 @@ public:
void restoreState(State S) {
assert(S.isValid());
CurPtr = getBufferPtrForSourceLoc(S.Loc);
// Don't reemit diagnostics while readvancing the lexer.
auto TmpDiags = Diags;
Diags = nullptr;
lexImpl();
Diags = TmpDiags;
}
/// \brief Restore the lexer state to a given state that is located before
@@ -366,6 +370,7 @@ private:
bool StopAtDoubleQuote, bool EmitDiagnostics);
void lexCharacterLiteral();
void lexStringLiteral();
void lexEscapedIdentifier();
};