MLIR  20.0.0git
Public Types | Public Member Functions | List of all members
mlir::pdll::Token Class Reference

#include "Tools/PDLL/Parser/Lexer.h"

Public Types

enum  Kind {
  eof , error , code_complete , code_complete_string ,
  KW_BEGIN , KW_DEPENDENT_BEGIN , kw_attr , kw_op ,
  kw_type , KW_DEPENDENT_END , kw_Attr , kw_erase ,
  kw_let , kw_Constraint , kw_not , kw_Op ,
  kw_OpName , kw_Pattern , kw_replace , kw_return ,
  kw_rewrite , kw_Rewrite , kw_Type , kw_TypeRange ,
  kw_Value , kw_ValueRange , kw_with , KW_END ,
  arrow , colon , comma , dot ,
  equal , equal_arrow , semicolon , less ,
  greater , l_brace , r_brace , l_paren ,
  r_paren , l_square , r_square , underscore ,
  directive , identifier , integer , string_block ,
  string
}
 

Public Member Functions

 Token (Kind kind, StringRef spelling)
 
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...
 
bool isString () const
 Returns true if the current token is a string literal. More...
 
bool isKeyword () const
 Returns true if the current token is a keyword. More...
 
bool isDependentKeyword () const
 Returns true if the current token is a keyword in a dependent context, and in any other situation (e.g. More...
 
StringRef getSpelling () const
 Return the bytes that make up this token. More...
 
Kind getKind () const
 Return the kind of this token. More...
 
bool isAny (Kind k1, Kind k2) const
 Return true if this token is one of the specified kinds. More...
 
template<typename... T>
bool isAny (Kind k1, Kind k2, Kind k3, T... others) const
 
bool isNot (Kind k) const
 Return if the token does not have the given kind. More...
 
template<typename... T>
bool isNot (Kind k1, Kind k2, T... others) const
 
bool is (Kind k) const
 Return if the token has the given kind. More...
 
SMLoc getStartLoc () const
 Return a location for the start of this token. More...
 
SMLoc getEndLoc () const
 Return a location at the end of this token. More...
 
SMRange getLoc () const
 Return a location for the range of this token. More...
 

Detailed Description

Definition at line 32 of file Lexer.h.

Member Enumeration Documentation

◆ Kind

Enumerator
eof 

Markers.

error 
code_complete 

Token signifying a code completion location.

code_complete_string 

Token signifying a code completion location within a string.

KW_BEGIN 

Keywords.

KW_DEPENDENT_BEGIN 

Dependent keywords, i.e.

those that are treated as keywords depending on the current parser context.

kw_attr 
kw_op 
kw_type 
KW_DEPENDENT_END 
kw_Attr 

General keywords.

kw_erase 
kw_let 
kw_Constraint 
kw_not 
kw_Op 
kw_OpName 
kw_Pattern 
kw_replace 
kw_return 
kw_rewrite 
kw_Rewrite 
kw_Type 
kw_TypeRange 
kw_Value 
kw_ValueRange 
kw_with 
KW_END 
arrow 

Punctuation.

colon 
comma 
dot 
equal 
equal_arrow 
semicolon 
less 

Paired punctuation.

greater 
l_brace 
r_brace 
l_paren 
r_paren 
l_square 
r_square 
underscore 
directive 

Tokens.

identifier 
integer 
string_block 
string 

Definition at line 34 of file Lexer.h.

Constructor & Destructor Documentation

◆ Token()

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

Definition at line 99 of file Lexer.h.

Member Function Documentation

◆ getEndLoc()

SMLoc mlir::pdll::Token::getEndLoc ( ) const
inline

Return a location at the end of this token.

Definition at line 146 of file Lexer.h.

Referenced by getLoc().

◆ getKind()

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

Return the kind of this token.

Definition at line 124 of file Lexer.h.

◆ getLoc()

SMRange mlir::pdll::Token::getLoc ( ) const
inline

Return a location for the range of this token.

Definition at line 150 of file Lexer.h.

References getEndLoc(), and getStartLoc().

◆ getSpelling()

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

Return the bytes that make up this token.

Definition at line 121 of file Lexer.h.

◆ getStartLoc()

SMLoc mlir::pdll::Token::getStartLoc ( ) const
inline

Return a location for the start of this token.

Definition at line 144 of file Lexer.h.

Referenced by getLoc().

◆ getStringValue()

std::string mlir::pdll::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.

◆ is()

bool mlir::pdll::Token::is ( Kind  k) const
inline

Return if the token has the given kind.

Definition at line 141 of file Lexer.h.

Referenced by isAny().

◆ isAny() [1/2]

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

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

Definition at line 127 of file Lexer.h.

References is().

Referenced by isAny(), isNot(), and isString().

◆ isAny() [2/2]

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

Definition at line 129 of file Lexer.h.

References is(), and isAny().

◆ isDependentKeyword()

bool mlir::pdll::Token::isDependentKeyword ( ) const
inline

Returns true if the current token is a keyword in a dependent context, and in any other situation (e.g.

variable names) may be treated as an identifier.

Definition at line 116 of file Lexer.h.

References KW_DEPENDENT_BEGIN, and KW_DEPENDENT_END.

◆ isKeyword()

bool mlir::pdll::Token::isKeyword ( ) const
inline

Returns true if the current token is a keyword.

Definition at line 109 of file Lexer.h.

References KW_BEGIN, and KW_END.

◆ isNot() [1/2]

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

Return if the token does not have the given kind.

Definition at line 134 of file Lexer.h.

◆ isNot() [2/2]

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

Definition at line 136 of file Lexer.h.

References isAny().

◆ isString()

bool mlir::pdll::Token::isString ( ) const
inline

Returns true if the current token is a string literal.

Definition at line 106 of file Lexer.h.

References isAny(), string, and string_block.


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