CIRCT  19.0.0git
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
circt::firrtl::FIRToken Class Reference

This represents a specific token for .fir files. More...

#include <FIRLexer.h>

Collaboration diagram for circt::firrtl::FIRToken:
Collaboration graph
[legend]

Public Types

enum  Kind
 

Public Member Functions

 FIRToken (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_wire). More...
 
std::string getStringValue () const
 Given a token containing a string literal, return its value, including removing the quote characters and unescaping the contents of the string. More...
 
std::string getVerbatimStringValue () const
 Given a token containing a verbatim string, return its value, including removing the quote characters and unescaping the quotes of the string. More...
 
llvm::SMLoc getLoc () const
 
llvm::SMLoc getEndLoc () const
 
llvm::SMRange getLocRange () const
 

Static Public Member Functions

static std::string getStringValue (StringRef spelling)
 
static std::string getVerbatimStringValue (StringRef spelling)
 

Private Attributes

Kind kind
 Discriminator that indicates the sort of token this is. More...
 
StringRef spelling
 A reference to the entire token contents; this is always a pointer into a memory buffer owned by the source manager. More...
 

Detailed Description

This represents a specific token for .fir files.

Definition at line 29 of file FIRLexer.h.

Member Enumeration Documentation

◆ Kind

Definition at line 31 of file FIRLexer.h.

Constructor & Destructor Documentation

◆ FIRToken()

circt::firrtl::FIRToken::FIRToken ( Kind  kind,
StringRef  spelling 
)
inline

Definition at line 41 of file FIRLexer.h.

Member Function Documentation

◆ getEndLoc()

SMLoc FIRToken::getEndLoc ( ) const

Definition at line 37 of file FIRLexer.cpp.

References spelling.

Referenced by getLocRange().

◆ getKind()

Kind circt::firrtl::FIRToken::getKind ( ) const
inline

Definition at line 47 of file FIRLexer.h.

References kind.

Referenced by getStringValue(), and getVerbatimStringValue().

◆ getLoc()

SMLoc FIRToken::getLoc ( ) const

Definition at line 33 of file FIRLexer.cpp.

References spelling.

Referenced by getLocRange().

◆ getLocRange()

SMRange FIRToken::getLocRange ( ) const

Definition at line 41 of file FIRLexer.cpp.

References getEndLoc(), and getLoc().

◆ getSpelling()

StringRef circt::firrtl::FIRToken::getSpelling ( ) const
inline

Definition at line 44 of file FIRLexer.h.

References spelling.

Referenced by circt::firrtl::FIRLexer::getIndentation(), getStringValue(), and getVerbatimStringValue().

◆ getStringValue() [1/2]

std::string FIRToken::getStringValue ( ) const

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.

Definition at line 58 of file FIRLexer.cpp.

References assert(), getKind(), and getSpelling().

◆ getStringValue() [2/2]

std::string FIRToken::getStringValue ( StringRef  spelling)
static

Definition at line 63 of file FIRLexer.cpp.

References assert(), and spelling.

◆ getVerbatimStringValue() [1/2]

std::string FIRToken::getVerbatimStringValue ( ) const

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

The lexer has already verified that this token is valid.

Definition at line 117 of file FIRLexer.cpp.

References assert(), getKind(), and getSpelling().

◆ getVerbatimStringValue() [2/2]

std::string FIRToken::getVerbatimStringValue ( StringRef  spelling)
static

Definition at line 122 of file FIRLexer.cpp.

References assert(), and spelling.

◆ is()

bool circt::firrtl::FIRToken::is ( Kind  K) const
inline

Definition at line 48 of file FIRLexer.h.

References kind.

Referenced by isAny().

◆ isAny() [1/2]

bool circt::firrtl::FIRToken::isAny ( Kind  k1,
Kind  k2 
) const
inline

Definition at line 50 of file FIRLexer.h.

References is().

Referenced by isAny(), and isNot().

◆ isAny() [2/2]

template<typename... T>
bool circt::firrtl::FIRToken::isAny ( Kind  k1,
Kind  k2,
Kind  k3,
T...  others 
) const
inline

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

Definition at line 54 of file FIRLexer.h.

References is(), and isAny().

◆ isKeyword()

bool FIRToken::isKeyword ( ) const

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

Definition at line 44 of file FIRLexer.cpp.

References kind.

◆ isNot() [1/2]

bool circt::firrtl::FIRToken::isNot ( Kind  k) const
inline

Definition at line 60 of file FIRLexer.h.

References kind.

◆ isNot() [2/2]

template<typename... T>
bool circt::firrtl::FIRToken::isNot ( Kind  k1,
Kind  k2,
T...  others 
) const
inline

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

Definition at line 64 of file FIRLexer.h.

References isAny().

Member Data Documentation

◆ kind

Kind circt::firrtl::FIRToken::kind
private

Discriminator that indicates the sort of token this is.

Definition at line 90 of file FIRLexer.h.

Referenced by getKind(), is(), isKeyword(), and isNot().

◆ spelling

StringRef circt::firrtl::FIRToken::spelling
private

A reference to the entire token contents; this is always a pointer into a memory buffer owned by the source manager.

Definition at line 94 of file FIRLexer.h.

Referenced by getEndLoc(), getLoc(), getSpelling(), getStringValue(), and getVerbatimStringValue().


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