LLVM 20.0.0git
|
Generic assembler lexer interface, for use by target specific assembly lexers. More...
#include "llvm/MC/MCParser/MCAsmLexer.h"
Public Member Functions | |
MCAsmLexer (const MCAsmLexer &)=delete | |
MCAsmLexer & | operator= (const MCAsmLexer &)=delete |
virtual | ~MCAsmLexer () |
const AsmToken & | Lex () |
Consume the next token from the input stream and return it. | |
void | UnLex (AsmToken const &Token) |
bool | isAtStartOfStatement () |
virtual StringRef | LexUntilEndOfStatement ()=0 |
SMLoc | getLoc () const |
Get the current source location. | |
const AsmToken & | getTok () const |
Get the current (last) lexed token. | |
const AsmToken | peekTok (bool ShouldSkipSpace=true) |
Look ahead at the next token to be lexed. | |
virtual size_t | peekTokens (MutableArrayRef< AsmToken > Buf, bool ShouldSkipSpace=true)=0 |
Look ahead an arbitrary number of tokens. | |
SMLoc | getErrLoc () |
Get the current error location. | |
const std::string & | getErr () |
Get the current error string. | |
AsmToken::TokenKind | getKind () const |
Get the kind of current token. | |
bool | is (AsmToken::TokenKind K) const |
Check if the current token has kind K . | |
bool | isNot (AsmToken::TokenKind K) const |
Check if the current token has kind K . | |
void | setSkipSpace (bool val) |
Set whether spaces should be ignored by the lexer. | |
bool | getAllowAtInIdentifier () |
void | setAllowAtInIdentifier (bool v) |
void | setAllowHashInIdentifier (bool V) |
void | setCommentConsumer (AsmCommentConsumer *CommentConsumer) |
void | setLexMasmIntegers (bool V) |
Set whether to lex masm-style binary (e.g., 0b1101) and radix-specified literals (e.g., 0ABCh [hex], 576t [decimal], 77o [octal], 1101y [binary]). | |
void | useMasmDefaultRadix (bool V) |
Set whether to use masm-style default-radix integer literals. | |
unsigned | getMasmDefaultRadix () const |
void | setMasmDefaultRadix (unsigned Radix) |
void | setLexMasmHexFloats (bool V) |
Set whether to lex masm-style hex float literals, such as 3f800000r. | |
void | setLexMasmStrings (bool V) |
Set whether to lex masm-style string literals, such as 'Can''t find file' and "This ""value"" not found". | |
void | setLexMotorolaIntegers (bool V) |
Set whether to lex Motorola-style integer literals, such as $deadbeef or %01010110. | |
void | setLexHLASMIntegers (bool V) |
Set whether to lex HLASM-flavour integers. For now this is only [0-9]*. | |
void | setLexHLASMStrings (bool V) |
Set whether to "lex" HLASM-flavour character and string literals. | |
Protected Member Functions | |
MCAsmLexer () | |
virtual AsmToken | LexToken ()=0 |
void | SetError (SMLoc errLoc, const std::string &err) |
Protected Attributes | |
const char * | TokStart = nullptr |
bool | SkipSpace = true |
bool | AllowAtInIdentifier = false |
bool | AllowHashInIdentifier = false |
bool | IsAtStartOfStatement = true |
bool | LexMasmHexFloats = false |
bool | LexMasmIntegers = false |
bool | LexMasmStrings = false |
bool | LexMotorolaIntegers = false |
bool | UseMasmDefaultRadix = false |
unsigned | DefaultRadix = 10 |
bool | LexHLASMIntegers = false |
bool | LexHLASMStrings = false |
AsmCommentConsumer * | CommentConsumer = nullptr |
Generic assembler lexer interface, for use by target specific assembly lexers.
Definition at line 37 of file MCAsmLexer.h.
|
protected |
Definition at line 16 of file MCAsmLexer.cpp.
References llvm::AsmToken::Space.
|
delete |
|
virtualdefault |
|
inline |
Definition at line 149 of file MCAsmLexer.h.
References AllowAtInIdentifier.
|
inline |
Get the current error string.
Definition at line 133 of file MCAsmLexer.h.
Referenced by llvm::AsmLexer::peekTokens().
|
inline |
Get the current error location.
Definition at line 128 of file MCAsmLexer.h.
Referenced by llvm::AsmLexer::peekTokens().
|
inline |
Get the kind of current token.
Definition at line 138 of file MCAsmLexer.h.
References llvm::AsmToken::getKind(), and getTok().
SMLoc MCAsmLexer::getLoc | ( | ) | const |
Get the current source location.
Definition at line 22 of file MCAsmLexer.cpp.
References llvm::SMLoc::getFromPointer(), and TokStart.
Referenced by llvm::MCAsmParserExtension::ParseDirectiveCGProfile().
|
inline |
Definition at line 166 of file MCAsmLexer.h.
References DefaultRadix.
Get the current (last) lexed token.
Definition at line 106 of file MCAsmLexer.h.
Referenced by getKind(), llvm::MCAsmParser::getTok(), is(), and isNot().
|
inline |
Check if the current token has kind K
.
Definition at line 141 of file MCAsmLexer.h.
References getTok(), and llvm::AsmToken::is().
Referenced by llvm::AsmLexer::LexToken().
|
inline |
Definition at line 98 of file MCAsmLexer.h.
References IsAtStartOfStatement.
|
inline |
Check if the current token has kind K
.
Definition at line 144 of file MCAsmLexer.h.
References getTok(), and llvm::AsmToken::isNot().
Referenced by expectAbsExpression(), and parseExpr().
Consume the next token from the input stream and return it.
The lexer will continuously return the end-of-file token once the end of the main input file has been reached.
Definition at line 79 of file MCAsmLexer.h.
References assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::SmallVectorBase< Size_T >::empty(), llvm::AsmToken::EndOfStatement, llvm::SmallVectorImpl< T >::erase(), llvm::SmallVectorTemplateCommon< T, typename >::front(), llvm::SmallVectorImpl< T >::insert(), IsAtStartOfStatement, and LexToken().
Referenced by llvm::MCAsmParser::Error(), expectAbsExpression(), and parseExpr().
|
protectedpure virtual |
Implemented in llvm::AsmLexer.
Referenced by Lex().
|
pure virtual |
Implemented in llvm::AsmLexer.
|
delete |
Look ahead at the next token to be lexed.
Definition at line 111 of file MCAsmLexer.h.
References assert(), and peekTokens().
|
pure virtual |
|
inline |
Definition at line 150 of file MCAsmLexer.h.
References AllowAtInIdentifier.
|
inline |
Definition at line 152 of file MCAsmLexer.h.
References AllowHashInIdentifier.
|
inline |
Definition at line 154 of file MCAsmLexer.h.
References CommentConsumer.
Definition at line 65 of file MCAsmLexer.h.
Referenced by llvm::AsmLexer::peekTokens().
|
inline |
Set whether to lex HLASM-flavour integers. For now this is only [0-9]*.
Definition at line 181 of file MCAsmLexer.h.
References LexHLASMIntegers.
|
inline |
Set whether to "lex" HLASM-flavour character and string literals.
For now, setting this option to true, will disable lexing for character and string literals.
Definition at line 186 of file MCAsmLexer.h.
References LexHLASMStrings.
|
inline |
Set whether to lex masm-style hex float literals, such as 3f800000r.
Definition at line 170 of file MCAsmLexer.h.
References LexMasmHexFloats.
|
inline |
Set whether to lex masm-style binary (e.g., 0b1101) and radix-specified literals (e.g., 0ABCh [hex], 576t [decimal], 77o [octal], 1101y [binary]).
Definition at line 160 of file MCAsmLexer.h.
References LexMasmIntegers.
|
inline |
Set whether to lex masm-style string literals, such as 'Can''t find file' and "This ""value"" not found".
Definition at line 174 of file MCAsmLexer.h.
References LexMasmStrings.
|
inline |
Set whether to lex Motorola-style integer literals, such as $deadbeef or %01010110.
Definition at line 178 of file MCAsmLexer.h.
References LexMotorolaIntegers.
|
inline |
Definition at line 167 of file MCAsmLexer.h.
References DefaultRadix.
|
inline |
Set whether spaces should be ignored by the lexer.
Definition at line 147 of file MCAsmLexer.h.
References SkipSpace.
Definition at line 93 of file MCAsmLexer.h.
References llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::SmallVectorImpl< T >::insert(), and IsAtStartOfStatement.
Referenced by llvm::AsmLexer::LexToken().
|
inline |
Set whether to use masm-style default-radix integer literals.
If disabled, assume decimal unless prefixed (e.g., 0x2c [hex], 077 [octal]).
Definition at line 164 of file MCAsmLexer.h.
References UseMasmDefaultRadix.
|
protected |
Definition at line 48 of file MCAsmLexer.h.
Referenced by llvm::AsmLexer::AsmLexer(), getAllowAtInIdentifier(), and setAllowAtInIdentifier().
|
protected |
Definition at line 49 of file MCAsmLexer.h.
Referenced by setAllowHashInIdentifier().
|
protected |
Definition at line 59 of file MCAsmLexer.h.
Referenced by setCommentConsumer().
|
protected |
Definition at line 56 of file MCAsmLexer.h.
Referenced by getMasmDefaultRadix(), and setMasmDefaultRadix().
Definition at line 50 of file MCAsmLexer.h.
Referenced by isAtStartOfStatement(), Lex(), and UnLex().
|
protected |
Definition at line 57 of file MCAsmLexer.h.
Referenced by setLexHLASMIntegers().
|
protected |
Definition at line 58 of file MCAsmLexer.h.
Referenced by setLexHLASMStrings().
|
protected |
Definition at line 51 of file MCAsmLexer.h.
Referenced by setLexMasmHexFloats().
|
protected |
Definition at line 52 of file MCAsmLexer.h.
Referenced by setLexMasmIntegers().
|
protected |
Definition at line 53 of file MCAsmLexer.h.
Referenced by setLexMasmStrings().
|
protected |
Definition at line 54 of file MCAsmLexer.h.
Referenced by llvm::AsmLexer::AsmLexer(), llvm::AsmLexer::LexToken(), and setLexMotorolaIntegers().
Definition at line 47 of file MCAsmLexer.h.
Referenced by llvm::AsmLexer::LexToken(), llvm::AsmLexer::peekTokens(), and setSkipSpace().
Definition at line 46 of file MCAsmLexer.h.
Referenced by getLoc(), llvm::AsmLexer::LexToken(), llvm::AsmLexer::LexUntilEndOfStatement(), llvm::AsmLexer::peekTokens(), and llvm::AsmLexer::setBuffer().
|
protected |
Definition at line 55 of file MCAsmLexer.h.
Referenced by useMasmDefaultRadix().