AST building #2

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

View File

@ -38,6 +38,9 @@ namespace ppc::data {
bool is_number() const;
bool is_string() const;
bool is_bool() const;
bool is_true() {
return is_bool() && boolean();
}
array_t &array(const array_t &arr);
map_t &map(const map_t &map);

View File

@ -20,5 +20,6 @@ ast_ctx_t::ast_ctx_t(msg_stack_t &messages, std::vector<token_t> &tokens): messa
.add_last("$_exp", parse_stat_exp);
group("$_def")
.add_last("$_func", parse_func)
.add_named("$_export", parse_export, { "export" })
.add_last("$_field", parse_field);
}

View File

@ -0,0 +1,12 @@
#include "compiler/treeifier/ast/helper.hh"
bool ast::parse_export(ast_ctx_t &ctx, size_t &res_i, map_t &out) {
tree_helper_t h(ctx, res_i);
if (out["exported"].is_true()) {
ctx.messages.push(message_t(message_t::WARNING, "Export is alredy specified for this definition.", h.prev_loc()));
}
out["exported"] = true;
return ctx.group("$_def")(ctx, res_i, out);
}