/* * 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 HC_GEN_PARSER_H #define HC_GEN_PARSER_H #include #include "ast.h" #include "lexer.h" namespace OHOS { namespace Hardware { class Parser { public: Parser() = default; ~Parser() = default; bool Parse(); std::list> ParseOne(const std::string &src); std::shared_ptr ParseOneContent(const std::string &src, std::list &includeList); std::shared_ptr GetAst(); private: bool ProcessInclude(std::list &includeList); bool CheckCycleInclude(const std::string &includeSrc); std::shared_ptr ParseTemplate(); std::shared_ptr ParseNodeAndTerm(); std::shared_ptr ParseNodeCopy(Token &name); std::shared_ptr ParseNodeRef(Token &name); std::shared_ptr ParseNodeDelete(Token &name); std::shared_ptr ParseNodeInherit(Token &name); std::shared_ptr ParseNode(Token &name, bool bracesStart = false); std::shared_ptr ParseTerm(Token &name); std::shared_ptr ParseNodeWithRef(Token name); std::shared_ptr ParseArray(); void CleanError(); Lexer lexer_; Token current_; std::shared_ptr ast_; std::list srcQueue_; uint32_t errno_ = NOERR; }; } // namespace Hardware } // namespace OHOS #endif // HC_GEN_PARSER_H