From 0588e48ac1499388f4d2ad5bc03fe9f63782f161 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 25 Mar 2020 07:36:31 +0200 Subject: Enforce config directives only appearing in project's root.build --- libbuild2/parser.hxx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'libbuild2/parser.hxx') 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_; -- cgit v1.1