aboutsummaryrefslogtreecommitdiff
path: root/tools/llvm-mc/AsmLexer.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-06-29 20:37:27 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-06-29 20:37:27 +0000
commit475839e9a97a0c0282e107d14fd1dc6e5f223435 (patch)
tree6d5ed8824683ef43a3491907d099c275ef8e0044 /tools/llvm-mc/AsmLexer.cpp
parentcffddcd72620d76e160c25780277c26d6792ca2c (diff)
MC: Improve expression parsing and implement evaluation of absolute expressions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74448 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-mc/AsmLexer.cpp')
-rw-r--r--tools/llvm-mc/AsmLexer.cpp39
1 files changed, 25 insertions, 14 deletions
diff --git a/tools/llvm-mc/AsmLexer.cpp b/tools/llvm-mc/AsmLexer.cpp
index db86825f3d..f871d065c4 100644
--- a/tools/llvm-mc/AsmLexer.cpp
+++ b/tools/llvm-mc/AsmLexer.cpp
@@ -262,11 +262,23 @@ asmtok::TokKind AsmLexer::LexToken() {
case '*': return asmtok::Star;
case ',': return asmtok::Comma;
case '$': return asmtok::Dollar;
- case '=': return asmtok::Equal;
- case '|': return asmtok::Pipe;
+ case '=':
+ if (*CurPtr == '=')
+ return ++CurPtr, asmtok::EqualEqual;
+ return asmtok::Equal;
+ case '|':
+ if (*CurPtr == '|')
+ return ++CurPtr, asmtok::PipePipe;
+ return asmtok::Pipe;
case '^': return asmtok::Caret;
- case '&': return asmtok::Amp;
- case '!': return asmtok::Exclaim;
+ case '&':
+ if (*CurPtr == '&')
+ return ++CurPtr, asmtok::AmpAmp;
+ return asmtok::Amp;
+ case '!':
+ if (*CurPtr == '=')
+ return ++CurPtr, asmtok::ExclaimEqual;
+ return asmtok::Exclaim;
case '%': return LexPercent();
case '/': return LexSlash();
case '#': return LexHash();
@@ -275,19 +287,18 @@ asmtok::TokKind AsmLexer::LexToken() {
case '5': case '6': case '7': case '8': case '9':
return LexDigit();
case '<':
- if (*CurPtr == '<') {
- ++CurPtr;
- return asmtok::LessLess;
+ switch (*CurPtr) {
+ case '<': return ++CurPtr, asmtok::LessLess;
+ case '=': return ++CurPtr, asmtok::LessEqual;
+ case '>': return ++CurPtr, asmtok::LessGreater;
+ default: return asmtok::Less;
}
- // Don't have any use for bare '<' yet.
- return ReturnError(TokStart, "invalid character in input");
case '>':
- if (*CurPtr == '>') {
- ++CurPtr;
- return asmtok::GreaterGreater;
+ switch (*CurPtr) {
+ case '>': return ++CurPtr, asmtok::GreaterGreater;
+ case '=': return ++CurPtr, asmtok::GreaterEqual;
+ default: return asmtok::Greater;
}
- // 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][:]