MLIR  19.0.0git
Public Member Functions | List of all members
mlir::AsmParser::KeywordSwitch< ResultT > Class Template Reference

This class represents a StringSwitch like class that is useful for parsing expected keywords. More...

#include "mlir/IR/OpImplementation.h"

Public Member Functions

 KeywordSwitch (AsmParser &parser, StringRef *keyword=nullptr)
 
KeywordSwitchCase (StringLiteral str, ResultT value)
 Case that uses the provided value when true. More...
 
KeywordSwitchDefault (ResultT value)
 
template<typename FnT >
std::enable_if_t<!std::is_convertible< FnT, ResultT >::value, KeywordSwitch & > Case (StringLiteral str, FnT &&fn)
 Case that invokes the provided functor when true. More...
 
template<typename FnT >
std::enable_if_t<!std::is_convertible< FnT, ResultT >::value, KeywordSwitch & > Default (FnT &&fn)
 
bool hasValue () const
 Returns true if this switch has a value yet. More...
 
 operator ResultT ()
 Return the result of the switch. More...
 

Detailed Description

template<typename ResultT = ParseResult>
class mlir::AsmParser::KeywordSwitch< ResultT >

This class represents a StringSwitch like class that is useful for parsing expected keywords.

On construction, unless a non-empty keyword is provided, it invokes parseKeyword and processes each of the provided cases statements until a match is hit. The provided ResultT must be assignable from failure().

Definition at line 791 of file OpImplementation.h.

Constructor & Destructor Documentation

◆ KeywordSwitch()

template<typename ResultT = ParseResult>
mlir::AsmParser::KeywordSwitch< ResultT >::KeywordSwitch ( AsmParser parser,
StringRef *  keyword = nullptr 
)
inline

Member Function Documentation

◆ Case() [1/2]

template<typename ResultT = ParseResult>
template<typename FnT >
std::enable_if_t<!std::is_convertible<FnT, ResultT>::value, KeywordSwitch &> mlir::AsmParser::KeywordSwitch< ResultT >::Case ( StringLiteral  str,
FnT &&  fn 
)
inline

Case that invokes the provided functor when true.

The parameters passed to the functor are the keyword, and the location of the keyword (in case any errors need to be emitted).

Definition at line 812 of file OpImplementation.h.

References mlir::AsmParser::codeCompleteExpectedTokens().

◆ Case() [2/2]

template<typename ResultT = ParseResult>
KeywordSwitch& mlir::AsmParser::KeywordSwitch< ResultT >::Case ( StringLiteral  str,
ResultT  value 
)
inline

Case that uses the provided value when true.

Definition at line 801 of file OpImplementation.h.

◆ Default() [1/2]

template<typename ResultT = ParseResult>
template<typename FnT >
std::enable_if_t<!std::is_convertible<FnT, ResultT>::value, KeywordSwitch &> mlir::AsmParser::KeywordSwitch< ResultT >::Default ( FnT &&  fn)
inline

Definition at line 825 of file OpImplementation.h.

◆ Default() [2/2]

template<typename ResultT = ParseResult>
KeywordSwitch& mlir::AsmParser::KeywordSwitch< ResultT >::Default ( ResultT  value)
inline

Definition at line 804 of file OpImplementation.h.

◆ hasValue()

template<typename ResultT = ParseResult>
bool mlir::AsmParser::KeywordSwitch< ResultT >::hasValue ( ) const
inline

Returns true if this switch has a value yet.

Definition at line 832 of file OpImplementation.h.

◆ operator ResultT()

template<typename ResultT = ParseResult>
mlir::AsmParser::KeywordSwitch< ResultT >::operator ResultT ( )
inline

Return the result of the switch.

Definition at line 835 of file OpImplementation.h.

References mlir::AsmParser::emitError().


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