mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-21 18:29:45 +00:00
MIR Parser: Reuse the function 'lexName' when lexing global value tokens. NFC.
This commit refactors the function 'maybeLexGlobalValue' so that now it reuses the function 'lexName' when lexing a named global value token. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242837 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
52509c07e5
commit
5938be0e84
@ -240,37 +240,6 @@ static Cursor maybeLexRegister(Cursor C, MIToken &Token) {
|
||||
return C;
|
||||
}
|
||||
|
||||
static Cursor maybeLexGlobalValue(
|
||||
Cursor C, MIToken &Token,
|
||||
function_ref<void(StringRef::iterator Loc, const Twine &)> ErrorCallback) {
|
||||
if (C.peek() != '@')
|
||||
return None;
|
||||
auto Range = C;
|
||||
C.advance(); // Skip the '@'
|
||||
if (C.peek() == '"') {
|
||||
if (Cursor R = lexStringConstant(C, ErrorCallback)) {
|
||||
Token = MIToken(MIToken::QuotedNamedGlobalValue, Range.upto(R),
|
||||
/*StringOffset=*/1); // Drop the '@'
|
||||
return R;
|
||||
}
|
||||
Token = MIToken(MIToken::Error, Range.remaining());
|
||||
return Range;
|
||||
}
|
||||
if (!isdigit(C.peek())) {
|
||||
while (isIdentifierChar(C.peek()))
|
||||
C.advance();
|
||||
Token = MIToken(MIToken::NamedGlobalValue, Range.upto(C),
|
||||
/*StringOffset=*/1); // Drop the '@'
|
||||
return C;
|
||||
}
|
||||
auto NumberRange = C;
|
||||
while (isdigit(C.peek()))
|
||||
C.advance();
|
||||
Token =
|
||||
MIToken(MIToken::GlobalValue, Range.upto(C), APSInt(NumberRange.upto(C)));
|
||||
return C;
|
||||
}
|
||||
|
||||
static Cursor lexName(
|
||||
Cursor C, MIToken &Token, MIToken::TokenKind Type,
|
||||
MIToken::TokenKind QuotedType, unsigned PrefixLength,
|
||||
@ -291,6 +260,25 @@ static Cursor lexName(
|
||||
return C;
|
||||
}
|
||||
|
||||
static Cursor maybeLexGlobalValue(
|
||||
Cursor C, MIToken &Token,
|
||||
function_ref<void(StringRef::iterator Loc, const Twine &)> ErrorCallback) {
|
||||
if (C.peek() != '@')
|
||||
return None;
|
||||
if (!isdigit(C.peek(1)))
|
||||
return lexName(C, Token, MIToken::NamedGlobalValue,
|
||||
MIToken::QuotedNamedGlobalValue, /*PrefixLength=*/1,
|
||||
ErrorCallback);
|
||||
auto Range = C;
|
||||
C.advance(1); // Skip the '@'
|
||||
auto NumberRange = C;
|
||||
while (isdigit(C.peek()))
|
||||
C.advance();
|
||||
Token =
|
||||
MIToken(MIToken::GlobalValue, Range.upto(C), APSInt(NumberRange.upto(C)));
|
||||
return C;
|
||||
}
|
||||
|
||||
static Cursor maybeLexExternalSymbol(
|
||||
Cursor C, MIToken &Token,
|
||||
function_ref<void(StringRef::iterator Loc, const Twine &)> ErrorCallback) {
|
||||
|
Loading…
Reference in New Issue
Block a user