LLVM 20.0.0git
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::MCAsmLexer Class Referenceabstract

Generic assembler lexer interface, for use by target specific assembly lexers. More...

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

Inheritance diagram for llvm::MCAsmLexer:
Inheritance graph
[legend]

Public Member Functions

 MCAsmLexer (const MCAsmLexer &)=delete
 
MCAsmLexeroperator= (const MCAsmLexer &)=delete
 
virtual ~MCAsmLexer ()
 
const AsmTokenLex ()
 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 AsmTokengetTok () 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 charTokStart = 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
 
AsmCommentConsumerCommentConsumer = nullptr
 

Detailed Description

Generic assembler lexer interface, for use by target specific assembly lexers.

Definition at line 37 of file MCAsmLexer.h.

Constructor & Destructor Documentation

◆ MCAsmLexer() [1/2]

MCAsmLexer::MCAsmLexer ( )
protected

Definition at line 16 of file MCAsmLexer.cpp.

References llvm::AsmToken::Space.

◆ MCAsmLexer() [2/2]

llvm::MCAsmLexer::MCAsmLexer ( const MCAsmLexer )
delete

◆ ~MCAsmLexer()

MCAsmLexer::~MCAsmLexer ( )
virtualdefault

Member Function Documentation

◆ getAllowAtInIdentifier()

bool llvm::MCAsmLexer::getAllowAtInIdentifier ( )
inline

Definition at line 149 of file MCAsmLexer.h.

References AllowAtInIdentifier.

◆ getErr()

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

Get the current error string.

Definition at line 133 of file MCAsmLexer.h.

Referenced by llvm::AsmLexer::peekTokens().

◆ getErrLoc()

SMLoc llvm::MCAsmLexer::getErrLoc ( )
inline

Get the current error location.

Definition at line 128 of file MCAsmLexer.h.

Referenced by llvm::AsmLexer::peekTokens().

◆ getKind()

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

Get the kind of current token.

Definition at line 138 of file MCAsmLexer.h.

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

◆ getLoc()

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().

◆ getMasmDefaultRadix()

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

Definition at line 166 of file MCAsmLexer.h.

References DefaultRadix.

◆ getTok()

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

Get the current (last) lexed token.

Definition at line 106 of file MCAsmLexer.h.

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

◆ is()

bool llvm::MCAsmLexer::is ( AsmToken::TokenKind  K) const
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().

◆ isAtStartOfStatement()

bool llvm::MCAsmLexer::isAtStartOfStatement ( )
inline

Definition at line 98 of file MCAsmLexer.h.

References IsAtStartOfStatement.

◆ isNot()

bool llvm::MCAsmLexer::isNot ( AsmToken::TokenKind  K) const
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().

◆ Lex()

const AsmToken & llvm::MCAsmLexer::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 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().

◆ LexToken()

virtual AsmToken llvm::MCAsmLexer::LexToken ( )
protectedpure virtual

Implemented in llvm::AsmLexer.

Referenced by Lex().

◆ LexUntilEndOfStatement()

virtual StringRef llvm::MCAsmLexer::LexUntilEndOfStatement ( )
pure virtual

Implemented in llvm::AsmLexer.

◆ operator=()

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

◆ peekTok()

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

Look ahead at the next token to be lexed.

Definition at line 111 of file MCAsmLexer.h.

References assert(), and peekTokens().

◆ peekTokens()

virtual size_t llvm::MCAsmLexer::peekTokens ( MutableArrayRef< AsmToken Buf,
bool  ShouldSkipSpace = true 
)
pure virtual

Look ahead an arbitrary number of tokens.

Implemented in llvm::AsmLexer.

Referenced by peekTok().

◆ setAllowAtInIdentifier()

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

Definition at line 150 of file MCAsmLexer.h.

References AllowAtInIdentifier.

◆ setAllowHashInIdentifier()

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

Definition at line 152 of file MCAsmLexer.h.

References AllowHashInIdentifier.

◆ setCommentConsumer()

void llvm::MCAsmLexer::setCommentConsumer ( AsmCommentConsumer CommentConsumer)
inline

Definition at line 154 of file MCAsmLexer.h.

References CommentConsumer.

◆ SetError()

void llvm::MCAsmLexer::SetError ( SMLoc  errLoc,
const std::string &  err 
)
inlineprotected

Definition at line 65 of file MCAsmLexer.h.

Referenced by llvm::AsmLexer::peekTokens().

◆ setLexHLASMIntegers()

void llvm::MCAsmLexer::setLexHLASMIntegers ( bool  V)
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.

◆ setLexHLASMStrings()

void llvm::MCAsmLexer::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 186 of file MCAsmLexer.h.

References LexHLASMStrings.

◆ setLexMasmHexFloats()

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

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

Definition at line 170 of file MCAsmLexer.h.

References LexMasmHexFloats.

◆ setLexMasmIntegers()

void llvm::MCAsmLexer::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 160 of file MCAsmLexer.h.

References LexMasmIntegers.

◆ setLexMasmStrings()

void llvm::MCAsmLexer::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 174 of file MCAsmLexer.h.

References LexMasmStrings.

◆ setLexMotorolaIntegers()

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

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

Definition at line 178 of file MCAsmLexer.h.

References LexMotorolaIntegers.

◆ setMasmDefaultRadix()

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

Definition at line 167 of file MCAsmLexer.h.

References DefaultRadix.

◆ setSkipSpace()

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

Set whether spaces should be ignored by the lexer.

Definition at line 147 of file MCAsmLexer.h.

References SkipSpace.

◆ UnLex()

void llvm::MCAsmLexer::UnLex ( AsmToken const Token)
inline

◆ useMasmDefaultRadix()

void llvm::MCAsmLexer::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 164 of file MCAsmLexer.h.

References UseMasmDefaultRadix.

Member Data Documentation

◆ AllowAtInIdentifier

bool llvm::MCAsmLexer::AllowAtInIdentifier = false
protected

◆ AllowHashInIdentifier

bool llvm::MCAsmLexer::AllowHashInIdentifier = false
protected

Definition at line 49 of file MCAsmLexer.h.

Referenced by setAllowHashInIdentifier().

◆ CommentConsumer

AsmCommentConsumer* llvm::MCAsmLexer::CommentConsumer = nullptr
protected

Definition at line 59 of file MCAsmLexer.h.

Referenced by setCommentConsumer().

◆ DefaultRadix

unsigned llvm::MCAsmLexer::DefaultRadix = 10
protected

Definition at line 56 of file MCAsmLexer.h.

Referenced by getMasmDefaultRadix(), and setMasmDefaultRadix().

◆ IsAtStartOfStatement

bool llvm::MCAsmLexer::IsAtStartOfStatement = true
protected

Definition at line 50 of file MCAsmLexer.h.

Referenced by isAtStartOfStatement(), Lex(), and UnLex().

◆ LexHLASMIntegers

bool llvm::MCAsmLexer::LexHLASMIntegers = false
protected

Definition at line 57 of file MCAsmLexer.h.

Referenced by setLexHLASMIntegers().

◆ LexHLASMStrings

bool llvm::MCAsmLexer::LexHLASMStrings = false
protected

Definition at line 58 of file MCAsmLexer.h.

Referenced by setLexHLASMStrings().

◆ LexMasmHexFloats

bool llvm::MCAsmLexer::LexMasmHexFloats = false
protected

Definition at line 51 of file MCAsmLexer.h.

Referenced by setLexMasmHexFloats().

◆ LexMasmIntegers

bool llvm::MCAsmLexer::LexMasmIntegers = false
protected

Definition at line 52 of file MCAsmLexer.h.

Referenced by setLexMasmIntegers().

◆ LexMasmStrings

bool llvm::MCAsmLexer::LexMasmStrings = false
protected

Definition at line 53 of file MCAsmLexer.h.

Referenced by setLexMasmStrings().

◆ LexMotorolaIntegers

bool llvm::MCAsmLexer::LexMotorolaIntegers = false
protected

◆ SkipSpace

bool llvm::MCAsmLexer::SkipSpace = true
protected

Definition at line 47 of file MCAsmLexer.h.

Referenced by llvm::AsmLexer::LexToken(), llvm::AsmLexer::peekTokens(), and setSkipSpace().

◆ TokStart

const char* llvm::MCAsmLexer::TokStart = nullptr
protected

◆ UseMasmDefaultRadix

bool llvm::MCAsmLexer::UseMasmDefaultRadix = false
protected

Definition at line 55 of file MCAsmLexer.h.

Referenced by useMasmDefaultRadix().


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