bmv2
Designing your own switch target with bmv2
|
Go to the documentation of this file.
23 #ifndef BM_BM_SIM_PARSER_ERROR_H_
24 #define BM_BM_SIM_PARSER_ERROR_H_
29 #include <unordered_map>
43 type_t get() {
return v; }
47 return (v == other.v);
52 return !(*
this == other);
62 static constexpr type_t INVALID_V = std::numeric_limits<type_t>::max();
87 bool add(
const std::string &name, ErrorCode::type_t v);
88 bool exists(
const std::string &name)
const;
89 bool exists(ErrorCode::type_t v)
const;
107 static const char *core_to_name(
const Core &core);
109 std::unordered_map<ErrorCode::type_t, std::string> map_v_to_name{};
110 std::unordered_map<std::string, ErrorCode::type_t> map_name_to_v{};
113 class parser_exception :
public std::exception {
115 virtual ~parser_exception() { }
117 virtual ErrorCode get(
const ErrorCodeMap &error_codes)
const = 0;
120 class parser_exception_arch :
public parser_exception {
122 explicit parser_exception_arch(
const ErrorCode &code);
124 ErrorCode get(
const ErrorCodeMap &error_codes)
const override;
127 const ErrorCode code;
130 class parser_exception_core :
public parser_exception {
134 ErrorCode get(
const ErrorCodeMap &error_codes)
const override;
142 #endif // BM_BM_SIM_PARSER_ERROR_H_
ErrorCode from_name(const std::string &name) const
@ NoError
No error raised in parser.
static ErrorCode make_invalid()
Definition: parser_error.h:57
Definition: parser_error.h:35
bool operator!=(const ErrorCode &other) const
Inequality operator.
Definition: parser_error.h:51
const std::string & to_name(const ErrorCode &code) const
@ ParserTimeout
Parser execution time limit exceeded (unused for now)
@ HeaderTooShort
Extracting too many bits into a varbit field (unused for now)
@ NoMatch
Match statement has no matches (unused for now)
@ StackOutOfBounds
Reference to invalid element of a header stack (partial support)
@ PacketTooShort
Not enough bits in packet for extract or lookahead.
ErrorCode from_core(const Core &core) const
Retrieve an error code for one of the core errors.
A bi-directional map between error codes and their P4 names.
Definition: parser_error.h:66
Core
The core erros, as per core.p4.
Definition: parser_error.h:69
bool operator==(const ErrorCode &other) const
Equality operator.
Definition: parser_error.h:46