mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 20:05:31 +00:00
Fixed build errors.
This commit is contained in:
parent
65d1d99b2b
commit
02957c3668
@ -89,13 +89,14 @@ int main(int argc, const char** argv)
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (opt_ast) {
|
if (opt_ast) {
|
||||||
peg.enable_ast(opt_optimize_ast_nodes);
|
peg.enable_ast();
|
||||||
|
|
||||||
std::shared_ptr<peglib::Ast> ast;
|
std::shared_ptr<peglib::Ast> ast;
|
||||||
if (!peg.parse_n(source.data(), source.size(), ast)) {
|
if (!peg.parse_n(source.data(), source.size(), ast)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ast = peglib::AstOptimizer(opt_optimize_ast_nodes).optimize(ast);
|
||||||
peglib::AstPrint().print(*ast);
|
peglib::AstPrint().print(*ast);
|
||||||
} else {
|
} else {
|
||||||
if (!peg.parse_n(source.data(), source.size())) {
|
if (!peg.parse_n(source.data(), source.size())) {
|
||||||
|
@ -453,7 +453,7 @@ TEST_CASE("Calculator test with AST", "[general]")
|
|||||||
" ~_ <- [ \t\r\n]* "
|
" ~_ <- [ \t\r\n]* "
|
||||||
);
|
);
|
||||||
|
|
||||||
parser.enable_ast(true);
|
parser.enable_ast();
|
||||||
|
|
||||||
function<long (const Ast&)> eval = [&](const Ast& ast) {
|
function<long (const Ast&)> eval = [&](const Ast& ast) {
|
||||||
if (ast.name == "NUMBER") {
|
if (ast.name == "NUMBER") {
|
||||||
@ -477,6 +477,7 @@ TEST_CASE("Calculator test with AST", "[general]")
|
|||||||
|
|
||||||
shared_ptr<Ast> ast;
|
shared_ptr<Ast> ast;
|
||||||
auto ret = parser.parse("1+2*3*(4-5+6)/7-8", ast);
|
auto ret = parser.parse("1+2*3*(4-5+6)/7-8", ast);
|
||||||
|
ast = peglib::AstOptimizer(true).optimize(ast);
|
||||||
auto val = eval(*ast);
|
auto val = eval(*ast);
|
||||||
|
|
||||||
REQUIRE(ret == true);
|
REQUIRE(ret == true);
|
||||||
@ -492,7 +493,7 @@ TEST_CASE("Ignore semantic value test", "[general]")
|
|||||||
" _ <- [ \t\r\n]* "
|
" _ <- [ \t\r\n]* "
|
||||||
);
|
);
|
||||||
|
|
||||||
parser.enable_ast(false);
|
parser.enable_ast();
|
||||||
|
|
||||||
shared_ptr<Ast> ast;
|
shared_ptr<Ast> ast;
|
||||||
auto ret = parser.parse("Hello World", ast);
|
auto ret = parser.parse("Hello World", ast);
|
||||||
@ -512,7 +513,7 @@ TEST_CASE("Ignore semantic value of 'or' predicate test", "[general]")
|
|||||||
" ~_ <- [ \t\r\n]* "
|
" ~_ <- [ \t\r\n]* "
|
||||||
);
|
);
|
||||||
|
|
||||||
parser.enable_ast(false);
|
parser.enable_ast();
|
||||||
|
|
||||||
shared_ptr<Ast> ast;
|
shared_ptr<Ast> ast;
|
||||||
auto ret = parser.parse("Hello World.", ast);
|
auto ret = parser.parse("Hello World.", ast);
|
||||||
@ -531,7 +532,7 @@ TEST_CASE("Ignore semantic value of 'and' predicate test", "[general]")
|
|||||||
" ~_ <- [ \t\r\n]* "
|
" ~_ <- [ \t\r\n]* "
|
||||||
);
|
);
|
||||||
|
|
||||||
parser.enable_ast(false);
|
parser.enable_ast();
|
||||||
|
|
||||||
shared_ptr<Ast> ast;
|
shared_ptr<Ast> ast;
|
||||||
auto ret = parser.parse("Hello World.", ast);
|
auto ret = parser.parse("Hello World.", ast);
|
||||||
|
Loading…
Reference in New Issue
Block a user