From 79c6b7ce9b5ca9927e69b97c4a434680fd3f106f Mon Sep 17 00:00:00 2001 From: yhirose Date: Fri, 12 Jun 2015 15:28:10 -0400 Subject: [PATCH] Fixed AST problem with And and Not predicates. --- peglib.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/peglib.h b/peglib.h index 09aa655..c43da2a 100644 --- a/peglib.h +++ b/peglib.h @@ -712,7 +712,9 @@ public: size_t parse(const char* s, size_t n, SemanticValues& sv, Context& c, any& dt) const override { const auto& rule = *ope_; - auto len = rule.parse(s, n, sv, c, dt); + auto& chldsv = c.push(); + auto len = rule.parse(s, n, chldsv, c, dt); + c.pop(); if (success(len)) { return 0; } else { @@ -734,8 +736,11 @@ public: size_t parse(const char* s, size_t n, SemanticValues& sv, Context& c, any& dt) const override { const auto& rule = *ope_; auto error_pos = c.error_pos; + auto& chldsv = c.push(); auto len = rule.parse(s, n, sv, c, dt); - if (success(len)) { + c.pop(); + if (success(len)) + { c.set_error_pos(s); return -1; } else {