P4C
The P4 Compiler
Loading...
Searching...
No Matches
p4tools/modules/smith/common/parser.h
1/*
2 * SPDX-FileCopyrightText: 2024 The P4 Language Consortium
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef BACKENDS_P4TOOLS_MODULES_SMITH_COMMON_PARSER_H_
8#define BACKENDS_P4TOOLS_MODULES_SMITH_COMMON_PARSER_H_
9
10#include "backends/p4tools/modules/smith/common/generator.h"
11#include "ir/indexed_vector.h"
12#include "ir/ir.h"
13#include "ir/vector.h"
14#include "lib/cstring.h"
15
16namespace P4::P4Tools::P4Smith {
17
18class ParserGenerator : public Generator {
19 private:
21
22 public:
23 virtual ~ParserGenerator() = default;
24 explicit ParserGenerator(const SmithTarget &target) : Generator(target) {}
25
26 virtual IR::MethodCallStatement *genHdrExtract(IR::Member *pkt_call, IR::Expression *mem);
27 virtual void genHdrUnionExtract(IR::IndexedVector<IR::StatOrDecl> &components,
28 const IR::Type_HeaderUnion *hdru, IR::ArrayIndex *arr_ind,
29 IR::Member *pkt_call);
30 virtual IR::ListExpression *buildMatchExpr(IR::Vector<IR::Type> types);
31 virtual IR::ParserState *genStartState();
32 virtual IR::ParserState *genHdrStates();
33 virtual void genState(cstring name);
34 virtual void buildParserTree();
35
36 [[nodiscard]] IR::IndexedVector<IR::ParserState> getStates() const { return state_list; }
37};
38
39} // namespace P4::P4Tools::P4Smith
40
41#endif /* BACKENDS_P4TOOLS_MODULES_SMITH_COMMON_PARSER_H_ */
Definition indexed_vector.h:31
Definition ir/vector.h:59
Definition p4tools/modules/smith/core/target.h:23
Definition cstring.h:85