From 2cc2772263d17a9b2755990d53e992a94d37e29d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 27 Mar 2020 10:39:52 +0200 Subject: Implement project configuration reporting, similar to build system modules --- libbuild2/parser.hxx | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'libbuild2/parser.hxx') 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> 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 { - bool has; // Has attributes flag. - location loc; // Start location. - small_vector, 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 attributes_push (token&, token_type&, bool standalone = false); -- cgit v1.1