mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2025-01-22 21:35:29 +00:00
Updated ast methods.
This commit is contained in:
parent
19c3644490
commit
ce51b0ee98
6
peglib.h
6
peglib.h
@ -2022,14 +2022,14 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
peg& ast_node(const char* name, int type) {
|
peg& ast_node(const char* name, int type = -1) {
|
||||||
(*this)[name] = [=](const SemanticValues& sv) {
|
(*this)[name] = [=](const SemanticValues& sv) {
|
||||||
return std::make_shared<Ast>(name, type, sv.map<std::shared_ptr<Ast>>());
|
return std::make_shared<Ast>(name, type, sv.map<std::shared_ptr<Ast>>());
|
||||||
};
|
};
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
peg& ast_list(const char* name, int type) {
|
peg& ast_node_optimizable(const char* name, int type = -1) {
|
||||||
(*this)[name] = [=](const SemanticValues& sv) {
|
(*this)[name] = [=](const SemanticValues& sv) {
|
||||||
if (sv.size() == 1) {
|
if (sv.size() == 1) {
|
||||||
std::shared_ptr<Ast> ast = sv[0].get<std::shared_ptr<Ast>>();
|
std::shared_ptr<Ast> ast = sv[0].get<std::shared_ptr<Ast>>();
|
||||||
@ -2058,8 +2058,6 @@ public:
|
|||||||
std::shared_ptr<Ast> ast = sv[0].get<std::shared_ptr<Ast>>();
|
std::shared_ptr<Ast> ast = sv[0].get<std::shared_ptr<Ast>>();
|
||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
//std::string msg = "AST handler for '" + name + "' is not defined...";
|
|
||||||
//throw std::logic_error(msg);
|
|
||||||
return std::make_shared<Ast>(name.c_str(), -1, sv.map<std::shared_ptr<Ast>>());
|
return std::make_shared<Ast>(name.c_str(), -1, sv.map<std::shared_ptr<Ast>>());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user