aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/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/script/parser.hxx
parent4001ff053071c09008e88312c4f973c417322a07 (diff)
Allow process path values and targets as buildscript program names
Also deduce the recipe name.
Diffstat (limited to 'libbuild2/script/parser.hxx')
-rw-r--r--libbuild2/script/parser.hxx32
1 files changed, 30 insertions, 2 deletions
diff --git a/libbuild2/script/parser.hxx b/libbuild2/script/parser.hxx
index a63ecde..b15f632 100644
--- a/libbuild2/script/parser.hxx
+++ b/libbuild2/script/parser.hxx
@@ -162,14 +162,42 @@ namespace build2
size_t& li,
variable_pool* = nullptr);
+ // Customization hooks.
+ //
+ protected:
+ // Parse the command's leading name chunk.
+ //
+ // 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.
+ //
+ // The default implementation always returns nullopt. The derived parser
+ // can provide an override that can, for example, handle process path
+ // values, executable targets, etc.
+ //
+ // Note that normally it makes sense to leave simple unpaired names for
+ // the parser to handle, unless there is a good reason not to (e.g.,
+ // it's a special builtin or some such). Such names may contain
+ // something that requires re-lexing, for example `foo|bar`, which won't
+ // be easy to translate but which are handled by the parser.
+ //
+ // During the pre-parsing phase the returned process path and names
+ // (that must still be parsed) are discarded. The main purpose of the
+ // call is to allow implementations to perform static script analysis,
+ // recognize and execute certain directives, or some such.
+ //
+ virtual optional<process_path>
+ parse_program (token&, token_type&, names&);
+
// Set lexer pointers for both the current and the base classes.
//
protected:
void
set_lexer (lexer*);
- // Number of quoted tokens since last reset. Note that this includes
- // the peeked token, if any.
+ // Number of quoted tokens since last reset. Note that this includes the
+ // peeked token, if any.
//
protected:
size_t