From 6b7075adc71104c5f6ad652b99fb753565eb67d8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 18 Nov 2016 17:28:46 +0200 Subject: Add function machinery, implement path.normalize() Note that multi-argument functions are not yet "callable" since there is no support for value packs. --- build2/parser.cxx | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) (limited to 'build2/parser.cxx') diff --git a/build2/parser.cxx b/build2/parser.cxx index d095047..4d2b933 100644 --- a/build2/parser.cxx +++ b/build2/parser.cxx @@ -8,14 +8,15 @@ #include +#include #include +#include #include -#include +#include +#include #include -#include -#include #include -#include +#include using namespace std; @@ -1658,12 +1659,14 @@ namespace build2 } } - value parser:: + pair parser:: parse_eval (token& t, type& tt) { mode (lexer_mode::eval, '@'); next (t, tt); - return parse_eval_trailer (t, tt); + return tt != type::rparen + ? make_pair (parse_eval_trailer (t, tt), true) + : make_pair (value (names ()), false); } value parser:: @@ -2306,7 +2309,7 @@ namespace build2 else if (tt == type::lparen) { expire_mode (); - value v (parse_eval (t, tt)); //@@ OUT will parse @-pair and do well? + value v (parse_eval (t, tt).first); //@@ OUT will parse @-pair and do well? if (!pre_parse_) { @@ -2357,31 +2360,22 @@ namespace build2 next (t, tt); // Get '('. - // Just a stub for now. - // - // Should we use (target/scope) qualification (of name) as the + // @@ Should we use (target/scope) qualification (of name) as the // context in which to call the function? // - value a (parse_eval (t, tt)); + auto args (parse_eval (t, tt)); tt = peek (); if (pre_parse_) continue; // As if empty result. - cout << name << "("; - - if (a) - { - if (!a.empty ()) - cout << reverse (a, lv_storage); - } - else - cout << "[null]"; - - - cout << ")" << endl; - - result = value (); // NULL for now. + // Note that we move args to call(). + // + result = functions.call (name, + vector_view ( + args.second ? &args.first : nullptr, + args.second ? 1 : 0), + loc); // See if we should propagate the NULL indicator. // @@ -2428,7 +2422,7 @@ namespace build2 else { loc = get_location (t); - result = parse_eval (t, tt); + result = parse_eval (t, tt).first; tt = peek (); -- cgit v1.1