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
This commit is contained in:
Chris Lattner
2009-06-23 05:57:07 +00:00
parent e07715cfba
commit 8dfbe6c853
4 changed files with 84 additions and 7 deletions

View File

@@ -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][:]