diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2020-03-25 07:36:31 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2020-03-25 07:36:31 +0200 |
commit | 0588e48ac1499388f4d2ad5bc03fe9f63782f161 (patch) | |
tree | 8a1785909c41dc159dce30f3682b84aa4f771661 /libbuild2/parser.hxx | |
parent | d1663e509e8cc77a8fbb8345bb1fbccacacf2429 (diff) |
Enforce config directives only appearing in project's root.build
Diffstat (limited to 'libbuild2/parser.hxx')
-rw-r--r-- | libbuild2/parser.hxx | 16 |
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_; |