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
diff --git a/tools/llvm-mc/AsmLexer.cpp b/tools/llvm-mc/AsmLexer.cpp
index 95937d2..dbd3c06 100644
--- a/tools/llvm-mc/AsmLexer.cpp
+++ b/tools/llvm-mc/AsmLexer.cpp
@@ -75,17 +75,18 @@
   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 @@
   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 @@
   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][:]