ppc-lang/src/compiler/treeifier/ast/parsers/identifier.cc
2022-10-14 20:27:45 +03:00

22 lines
676 B
C++

#include "compiler/treeifier/ast/helper.hh"
class identifier_parser_t : public parser_t {
bool parse(ast_ctx_t &ctx, size_t &res_i, map_t &out) const {
tree_helper_t h(ctx, res_i);
if (h.ended()) return false;
if (h.curr().is_identifier()) {
auto loc = h.loc();
out["location"] = conv::loc_to_map(loc);
out["content"] = h.curr().identifier();
return h.submit();
}
else return false;
}
public: identifier_parser_t(): parser_t("$_identifier") { }
};
parser_adder_t ppc::comp::tree::ast::identifier_adder = [](ast_ctx_t &ctx) { ctx.add_parser(new identifier_parser_t()); };