/* * Copyright (c) 2021 Huawei Device Co., Ltd. * * HDF is dual licensed: you can use it either under the terms of * the GPL, or the BSD license, at your option. * See the LICENSE file in the root of this repository for complete details. */ #ifndef OHOS_HDI_MODULE_PARSER_H #define OHOS_HDI_MODULE_PARSER_H #include #include #include "ast/ast_module.h" #include "parser/file_detail.h" #include "util/options.h" namespace OHOS { namespace HDI { class ModuleParser { public: using FileDetailMap = std::unordered_map, StringHashFunc, StringEqualFunc>; explicit ModuleParser(const Options& option) : option_(option), sourceFiles_(), searchedFile_(), traceFilePtr_(nullptr), allCirclesFile_(), compileFiles_(), module_(new ASTModule()) {} ~ModuleParser() {} AutoPtr Parse(); private: // parser file and circular reference bool ParserDependencies(); bool CompileFiles(); // parse all idl file involved in compilation. bool ParserAllImports(const String& rootFilePath); bool ParserAllImportsRecursion(const std::shared_ptr& fileInfo); bool ParserAllidlFile(const std::vector& idlSourceFile); // check circular reference and reverse topology sorting of all idl file bool CheckCircularReference(); static const char* TAG; const Options& option_; FileDetailMap sourceFiles_; std::set searchedFile_; std::shared_ptr> traceFilePtr_; std::vector> allCirclesFile_; std::vector compileFiles_; AutoPtr module_; }; } // namespace HDI } // namespace OHOS #endif // OHOS_HDI_MODULE_PARSER_H