P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::P4Tools::P4Testgen::Bmv2::Token Class Reference

Public Types

enum class  Kind {
  Priority , Text , True , False ,
  LineStatementClose , Id , Number , Minus ,
  Plus , Dot , FieldAcces , MetadataAccess ,
  LeftParen , RightParen , Equal , NotEqual ,
  GreaterThan , GreaterEqual , LessThan , LessEqual ,
  LNot , Colon , Semicolon , Conjunction ,
  Disjunction , Implication , Slash , Percent ,
  Shr , Shl , Mul , Comment ,
  Unknown , EndString , End
}
 

Public Member Functions

 Token (Kind kind) noexcept
 
 Token (Kind kind, const char *beg, const char *end) noexcept
 
 Token (Kind kind, const char *beg, std::size_t len) noexcept
 
bool is (Kind kind) const noexcept
 
bool isNot (Kind kind) const noexcept
 
bool isOneOf (Kind k1, Kind k2) const noexcept
 Functions for multiple comparison kind.
 
template<typename... Ts>
bool isOneOf (Kind k1, Kind k2, Ts... ks) const noexcept
 
Kind kind () const noexcept
 The function to get kind from token.
 
void kind (Kind kind) noexcept
 The function to replace the token kind with another kind.
 
std::string_view lexeme () const noexcept
 The function to get lexeme from token.
 
void lexeme (std::string_view lexeme) noexcept
 The function to replace the token lexeme with another lexeme.
 

Public Attributes

Kind m_kind {}
 
std::string_view m_lexeme {}
 

Member Function Documentation

◆ is()

bool P4::P4Tools::P4Testgen::Bmv2::Token::is ( Token::Kind kind) const
nodiscardnoexcept

Kind comparison function. Allows you to compare token kind with the specified kind and return bool values, replacement for ==

◆ isNot()

bool P4::P4Tools::P4Testgen::Bmv2::Token::isNot ( Token::Kind kind) const
nodiscardnoexcept

Kind comparison function. Allows you to compare token kind with the specified kind and return bool values, replacement for !=