diff options
author | Chris Lattner <sabre@nondot.org> | 2009-06-21 19:56:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-06-21 19:56:35 +0000 |
commit | 10a907d70fb54c40eecabb889e81c79b44092221 (patch) | |
tree | 1e591f04503eaa3c0bc13f1f0a7f227a6f20347a /tools/llvm-mc/AsmLexer.cpp | |
parent | 4506bd2cfd3e75535670890031eec26e216993b8 (diff) |
add string literals.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73858 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-mc/AsmLexer.cpp')
-rw-r--r-- | tools/llvm-mc/AsmLexer.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/tools/llvm-mc/AsmLexer.cpp b/tools/llvm-mc/AsmLexer.cpp index 4a68d0d354..f29075ace4 100644 --- a/tools/llvm-mc/AsmLexer.cpp +++ b/tools/llvm-mc/AsmLexer.cpp @@ -77,7 +77,7 @@ asmtok::TokKind AsmLexer::LexIdentifier() { while (isalnum(*CurPtr) || *CurPtr == '_' || *CurPtr == '$' || *CurPtr == '.' || *CurPtr == '@') ++CurPtr; - CurStrVal.assign(TokStart, CurPtr); // Skip % + CurStrVal.assign(TokStart, CurPtr); // Include % return asmtok::Identifier; } @@ -194,6 +194,28 @@ asmtok::TokKind AsmLexer::LexDigit() { return asmtok::IntVal; } +/// LexQuote: String: "..." +asmtok::TokKind AsmLexer::LexQuote() { + int CurChar = getNextChar(); + // TODO: does gas allow multiline string constants? + while (CurChar != '"') { + if (CurChar == '\\') { + // Allow \", etc. + CurChar = getNextChar(); + } + + if (CurChar == EOF) { + PrintError(TokStart, "unterminated string constant"); + return asmtok::Eof; + } + + CurChar = getNextChar(); + } + + CurStrVal.assign(TokStart, CurPtr); // include quotes. + return asmtok::String; +} + asmtok::TokKind AsmLexer::LexToken() { TokStart = CurPtr; @@ -228,6 +250,7 @@ asmtok::TokKind AsmLexer::LexToken() { case '%': return LexPercent(); case '/': return LexSlash(); case '#': return LexHash(); + case '"': return LexQuote(); case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': return LexDigit(); |