From f00f62d89fdcd5ca2d49fbdd4efe41ab4fc3fd64 Mon Sep 17 00:00:00 2001 From: dellaert Date: Tue, 2 Dec 2014 11:24:53 +0100 Subject: [PATCH] Much better way of handling local variables in grammar --- wrap/Argument.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/wrap/Argument.h b/wrap/Argument.h index 3b7a13ee3..fd7e82061 100644 --- a/wrap/Argument.h +++ b/wrap/Argument.h @@ -171,27 +171,28 @@ struct ArgumentListGrammar: public classic::grammar { wrap::ArgumentList& result_; ///< successful parse will be placed in here - const Argument arg0; ///< used to reset arg - mutable Argument arg; ///< temporary argument for use during parsing - ArgumentGrammar argument_g; ///< single Argument parser - /// Construct type grammar and specify where result is placed ArgumentListGrammar(wrap::ArgumentList& result) : - result_(result), argument_g(arg) { + result_(result) { } /// Definition of type grammar template struct definition { + const Argument arg0; ///< used to reset arg + Argument arg; ///< temporary argument for use during parsing + ArgumentGrammar argument_g; ///< single Argument parser + classic::rule argument_p, argumentList_p; - definition(ArgumentListGrammar const& self) { + definition(ArgumentListGrammar const& self) : + argument_g(arg) { using namespace classic; - argument_p = self.argument_g // - [classic::push_back_a(self.result_, self.arg)] // - [assign_a(self.arg, self.arg0)]; + argument_p = argument_g // + [classic::push_back_a(self.result_, arg)] // + [assign_a(arg, arg0)]; argumentList_p = '(' >> !argument_p >> *(',' >> argument_p) >> ')'; }