feat: add export def
This commit is contained in:
parent
9a63f8720d
commit
90497f601d
@ -38,6 +38,9 @@ namespace ppc::data {
|
|||||||
bool is_number() const;
|
bool is_number() const;
|
||||||
bool is_string() const;
|
bool is_string() const;
|
||||||
bool is_bool() const;
|
bool is_bool() const;
|
||||||
|
bool is_true() {
|
||||||
|
return is_bool() && boolean();
|
||||||
|
}
|
||||||
|
|
||||||
array_t &array(const array_t &arr);
|
array_t &array(const array_t &arr);
|
||||||
map_t &map(const map_t &map);
|
map_t &map(const map_t &map);
|
||||||
|
@ -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);
|
.add_last("$_exp", parse_stat_exp);
|
||||||
group("$_def")
|
group("$_def")
|
||||||
.add_last("$_func", parse_func)
|
.add_last("$_func", parse_func)
|
||||||
|
.add_named("$_export", parse_export, { "export" })
|
||||||
.add_last("$_field", parse_field);
|
.add_last("$_field", parse_field);
|
||||||
}
|
}
|
12
src/compiler/treeifier/ast/parsers/export.cc
Normal file
12
src/compiler/treeifier/ast/parsers/export.cc
Normal 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);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user