7#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_P4_ASSERTS_PARSER_H_
8#define BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_P4_ASSERTS_PARSER_H_
15#include "backends/p4tools/common/lib/variables.h"
19#include "ir/visitor.h"
20#include "lib/cstring.h"
28class AssertsParser :
public Transform {
41 const IR::Node *postorder(IR::P4Action *actionContext)
override;
42 const IR::Node *postorder(IR::P4Table *tableContext)
override;
86 std::string_view m_lexeme{};
88 explicit Token(Kind
kind) noexcept : m_kind{
kind} {}
90 Token(Kind
kind,
const char *beg, std::size_t len) noexcept
91 : m_kind{
kind}, m_lexeme(beg, len) {}
95 Token(Kind
kind,
const char *beg,
const char *end) noexcept
96 : m_kind{
kind}, m_lexeme(beg, std::distance(beg, end)) {}
98 [[nodiscard]] Kind
kind()
const noexcept;
102 [[nodiscard]]
bool is(Kind
kind)
const noexcept;
104 [[nodiscard]]
bool isNot(Kind
kind)
const noexcept;
106 [[nodiscard]]
bool isOneOf(Kind k1, Kind k2)
const noexcept;
108 template <
typename... Ts>
109 bool isOneOf(Kind k1, Kind k2, Ts... ks)
const noexcept;
111 [[nodiscard]] std::string_view
lexeme()
const noexcept;
118 explicit Lexer(
const char *beg) noexcept : mBeg{beg} {}
120 Token next()
noexcept;
121 const char *mBeg =
nullptr;
124 Token atom(Token::Kind)
noexcept;
126 [[nodiscard]]
char peek()
const noexcept;
127 char prev()
noexcept;