diff --git a/include/compiler/treeifier/ast.hh b/include/compiler/treeifier/ast.hh new file mode 100644 index 0000000..76a8c1d --- /dev/null +++ b/include/compiler/treeifier/ast.hh @@ -0,0 +1,41 @@ +#pragma once + +#include +#include +#include +#include +#include "compiler/treeifier/tokenizer.hh" +#include "utils/data.hh" +#include "utils/slice.hh" +#include "lang/common.hh" + +using namespace std::string_literals; +using namespace ppc; + +namespace ppc::comp::tree::ast { + class constr_parser_t { + private: + std::string name; + public: + const std::string &name() { return name; } + virtual bool parse(messages::msg_stack_t &messages, vec_slice_t &tokens, data::map_t &out) = 0; + }; + + class group_parser_t : constr_parser_t { + private: + struct named_parser { + constr_parser_t *parser; + std::string name; + }; + std::list parsers; + std::unordered_map insertion_points; + public: + void add_insertion_point(constr_parser_t &parser, const std::string &name); + void add(constr_parser_t &parser); + void add(const std::string &ins_point, constr_parser_t &parser); + + bool parse(messages::msg_stack_t &messages, data::map_t &out); + + group_parser_t(); + }; +} \ No newline at end of file diff --git a/src/compiler/treeifier/ast.cc b/src/compiler/treeifier/ast.cc new file mode 100644 index 0000000..04e224d --- /dev/null +++ b/src/compiler/treeifier/ast.cc @@ -0,0 +1 @@ +#include "compiler/treeifier/ast.hh"