1#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_P4_ASSERTS_PARSER_H_
2#define BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_P4_ASSERTS_PARSER_H_
9#include "backends/p4tools/common/lib/variables.h"
13#include "ir/visitor.h"
14#include "lib/cstring.h"
35 const IR::Node *postorder(IR::P4Action *actionContext)
override;
36 const IR::Node *postorder(IR::P4Table *tableContext)
override;
80 std::string_view m_lexeme{};
84 Token(Kind
kind,
const char *beg, std::size_t len) noexcept
85 : m_kind{
kind}, m_lexeme(beg, len) {}
89 Token(Kind
kind,
const char *beg,
const char *end) noexcept
90 : m_kind{
kind}, m_lexeme(beg, std::distance(beg, end)) {}
92 [[nodiscard]] Kind
kind()
const noexcept;
96 [[nodiscard]]
bool is(Kind
kind)
const noexcept;
98 [[nodiscard]]
bool isNot(Kind
kind)
const noexcept;
100 [[nodiscard]]
bool isOneOf(Kind k1, Kind k2)
const noexcept;
102 template <
typename... Ts>
103 bool isOneOf(Kind k1, Kind k2, Ts... ks)
const noexcept;
105 [[nodiscard]] std::string_view
lexeme()
const noexcept;
112 explicit Lexer(
const char *beg) noexcept : mBeg{beg} {}
114 Token next()
noexcept;
115 const char *mBeg =
nullptr;
118 Token atom(Token::Kind)
noexcept;
120 [[nodiscard]]
char peek()
const noexcept;
121 char prev()
noexcept;