LLVM  14.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]
Collaboration diagram for llvm::MCAsmLexer:
Collaboration 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. More...
 
void UnLex (AsmToken const &Token)
 
bool isAtStartOfStatement ()
 
virtual StringRef LexUntilEndOfStatement ()=0
 
SMLoc getLoc () const
 Get the current source location. More...
 
const AsmTokengetTok () const
 Get the current (last) lexed token. More...
 
const AsmToken peekTok (bool ShouldSkipSpace=true)
 Look ahead at the next token to be lexed. More...
 
virtual size_t peekTokens (MutableArrayRef< AsmToken > Buf, bool ShouldSkipSpace=true)=0
 Look ahead an arbitrary number of tokens. More...
 
SMLoc getErrLoc ()
 Get the current error location. More...
 
const std::string & getErr ()
 Get the current error string. More...
 
AsmToken::TokenKind getKind () const
 Get the kind of current token. More...
 
bool is (AsmToken::TokenKind K) const
 Check if the current token has kind K. More...
 
bool isNot (AsmToken::TokenKind K) const
 Check if the current token has kind K. More...
 
void setSkipSpace (bool val)
 Set whether spaces should be ignored by the lexer. More...
 
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]). More...
 
void useMasmDefaultRadix (bool V)
 Set whether to use masm-style default-radix integer literals. More...
 
unsigned getMasmDefaultRadix () const
 
void setMasmDefaultRadix (unsigned Radix)
 
void setLexMasmHexFloats (bool V)
 Set whether to lex masm-style hex float literals, such as 3f800000r. More...
 
void setLexMasmStrings (bool V)
 Set whether to lex masm-style string literals, such as 'Can''t find file' and "This ""value"" not found". More...
 
void setLexMotorolaIntegers (bool V)
 Set whether to lex Motorola-style integer literals, such as $deadbeef or %01010110. More...
 
void setLexHLASMIntegers (bool V)
 Set whether to lex HLASM-flavour integers. For now this is only [0-9]*. More...
 
void setLexHLASMStrings (bool V)
 Set whether to "lex" HLASM-flavour character and string literals. More...
 

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
 
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 39 of file MCAsmLexer.h.

Constructor & Destructor Documentation

◆ MCAsmLexer() [1/2]

MCAsmLexer::MCAsmLexer ( )
protected

Definition at line 17 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 151 of file MCAsmLexer.h.

References AllowAtInIdentifier.

◆ getErr()

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

Get the current error string.

Definition at line 135 of file MCAsmLexer.h.

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

◆ getErrLoc()

SMLoc llvm::MCAsmLexer::getErrLoc ( )
inline

Get the current error location.

Definition at line 130 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 140 of file MCAsmLexer.h.

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

◆ getLoc()

SMLoc MCAsmLexer::getLoc ( ) const

Get the current source location.

Definition at line 23 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 168 of file MCAsmLexer.h.

References DefaultRadix.

◆ getTok()

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

Get the current (last) lexed token.

Definition at line 108 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 143 of file MCAsmLexer.h.

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

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

◆ isAtStartOfStatement()

bool llvm::MCAsmLexer::isAtStartOfStatement ( )
inline

Definition at line 100 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 146 of file MCAsmLexer.h.

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

◆ 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 81 of file MCAsmLexer.h.

References assert(), llvm::AsmToken::EndOfStatement, llvm::SmallVectorImpl< T >::erase(), llvm::SmallVectorImpl< T >::insert(), IsAtStartOfStatement, LexToken(), and T.

Referenced by llvm::MCAsmParser::Error().

◆ 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 113 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 152 of file MCAsmLexer.h.

References AllowAtInIdentifier.

◆ setAllowHashInIdentifier()

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

Definition at line 154 of file MCAsmLexer.h.

References AllowHashInIdentifier.

◆ setCommentConsumer()

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

Definition at line 156 of file MCAsmLexer.h.

References CommentConsumer.

◆ SetError()

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

Definition at line 67 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 183 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 188 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 172 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 162 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 176 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 180 of file MCAsmLexer.h.

References LexMotorolaIntegers.

◆ setMasmDefaultRadix()

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

Definition at line 169 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 149 of file MCAsmLexer.h.

References SkipSpace, and val.

◆ UnLex()

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

Definition at line 95 of file MCAsmLexer.h.

References llvm::SmallVectorImpl< T >::insert(), and IsAtStartOfStatement.

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

◆ 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 166 of file MCAsmLexer.h.

References UseMasmDefaultRadix.

Member Data Documentation

◆ AllowAtInIdentifier

bool llvm::MCAsmLexer::AllowAtInIdentifier
protected

◆ AllowHashInIdentifier

bool llvm::MCAsmLexer::AllowHashInIdentifier = false
protected

Definition at line 51 of file MCAsmLexer.h.

Referenced by setAllowHashInIdentifier().

◆ CommentConsumer

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

Definition at line 61 of file MCAsmLexer.h.

Referenced by setCommentConsumer().

◆ DefaultRadix

unsigned llvm::MCAsmLexer::DefaultRadix = 10
protected

Definition at line 58 of file MCAsmLexer.h.

Referenced by getMasmDefaultRadix(), and setMasmDefaultRadix().

◆ IsAtStartOfStatement

bool llvm::MCAsmLexer::IsAtStartOfStatement = true
protected

Definition at line 52 of file MCAsmLexer.h.

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

◆ LexHLASMIntegers

bool llvm::MCAsmLexer::LexHLASMIntegers = false
protected

Definition at line 59 of file MCAsmLexer.h.

Referenced by setLexHLASMIntegers().

◆ LexHLASMStrings

bool llvm::MCAsmLexer::LexHLASMStrings = false
protected

Definition at line 60 of file MCAsmLexer.h.

Referenced by setLexHLASMStrings().

◆ LexMasmHexFloats

bool llvm::MCAsmLexer::LexMasmHexFloats = false
protected

Definition at line 53 of file MCAsmLexer.h.

Referenced by setLexMasmHexFloats().

◆ LexMasmIntegers

bool llvm::MCAsmLexer::LexMasmIntegers = false
protected

Definition at line 54 of file MCAsmLexer.h.

Referenced by setLexMasmIntegers().

◆ LexMasmStrings

bool llvm::MCAsmLexer::LexMasmStrings = false
protected

Definition at line 55 of file MCAsmLexer.h.

Referenced by setLexMasmStrings().

◆ LexMotorolaIntegers

bool llvm::MCAsmLexer::LexMotorolaIntegers = false
protected

◆ SkipSpace

bool llvm::MCAsmLexer::SkipSpace = true
protected

Definition at line 49 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 57 of file MCAsmLexer.h.

Referenced by useMasmDefaultRadix().


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