My Project
Public Types | Public Member Functions | Static Public Member Functions | List of all members
mlir::Token Class Reference

This represents a token in the MLIR syntax. More...

#include <Token.h>

Public Types

enum  Kind { TOK_IDENTIFIER, TOK_IDENTIFIER, TOK_IDENTIFIER }
 

Public Member Functions

 Token (Kind kind, StringRef spelling)
 
StringRef getSpelling () const
 
Kind getKind () const
 
bool is (Kind K) const
 
bool isAny (Kind k1, Kind k2) const
 
template<typename... T>
bool isAny (Kind k1, Kind k2, Kind k3, T... others) const
 Return true if this token is one of the specified kinds. More...
 
bool isNot (Kind k) const
 
template<typename... T>
bool isNot (Kind k1, Kind k2, T... others) const
 Return true if this token isn't one of the specified kinds. More...
 
bool isKeyword () const
 Return true if this is one of the keyword token kinds (e.g. kw_if). More...
 
Optional< unsigned > getUnsignedIntegerValue () const
 
Optional< uint64_t > getUInt64IntegerValue () const
 
Optional< double > getFloatingPointValue () const
 
Optional< unsigned > getIntTypeBitwidth () const
 For an inttype token, return its bitwidth. More...
 
Optional< unsigned > getHashIdentifierNumber () const
 
std::string getStringValue () const
 
llvm::SMLoc getLoc () const
 
llvm::SMLoc getEndLoc () const
 
llvm::SMRange getLocRange () const
 

Static Public Member Functions

static StringRef getTokenSpelling (Kind kind)
 

Detailed Description

This represents a token in the MLIR syntax.

Member Enumeration Documentation

◆ Kind

Enumerator
TOK_IDENTIFIER 
TOK_IDENTIFIER 
TOK_IDENTIFIER 

Constructor & Destructor Documentation

◆ Token()

mlir::Token::Token ( Kind  kind,
StringRef  spelling 
)
inline

Member Function Documentation

◆ getEndLoc()

SMLoc Token::getEndLoc ( ) const

◆ getFloatingPointValue()

Optional< double > Token::getFloatingPointValue ( ) const

For a floatliteral token, return its value as a double. Returns None in the case of underflow or overflow.

For a floatliteral, return its value as a double. Return None if the value underflows or overflows.

◆ getHashIdentifierNumber()

Optional< unsigned > Token::getHashIdentifierNumber ( ) const

Given a hash_identifier token like #123, try to parse the number out of the identifier, returning None if it is a named identifier like #x or if the integer doesn't fit.

◆ getIntTypeBitwidth()

Optional< unsigned > Token::getIntTypeBitwidth ( ) const

For an inttype token, return its bitwidth.

◆ getKind()

Kind mlir::Token::getKind ( ) const
inline

◆ getLoc()

SMLoc Token::getLoc ( ) const

◆ getLocRange()

SMRange Token::getLocRange ( ) const

◆ getSpelling()

StringRef mlir::Token::getSpelling ( ) const
inline

◆ getStringValue()

std::string Token::getStringValue ( ) const

Given a token containing a string literal, return its value, including removing the quote characters and unescaping the contents of the string.

Given a token containing a string literal, return its value, including removing the quote characters and unescaping the contents of the string. The lexer has already verified that this token is valid.

◆ getTokenSpelling()

StringRef Token::getTokenSpelling ( Kind  kind)
static

Given a punctuation or keyword token kind, return the spelling of the token as a string. Warning: This will abort on markers, identifiers and literal tokens since they have no fixed spelling.

◆ getUInt64IntegerValue()

Optional< uint64_t > Token::getUInt64IntegerValue ( ) const

For an integer token, return its value as an uint64_t. If it doesn't fit, return None.

For an integer token, return its value as a uint64_t. If it doesn't fit, return None.

◆ getUnsignedIntegerValue()

Optional< unsigned > Token::getUnsignedIntegerValue ( ) const

For an integer token, return its value as an unsigned. If it doesn't fit, return None.

◆ is()

bool mlir::Token::is ( Kind  K) const
inline

◆ isAny() [1/2]

bool mlir::Token::isAny ( Kind  k1,
Kind  k2 
) const
inline

◆ isAny() [2/2]

template<typename... T>
bool mlir::Token::isAny ( Kind  k1,
Kind  k2,
Kind  k3,
T...  others 
) const
inline

Return true if this token is one of the specified kinds.

◆ isKeyword()

bool Token::isKeyword ( ) const

Return true if this is one of the keyword token kinds (e.g. kw_if).

◆ isNot() [1/2]

bool mlir::Token::isNot ( Kind  k) const
inline

◆ isNot() [2/2]

template<typename... T>
bool mlir::Token::isNot ( Kind  k1,
Kind  k2,
T...  others 
) const
inline

Return true if this token isn't one of the specified kinds.


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