AST building #2

Merged
TopchetoEU merged 74 commits from TopchetoEU/ast-building into master 2022-10-28 11:58:03 +00:00
2 changed files with 42 additions and 0 deletions
Showing only changes of commit bd6a837ecb - Show all commits

View File

@ -0,0 +1,41 @@
#pragma once
#include <string>
#include <list>
#include <unordered_map>
#include <memory>
#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<tok::token_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<constr_parser_t*> parsers;
std::unordered_map<std::string, constr_parser_t*> 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();
};
}

View File

@ -0,0 +1 @@
#include "compiler/treeifier/ast.hh"