aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/build/script/parser.hxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-05-26 21:35:59 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-06-03 12:26:33 +0300
commit920ed11a433b0e292a18adb8c68829a00e8c70cc (patch)
treee365baf8be68b168e19f42f20c5dde1526c1cbba /libbuild2/build/script/parser.hxx
parent4001ff053071c09008e88312c4f973c417322a07 (diff)
Allow process path values and targets as buildscript program names
Also deduce the recipe name.
Diffstat (limited to 'libbuild2/build/script/parser.hxx')
-rw-r--r--libbuild2/build/script/parser.hxx47
1 files changed, 45 insertions, 2 deletions
diff --git a/libbuild2/build/script/parser.hxx b/libbuild2/build/script/parser.hxx
index 5f08209..15d4ede 100644
--- a/libbuild2/build/script/parser.hxx
+++ b/libbuild2/build/script/parser.hxx
@@ -34,8 +34,9 @@ namespace build2
// name.
//
script
- pre_parse (istream&, const path_name&, uint64_t line,
- optional<string> diag);
+ pre_parse (const target&,
+ istream&, const path_name&, uint64_t line,
+ optional<string> diag, const location& diag_loc);
// Recursive descent parser.
//
@@ -82,9 +83,51 @@ namespace build2
virtual lookup
lookup_variable (name&&, string&&, const location&) override;
+ // During execution translate the process path and executable targets
+ // leaving the rest for the base parser to handle.
+ //
+ // During pre-parsing try to deduce the low-verbosity script
+ // diagnostics name.
+ //
+ virtual optional<process_path>
+ parse_program (token&, build2::script::token_type&, names&) override;
+
+ void
+ parse_program_diag (token&, build2::script::token_type&, names&);
+
protected:
script* script_;
+ // Current low-verbosity script diagnostics name and weight.
+ //
+ // During pre-parsing each command leading names are translated into a
+ // potential script name, unless it is set manually (with the diag
+ // directive or via the constructor). The potential script name has a
+ // weight associated with it, so script names with greater weights
+ // override names with lesser weights. The possible weights are:
+ //
+ // 0 - builtins that do not add to the script semantics (exit,
+ // true, etc) and are never picked up as a script name
+ //
+ // [1 2] - other builtins
+ //
+ // 3 - process path or executable target
+ //
+ // 4 - manually set names
+ //
+ // If two potential script names with the same weights are encountered
+ // then this ambiguity is reported unless a higher-weighted name is
+ // encountered later.
+ //
+ optional<pair<string, location>> diag;
+ optional<pair<string, location>> diag2;
+ uint8_t diag_weight = 0;
+
+ // True during pre-parsing when the pre-parse mode is temporarily
+ // suspended to perform expansion.
+ //
+ bool pre_parse_suspended_ = false;
+
// Execute state.
//
runner* runner_;