diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-05-25 10:41:20 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-05-25 10:41:20 +0200 |
commit | a1f459f8446370704695919b3131653300866ee9 (patch) | |
tree | 8bc4670b2f9355d694e38443d99f506dd0ea9efc /build2/cc/parser.hxx | |
parent | 0cef93b4e2e9bf39b0ca542876f9ab1af6d0f01d (diff) |
Implement parsing of C++ module declarations
Diffstat (limited to 'build2/cc/parser.hxx')
-rw-r--r-- | build2/cc/parser.hxx | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/build2/cc/parser.hxx b/build2/cc/parser.hxx new file mode 100644 index 0000000..d52ddc9 --- /dev/null +++ b/build2/cc/parser.hxx @@ -0,0 +1,60 @@ +// file : build2/cc/parser.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD2_CC_PARSER_HXX +#define BUILD2_CC_PARSER_HXX + +#include <build2/types.hxx> +#include <build2/utility.hxx> + +#include <build2/diagnostics.hxx> + +namespace build2 +{ + namespace cc + { + // Extract (currently module) information from a preprocessed C/C++ + // source. + // + struct translation_unit + { + string module_name; // If not empty, then a module unit. + bool module_interface; // If true, then module interface unit. + vector<string> module_imports; // Imported modules. + }; + + struct token; + class lexer; + + class parser + { + public: + parser (): fail ("error", &name_), warn ("warning", &name_) {} + + translation_unit + parse (istream&, const path& name); + + private: + void + parse_import (token&); + + void + parse_module (token&, bool); + + string + parse_module_name (token&); + + private: + const path* name_; + + const fail_mark fail; + const basic_mark warn; + + lexer* l_; + translation_unit* u_; + }; + } +} + +#endif // BUILD2_CC_PARSER_HXX |