LLVM 22.0.0git
llvm::AsmLexer Class Reference

#include "llvm/MC/MCParser/AsmLexer.h"

Public Member Functions

LLVM_ABI AsmLexer (const MCAsmInfo &MAI)
 AsmLexer (const AsmLexer &)=delete
AsmLexeroperator= (const AsmLexer &)=delete
const AsmTokenLex ()
 Consume the next token from the input stream and return it.
void UnLex (AsmToken const &Token)
bool justConsumedEOL ()
LLVM_ABI StringRef LexUntilEndOfStatement ()
SMLoc getLoc () const
 Get the current source location.
const AsmTokengetTok () const
 Get the current (last) lexed token.
const AsmToken peekTok (bool ShouldSkipSpace=true)
 Look ahead at the next token to be lexed.
LLVM_ABI size_t peekTokens (MutableArrayRef< AsmToken > Buf, bool ShouldSkipSpace=true)
 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.
LLVM_ABI void setBuffer (StringRef Buf, const char *ptr=nullptr, bool EndStatementAtEOF=true)
const MCAsmInfogetMAI () const

Detailed Description

Definition at line 43 of file AsmLexer.h.

Constructor & Destructor Documentation

◆ AsmLexer() [1/2]

AsmLexer::AsmLexer ( const MCAsmInfo & MAI)

Definition at line 111 of file AsmLexer.cpp.

References llvm::AsmToken::Space, and llvm::StringRef::starts_with().

Referenced by AsmLexer(), and operator=().

◆ AsmLexer() [2/2]

llvm::AsmLexer::AsmLexer ( const AsmLexer & )
delete

References AsmLexer().

Member Function Documentation

◆ getAllowAtInIdentifier()

bool llvm::AsmLexer::getAllowAtInIdentifier ( )
inline

Definition at line 155 of file AsmLexer.h.

◆ getErr()

const std::string & llvm::AsmLexer::getErr ( )
inline

Get the current error string.

Definition at line 141 of file AsmLexer.h.

Referenced by peekTokens().

◆ getErrLoc()

SMLoc llvm::AsmLexer::getErrLoc ( )
inline

Get the current error location.

Definition at line 138 of file AsmLexer.h.

Referenced by peekTokens().

◆ getKind()

AsmToken::TokenKind llvm::AsmLexer::getKind ( ) const
inline

Get the kind of current token.

Definition at line 144 of file AsmLexer.h.

References llvm::AsmToken::getKind(), and getTok().

◆ getLoc()

SMLoc llvm::AsmLexer::getLoc ( ) const
inline

Get the current source location.

Definition at line 115 of file AsmLexer.h.

References llvm::SMLoc::getFromPointer().

Referenced by llvm::MCAsmParserExtension::parseDirectiveCGProfile().

◆ getMAI()

const MCAsmInfo & llvm::AsmLexer::getMAI ( ) const
inline

Definition at line 197 of file AsmLexer.h.

◆ getMasmDefaultRadix()

unsigned llvm::AsmLexer::getMasmDefaultRadix ( ) const
inline

Definition at line 172 of file AsmLexer.h.

◆ getTok()

const AsmToken & llvm::AsmLexer::getTok ( ) const
inline

Get the current (last) lexed token.

Definition at line 118 of file AsmLexer.h.

Referenced by getKind(), llvm::MCAsmParser::getTok(), is(), and isNot().

◆ is()

bool llvm::AsmLexer::is ( AsmToken::TokenKind K) const
inline

Check if the current token has kind K.

Definition at line 147 of file AsmLexer.h.

References getTok(), and llvm::AsmToken::is().

◆ isNot()

bool llvm::AsmLexer::isNot ( AsmToken::TokenKind K) const
inline

Check if the current token has kind K.

Definition at line 150 of file AsmLexer.h.

References getTok(), and llvm::AsmToken::isNot().

Referenced by expectAbsExpression(), and parseExpr().

◆ justConsumedEOL()

bool llvm::AsmLexer::justConsumedEOL ( )
inline

Definition at line 110 of file AsmLexer.h.

◆ Lex()

const AsmToken & llvm::AsmLexer::Lex ( )
inline

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 92 of file AsmLexer.h.

References assert(), llvm::AsmToken::EndOfStatement, and T.

Referenced by llvm::MCAsmParser::Error(), expectAbsExpression(), and parseExpr().

◆ LexUntilEndOfStatement()

StringRef AsmLexer::LexUntilEndOfStatement ( )

Definition at line 744 of file AsmLexer.cpp.

◆ operator=()

AsmLexer & llvm::AsmLexer::operator= ( const AsmLexer & )
delete

References AsmLexer().

◆ peekTok()

const AsmToken llvm::AsmLexer::peekTok ( bool ShouldSkipSpace = true)
inline

Look ahead at the next token to be lexed.

Definition at line 121 of file AsmLexer.h.

References assert(), and peekTokens().

◆ peekTokens()

size_t AsmLexer::peekTokens ( MutableArrayRef< AsmToken > Buf,
bool ShouldSkipSpace = true )

Look ahead an arbitrary number of tokens.

Definition at line 764 of file AsmLexer.cpp.

References llvm::AsmToken::Eof, getErr(), getErrLoc(), llvm::AsmToken::is(), and llvm::ArrayRef< T >::size().

Referenced by peekTok().

◆ setAllowAtInIdentifier()

void llvm::AsmLexer::setAllowAtInIdentifier ( bool v)
inline

Definition at line 156 of file AsmLexer.h.

◆ setAllowHashInIdentifier()

void llvm::AsmLexer::setAllowHashInIdentifier ( bool V)
inline

Definition at line 158 of file AsmLexer.h.

◆ setBuffer()

void AsmLexer::setBuffer ( StringRef Buf,
const char * ptr = nullptr,
bool EndStatementAtEOF = true )

Definition at line 121 of file AsmLexer.cpp.

◆ setCommentConsumer()

void llvm::AsmLexer::setCommentConsumer ( AsmCommentConsumer * CommentConsumer)
inline

Definition at line 160 of file AsmLexer.h.

◆ setLexHLASMIntegers()

void llvm::AsmLexer::setLexHLASMIntegers ( bool V)
inline

Set whether to lex HLASM-flavour integers. For now this is only [0-9]*.

Definition at line 187 of file AsmLexer.h.

◆ setLexHLASMStrings()

void llvm::AsmLexer::setLexHLASMStrings ( bool V)
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 192 of file AsmLexer.h.

◆ setLexMasmHexFloats()

void llvm::AsmLexer::setLexMasmHexFloats ( bool V)
inline

Set whether to lex masm-style hex float literals, such as 3f800000r.

Definition at line 176 of file AsmLexer.h.

◆ setLexMasmIntegers()

void llvm::AsmLexer::setLexMasmIntegers ( bool V)
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 166 of file AsmLexer.h.

◆ setLexMasmStrings()

void llvm::AsmLexer::setLexMasmStrings ( bool V)
inline

Set whether to lex masm-style string literals, such as 'Can''t find file' and "This ""value"" not found".

Definition at line 180 of file AsmLexer.h.

◆ setLexMotorolaIntegers()

void llvm::AsmLexer::setLexMotorolaIntegers ( bool V)
inline

Set whether to lex Motorola-style integer literals, such as $deadbeef or %01010110.

Definition at line 184 of file AsmLexer.h.

◆ setMasmDefaultRadix()

void llvm::AsmLexer::setMasmDefaultRadix ( unsigned Radix)
inline

Definition at line 173 of file AsmLexer.h.

◆ setSkipSpace()

void llvm::AsmLexer::setSkipSpace ( bool val)
inline

Set whether spaces should be ignored by the lexer.

Definition at line 153 of file AsmLexer.h.

◆ UnLex()

void llvm::AsmLexer::UnLex ( AsmToken const & Token)
inline

Definition at line 106 of file AsmLexer.h.

◆ useMasmDefaultRadix()

void llvm::AsmLexer::useMasmDefaultRadix ( bool V)
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 170 of file AsmLexer.h.


The documentation for this class was generated from the following files: