aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/parser.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-03-27 10:39:52 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-03-27 10:40:58 +0200
commit2cc2772263d17a9b2755990d53e992a94d37e29d (patch)
tree1ad8e98e564485ae87ebae9a6e3546798eeda7b4 /libbuild2/parser.hxx
parentee128a8d4c3d5739b31fbb9e935b319176837cc8 (diff)
Implement project configuration reporting, similar to build system modules
Diffstat (limited to 'libbuild2/parser.hxx')
-rw-r--r--libbuild2/parser.hxx37
1 files changed, 24 insertions, 13 deletions
diff --git a/libbuild2/parser.hxx b/libbuild2/parser.hxx
index 6d78ce1..b21336d 100644
--- a/libbuild2/parser.hxx
+++ b/libbuild2/parser.hxx
@@ -72,8 +72,15 @@ namespace build2
// Note that these are not touched by reset().
//
public:
+ // export directive result.
+ //
names export_value;
+ // config directive result.
+ //
+ vector<pair<lookup, string>> config_report; // Config value and format.
+ bool config_report_new = false; // One of values is new.
+
// Recursive descent parser.
//
protected:
@@ -231,24 +238,28 @@ namespace build2
// In this example we only apply the value attributes after evaluating
// the context, which has its own attributes.
//
- struct attributes
+ struct attribute
+ {
+ string name;
+ build2::value value;
+ };
+
+ struct attributes: small_vector<attribute, 1>
{
- bool has; // Has attributes flag.
- location loc; // Start location.
- small_vector<pair<string, value>, 1> ats; // Attributes.
+ location loc; // Start location.
- explicit operator bool () const {return has;}
+ explicit
+ attributes (location l): loc (move (l)) {}
};
- // Push a new entry into the attributes_ stack. If the next token is '['
- // 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.
+ // Push a new entry into the attributes_ stack. If the next token is `[`
+ // then parse the attribute sequence until ']' storing the result in the
+ // new stack entry. 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 we have seen `[` (even if it's the
+ // `[]` empty list) and its location.
//
- // Note that during pre-parsing nothing is pushed into the stack and
- // the returned attributes object indicates there are no attributes.
+ // Note that during pre-parsing nothing is pushed into the stack.
//
pair<bool, location>
attributes_push (token&, token_type&, bool standalone = false);