13#ifndef LLVM_MC_MCPARSER_ASMLEXER_H
14#define LLVM_MC_MCPARSER_ASMLEXER_H
47 const char *CurPtr =
nullptr;
57 bool IsAtStartOfLine =
true;
58 bool JustConsumedEOL =
true;
59 bool IsPeeking =
false;
60 bool EndStatementAtEOF =
true;
62 const char *TokStart =
nullptr;
63 bool SkipSpace =
true;
64 bool AllowAtInIdentifier =
false;
65 bool AllowHashInIdentifier =
false;
66 bool IsAtStartOfStatement =
true;
67 bool LexMasmHexFloats =
false;
68 bool LexMasmIntegers =
false;
69 bool LexMasmStrings =
false;
70 bool LexMotorolaIntegers =
false;
71 bool UseMasmDefaultRadix =
false;
72 unsigned DefaultRadix = 10;
73 bool LexHLASMIntegers =
false;
74 bool LexHLASMStrings =
false;
79 void SetError(
SMLoc errLoc,
const std::string &err) {
97 CurTok.erase(CurTok.begin());
100 if (CurTok.empty()) {
102 CurTok.insert(CurTok.begin(),
T);
104 return CurTok.front();
108 CurTok.insert(CurTok.begin(), Token);
126 size_t ReadCount =
peekTokens(Buf, ShouldSkipSpace);
136 bool ShouldSkipSpace =
true);
142 const std::string &
getErr() {
return Err; }
162 this->CommentConsumer = CommentConsumer;
202 bool EndStatementAtEOF =
true);
207 return isAlnum(
C) ||
C ==
'_' ||
C ==
'$' ||
C ==
'.' ||
C ==
'?' ||
208 (AllowAt &&
C ==
'@') || (AllowHash &&
C ==
'#');
212 bool isAtStartOfComment(
const char *Ptr);
213 bool isAtStatementSeparator(
const char *Ptr);
214 [[nodiscard]]
int getNextChar();
225 AsmToken LexHexFloatLiteral(
bool NoIntDigits);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file defines the SmallVector class.
void setLexHLASMStrings(bool V)
Set whether to "lex" HLASM-flavour character and string literals.
static bool isIdentifierChar(char C, bool AllowAt, bool AllowHash)
void setLexMasmIntegers(bool V)
Set whether to lex masm-style binary (e.g., 0b1101) and radix-specified literals (e....
SMLoc getLoc() const
Get the current source location.
void setLexMasmStrings(bool V)
Set whether to lex masm-style string literals, such as 'Can''t find file' and "This ""value"" not fou...
LLVM_ABI AsmLexer(const MCAsmInfo &MAI)
const AsmToken peekTok(bool ShouldSkipSpace=true)
Look ahead at the next token to be lexed.
bool getAllowAtInIdentifier()
void UnLex(AsmToken const &Token)
void setMasmDefaultRadix(unsigned Radix)
AsmToken::TokenKind getKind() const
Get the kind of current token.
void setLexMasmHexFloats(bool V)
Set whether to lex masm-style hex float literals, such as 3f800000r.
const MCAsmInfo & getMAI() const
const AsmToken & getTok() const
Get the current (last) lexed token.
bool is(AsmToken::TokenKind K) const
Check if the current token has kind K.
void setLexMotorolaIntegers(bool V)
Set whether to lex Motorola-style integer literals, such as $deadbeef or %01010110.
SMLoc getErrLoc()
Get the current error location.
AsmLexer(const AsmLexer &)=delete
const std::string & getErr()
Get the current error string.
const AsmToken & Lex()
Consume the next token from the input stream and return it.
void setSkipSpace(bool val)
Set whether spaces should be ignored by the lexer.
void setAllowAtInIdentifier(bool v)
LLVM_ABI StringRef LexUntilEndOfStatement()
AsmLexer & operator=(const AsmLexer &)=delete
LLVM_ABI void setBuffer(StringRef Buf, const char *ptr=nullptr, bool EndStatementAtEOF=true)
Set buffer to be lexed.
unsigned getMasmDefaultRadix() const
void useMasmDefaultRadix(bool V)
Set whether to use masm-style default-radix integer literals.
void setLexHLASMIntegers(bool V)
Set whether to lex HLASM-flavour integers. For now this is only [0-9]*.
bool isNot(AsmToken::TokenKind K) const
Check if the current token has kind K.
LLVM_ABI size_t peekTokens(MutableArrayRef< AsmToken > Buf, bool ShouldSkipSpace=true)
Look ahead an arbitrary number of tokens.
void setCommentConsumer(AsmCommentConsumer *CommentConsumer)
void setAllowHashInIdentifier(bool V)
Target independent representation for an assembler token.
bool isNot(TokenKind K) const
bool is(TokenKind K) const
TokenKind getKind() const
This class is intended to be used as a base class for asm properties and features specific to the tar...
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
Represents a location in source code.
static SMLoc getFromPointer(const char *Ptr)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
This is an optimization pass for GlobalISel generic memory operations.
bool isAlnum(char C)
Checks whether character C is either a decimal digit or an uppercase or lowercase letter as classifie...