From 3a2969cf54fb21273b7949095c709f6aa9a2a6d9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 14 Oct 2021 10:39:50 +0200 Subject: Pass along parse_names_result during script command parsing --- libbuild2/script/parser.cxx | 33 +++++++++++++++++++-------------- libbuild2/script/parser.hxx | 6 ++++-- 2 files changed, 23 insertions(+), 16 deletions(-) (limited to 'libbuild2/script') diff --git a/libbuild2/script/parser.cxx b/libbuild2/script/parser.cxx index f234d58..b0431a9 100644 --- a/libbuild2/script/parser.cxx +++ b/libbuild2/script/parser.cxx @@ -97,14 +97,16 @@ namespace build2 } optional parser:: - parse_program (token& t, type& tt, bool, bool, names& ns) + parse_program (token& t, type& tt, + bool, bool, + names& ns, parse_names_result& pr) { - parse_names (t, tt, - ns, - pattern_mode::ignore, - true /* chunk */, - "command line", - nullptr); + pr = parse_names (t, tt, + ns, + pattern_mode::ignore, + true /* chunk */, + "command line", + nullptr); return nullopt; } @@ -1048,10 +1050,13 @@ namespace build2 // reset_quoted (t); + parse_names_result pr; if (prog) { optional pp ( - parse_program (t, tt, p == pending::program_first, env, ns)); + parse_program (t, tt, + p == pending::program_first, env, + ns, pr)); // During pre-parsing we are not interested in the // parse_program() call result, so just discard the potentially @@ -1072,12 +1077,12 @@ namespace build2 } } else - parse_names (t, tt, - ns, - pattern_mode::ignore, - true /* chunk */, - "command line", - nullptr); + pr = parse_names (t, tt, + ns, + pattern_mode::ignore, + true /* chunk */, + "command line", + nullptr); // Nothing else to do if we are pre-parsing. // diff --git a/libbuild2/script/parser.hxx b/libbuild2/script/parser.hxx index 2a10311..077cb22 100644 --- a/libbuild2/script/parser.hxx +++ b/libbuild2/script/parser.hxx @@ -188,7 +188,7 @@ namespace build2 // During the execution phase try to parse and translate the leading // names into the process path and return nullopt if choose not to do // so, leaving it to the parser to handle. Also return in the last - // argument uninterpreted names, if any. + // two arguments uninterpreted names, if any. // // The default implementation always returns nullopt. The derived parser // can provide an override that can, for example, handle process path @@ -206,7 +206,9 @@ namespace build2 // recognize and execute certain directives, or some such. // virtual optional - parse_program (token&, token_type&, bool first, bool env, names&); + parse_program (token&, token_type&, + bool first, bool env, + names&, parse_names_result&); // Set lexer pointers for both the current and the base classes. // -- cgit v1.1