30 Cursor(
NoneType) : Ptr(nullptr), End(nullptr) {}
34 End = Ptr + Str.
size();
37 bool isEOF()
const {
return Ptr == End; }
39 char peek(
int I = 0)
const {
return End - Ptr <=
I ? 0 : Ptr[
I]; }
41 void advance(
unsigned I = 1) { Ptr +=
I; }
46 assert(C.Ptr >= Ptr && C.Ptr <= End);
52 operator bool()
const {
return Ptr !=
nullptr; }
59 while (isspace(C.peek()))
65 return isalpha(C) || isdigit(C) || C ==
'_' || C ==
'-' || C ==
'.';
80 if (!isalpha(C.peek()) && C.peek() !=
'_')
85 auto Identifier = Range.upto(C);
93 if (!C.remaining().startswith(
"%bb."))
97 if (!isdigit(C.peek())) {
99 ErrorCallback(C.location(),
"expected a number after '%bb.'");
102 auto NumberRange = C;
103 while (isdigit(C.peek()))
106 unsigned StringOffset = 4 + Number.
size();
107 if (C.peek() ==
'.') {
121 auto NumberRange = C;
122 while (isdigit(C.peek()))
125 APSInt(NumberRange.upto(C)));
132 if (isdigit(C.peek(1)))
149 if (!isdigit(C.peek())) {
156 auto NumberRange = C;
157 while (isdigit(C.peek()))
165 if (!isdigit(C.peek()) && (C.peek() !=
'-' || !isdigit(C.peek(1))))
169 while (isdigit(C.peek()))
205 return C.remaining();
209 return R.remaining();
211 return R.remaining();
213 return R.remaining();
215 return R.remaining();
217 return R.remaining();
219 return R.remaining();
222 ErrorCallback(C.location(),
223 Twine(
"unexpected character '") +
Twine(C.peek()) +
"'");
224 return C.remaining();
size_t size() const
size - Get the string size.
NoneType
A simple null object to allow implicit construction of Optional<T> and similar types without having to ...
An efficient, type-erasing, non-owning reference to a callable.
StringSwitch & Case(const char(&S)[N], const T &Value)
StringRef lexMIToken(StringRef Source, MIToken &Token, function_ref< void(StringRef::iterator, const Twine &)> ErrorCallback)
Consume a single machine instruction token in the given source and return the remaining source string...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static void advance(T &it, size_t Val)
static Cursor skipWhitespace(Cursor C)
Skip the leading whitespace characters and return the updated cursor.
static Cursor maybeLexIdentifier(Cursor C, MIToken &Token)
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
static Cursor maybeLexGlobalValue(Cursor C, MIToken &Token)
A switch()-like statement whose cases are string literals.
static Cursor lexVirtualRegister(Cursor C, MIToken &Token)
static MIToken::TokenKind symbolToken(char C)
static Cursor maybeLexSymbol(Cursor C, MIToken &Token)
R Default(const T &Value) const
static Cursor maybeLexRegister(Cursor C, MIToken &Token)
static Cursor maybeLexMachineBasicBlock(Cursor C, MIToken &Token, function_ref< void(StringRef::iterator Loc, const Twine &)> ErrorCallback)
static Cursor maybeLexIntegerLiteral(Cursor C, MIToken &Token)
const ARM::ArchExtKind Kind
A token produced by the machine instruction lexer.
StringRef - Represent a constant reference to a string, i.e.
static MIToken::TokenKind getIdentifierKind(StringRef Identifier)
static bool isIdentifierChar(char C)
LocationClass< Ty > location(Ty &L)