From 02957c3668216d3ad8cefd1a9b727163fdd0b026 Mon Sep 17 00:00:00 2001 From: yhirose Date: Fri, 31 Jul 2015 19:07:20 -0400 Subject: [PATCH] Fixed build errors. --- lint/peglint.cc | 3 ++- test/test.cc | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lint/peglint.cc b/lint/peglint.cc index d346bbf..6b7095b 100644 --- a/lint/peglint.cc +++ b/lint/peglint.cc @@ -89,13 +89,14 @@ int main(int argc, const char** argv) }; if (opt_ast) { - peg.enable_ast(opt_optimize_ast_nodes); + peg.enable_ast(); std::shared_ptr ast; if (!peg.parse_n(source.data(), source.size(), ast)) { return -1; } + ast = peglib::AstOptimizer(opt_optimize_ast_nodes).optimize(ast); peglib::AstPrint().print(*ast); } else { if (!peg.parse_n(source.data(), source.size())) { diff --git a/test/test.cc b/test/test.cc index 7307b58..93350e8 100644 --- a/test/test.cc +++ b/test/test.cc @@ -453,7 +453,7 @@ TEST_CASE("Calculator test with AST", "[general]") " ~_ <- [ \t\r\n]* " ); - parser.enable_ast(true); + parser.enable_ast(); function eval = [&](const Ast& ast) { if (ast.name == "NUMBER") { @@ -477,6 +477,7 @@ TEST_CASE("Calculator test with AST", "[general]") shared_ptr ast; auto ret = parser.parse("1+2*3*(4-5+6)/7-8", ast); + ast = peglib::AstOptimizer(true).optimize(ast); auto val = eval(*ast); REQUIRE(ret == true); @@ -492,7 +493,7 @@ TEST_CASE("Ignore semantic value test", "[general]") " _ <- [ \t\r\n]* " ); - parser.enable_ast(false); + parser.enable_ast(); shared_ptr 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]* " ); - parser.enable_ast(false); + parser.enable_ast(); shared_ptr 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]* " ); - parser.enable_ast(false); + parser.enable_ast(); shared_ptr ast; auto ret = parser.parse("Hello World.", ast);