aboutsummaryrefslogtreecommitdiff
path: root/tools/llvm-mc/AsmLexer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-06-23 05:57:07 +0000
committerChris Lattner <sabre@nondot.org>2009-06-23 05:57:07 +0000
commit8dfbe6c853e3e48b6e7b5957a4e028835ffe4400 (patch)
tree8bb6cf9cbfc86c6e0adb23ff5561f0c9ed75f0b6 /tools/llvm-mc/AsmLexer.cpp
parente07715cfba5528dfa368b25d484602ca2b0e1892 (diff)
implement a trivial binary expression parser, we can now parse all of 176.gcc.llc.s
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73950 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-mc/AsmLexer.cpp')
-rw-r--r--tools/llvm-mc/AsmLexer.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/tools/llvm-mc/AsmLexer.cpp b/tools/llvm-mc/AsmLexer.cpp
index 95937d2a60..dbd3c06db7 100644
--- a/tools/llvm-mc/AsmLexer.cpp
+++ b/tools/llvm-mc/AsmLexer.cpp
@@ -75,17 +75,18 @@ asmtok::TokKind AsmLexer::LexIdentifier() {
while (isalnum(*CurPtr) || *CurPtr == '_' || *CurPtr == '$' ||
*CurPtr == '.' || *CurPtr == '@')
++CurPtr;
- CurStrVal.assign(TokStart, CurPtr); // Include %
+ CurStrVal.assign(TokStart, CurPtr);
return asmtok::Identifier;
}
/// LexPercent: Register: %[a-zA-Z0-9]+
asmtok::TokKind AsmLexer::LexPercent() {
if (!isalnum(*CurPtr))
- return ReturnError(TokStart, "invalid register name");
+ return asmtok::Percent; // Single %.
+
while (isalnum(*CurPtr))
++CurPtr;
- CurStrVal.assign(TokStart, CurPtr); // Skip %
+ CurStrVal.assign(TokStart, CurPtr); // Include %
return asmtok::Register;
}
@@ -243,6 +244,10 @@ asmtok::TokKind AsmLexer::LexToken() {
case '*': return asmtok::Star;
case ',': return asmtok::Comma;
case '$': return asmtok::Dollar;
+ case '|': return asmtok::Pipe;
+ case '^': return asmtok::Caret;
+ case '&': return asmtok::Amp;
+ case '!': return asmtok::Exclaim;
case '%': return LexPercent();
case '/': return LexSlash();
case '#': return LexHash();
@@ -250,6 +255,20 @@ asmtok::TokKind AsmLexer::LexToken() {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
return LexDigit();
+ case '<':
+ if (*CurPtr == '<') {
+ ++CurPtr;
+ return asmtok::LessLess;
+ }
+ // Don't have any use for bare '<' yet.
+ return ReturnError(TokStart, "invalid character in input");
+ case '>':
+ if (*CurPtr == '>') {
+ ++CurPtr;
+ return asmtok::GreaterGreater;
+ }
+ // Don't have any use for bare '>' yet.
+ return ReturnError(TokStart, "invalid character in input");
// TODO: Quoted identifiers (objc methods etc)
// local labels: [0-9][:]