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) {}
87 Token(Kind
kind,
const char *beg,
const char *end) noexcept
88 : m_kind{
kind}, m_lexeme(beg, std::distance(beg, end)) {}
90 [[nodiscard]] Kind
kind()
const noexcept;
94 [[nodiscard]]
bool is(Kind
kind)
const noexcept;
96 [[nodiscard]]
bool isNot(Kind
kind)
const noexcept;
98 [[nodiscard]]
bool isOneOf(Kind k1, Kind k2)
const noexcept;
100 template <
typename... Ts>
101 bool isOneOf(Kind k1, Kind k2, Ts... ks)
const noexcept;
103 [[nodiscard]] std::string_view
lexeme()
const noexcept;
110 explicit Lexer(
const char *beg) noexcept : mBeg{beg} {}
112 Token next()
noexcept;
113 const char *mBeg =
nullptr;
116 Token atom(Token::Kind)
noexcept;
118 [[nodiscard]]
char peek()
const noexcept;
119 char prev()
noexcept;