aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/parser.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-03-25 07:36:31 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-03-25 07:36:31 +0200
commit0588e48ac1499388f4d2ad5bc03fe9f63782f161 (patch)
tree8a1785909c41dc159dce30f3682b84aa4f771661 /libbuild2/parser.hxx
parentd1663e509e8cc77a8fbb8345bb1fbccacacf2429 (diff)
Enforce config directives only appearing in project's root.build
Diffstat (limited to 'libbuild2/parser.hxx')
-rw-r--r--libbuild2/parser.hxx16
1 files changed, 11 insertions, 5 deletions
diff --git a/libbuild2/parser.hxx b/libbuild2/parser.hxx
index dd5cbda..ba707da 100644
--- a/libbuild2/parser.hxx
+++ b/libbuild2/parser.hxx
@@ -23,12 +23,18 @@ namespace build2
class LIBBUILD2_SYMEXPORT parser
{
public:
- // If boot is true, then we are parsing bootstrap.build and modules
- // should only be bootstrapped.
+ // The project's loading stage during which the parsing is performed.
//
+ enum class stage
+ {
+ boot, // Parsing bootstrap.build (or bootstrap pre/post hooks).
+ root, // Parsing root.build (or root pre/post hooks).
+ rest // Parsing the rest (ordinary buildfiles, command line, etc).
+ };
+
explicit
- parser (context& c, bool boot = false)
- : fail ("error", &path_), ctx (c), boot_ (boot) {}
+ parser (context& c, stage s = stage::rest)
+ : fail ("error", &path_), ctx (c), stage_ (s) {}
// Issue diagnostics and throw failed in case of an error.
//
@@ -699,9 +705,9 @@ namespace build2
protected:
context& ctx;
+ stage stage_;
bool pre_parse_ = false;
- bool boot_;
const path_name* path_; // Current path name.
lexer* lexer_;