diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2019-05-09 14:12:45 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2019-05-10 08:01:33 +0200 |
commit | 2b1272f1c94ab1dbaf806af9c02ef866267ffed7 (patch) | |
tree | e7ad99fbb36367a0883eadaade94c41c9894fced /build2/parser.hxx | |
parent | 1b0efce7791d4d61aa57038edb30fb823ed48e21 (diff) |
Generalize target/prerequisite var block, initial ad hoc target work
Target/prerequisite-specific variable blocks can now be present even if
there are prerequisites. For example, now instead of:
exe{foo}: cxx{foo}
exe{foo}: cc.loptions += ...
Or:
exe{foo}: cxx{foo}
exe{foo}:
{
cc.loptions += ...
cc.libs += ...
}
We can write:
exe{foo}: cxx{foo}
{
cc.loptions += ...
cc.libs += ...
}
This also works with dependency chains in which case the block applies
to the set of prerequisites (note: not targets) before the last ':'. For
example:
./: exe{foo}: libue{foo}: cxx{foo}
{
bin.whole = false # Applies to the libue{foo} prerequisite.
}
Diffstat (limited to 'build2/parser.hxx')
-rw-r--r-- | build2/parser.hxx | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/build2/parser.hxx b/build2/parser.hxx index fb7fb4e..b4b7093 100644 --- a/build2/parser.hxx +++ b/build2/parser.hxx @@ -78,10 +78,28 @@ namespace build2 void parse_variable_block (token&, token_type&, const target_type*, string); + // Ad hoc target names inside < ... >. + // + struct adhoc_names_loc + { + names ns; + location loc; + }; + + using adhoc_names = small_vector<adhoc_names_loc, 1>; + void + enter_adhoc_members (adhoc_names_loc&&, bool); + + small_vector<reference_wrapper<target>, 1> + enter_targets (names&&, const location&, adhoc_names&&, size_t); + + bool parse_dependency (token&, token_type&, names&&, const location&, - names&&, const location&); + adhoc_names&&, + names&&, const location&, + bool = false); void parse_assert (token&, token_type&); @@ -189,11 +207,11 @@ namespace build2 }; // Push a new entry into the attributes_ stack. If the next token is '[' - // parse the attribute sequence until ']' setting the 'has' flag and - // storing the result on the stack. Then get the next token and, if - // standalone is false, verify it is not newline/eos (i.e., there is - // something after it). Return the indication of whether there are - // any attributes and their location. + // parse the attribute sequence until ']' storing the result in the new + // stack entry and setting the 'has' flag (unless the attribute list is + // empty). Then get the next token and, if standalone is false, verify + // it is not newline/eos (i.e., there is something after it). Return the + // indication of whether there are any attributes and their location. // // Note that during pre-parsing nothing is pushed into the stack and // the returned attributes object indicates there are no attributes. @@ -258,6 +276,14 @@ namespace build2 return ns; } + // Return true if this token starts a name. Or, to put it another way, + // calling parse_names() on this token won't fail with the "expected name + // instead of <this-token>" error. Only consider '(' if the second + // argument is true. + // + bool + start_names (token_type&, bool lparen = true); + // As above but return the result as a value, which can be typed and NULL. // value @@ -422,6 +448,14 @@ namespace build2 token_type next (token&, token_type&); + // If the current token is newline, then get the next token. Otherwise, + // fail unless the current token is eos (i.e., optional newline at the end + // of stream). If the after argument is not \0, use it in diagnostics as + // the token after which the newline was expectd. + // + token_type + next_after_newline (token&, token_type&, char after = '\0'); + // Be careful with peeking and switching the lexer mode. See keyword() // for more information. // |