• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef MAPLEBE_MDGEN_INCLUDE_MDPARSER_H
17 #define MAPLEBE_MDGEN_INCLUDE_MDPARSER_H
18 
19 #include "mdlexer.h"
20 #include "mdrecord.h"
21 #include "mempool.h"
22 
23 namespace MDGen {
24 class MDParser {
25 public:
MDParser(MDClassRange & newKeeper,maple::MemPool * memPool)26     MDParser(MDClassRange &newKeeper, maple::MemPool *memPool) : dataKeeper(newKeeper), mdMemPool(memPool) {}
27     ~MDParser() = default;
28 
29     bool ParseFile(const std::string &inputFile);
30     bool ParseObjectStart();
31     bool ParseObject();
32     bool IsObjectStart(MDTokenKind k) const;
33     bool ParseDefType();
34     bool ParseMDClass();
35     bool ParseMDClassBody(MDClass &oneClass);
36     bool ParseMDObject();
37     bool ParseMDObjBody(MDObject &curObj);
38     bool ParseIntElement(MDObject &curObj, bool isVec);
39     bool ParseStrElement(MDObject &curObj, bool isVec);
40     bool ParseDefTyElement(MDObject &curObj, bool isVec, const std::set<unsigned int> &childSet);
41     bool ParseDefObjElement(MDObject &curObj, bool isVec, const MDClass &pClass);
42 
43     /* error process */
44     bool EmitError(const std::string &errMsg);
45 
46 private:
47     MDLexer lexer;
48     MDClassRange &dataKeeper;
49     maple::MemPool *mdMemPool;
50 };
51 } /* namespace MDGen */
52 
53 #endif /* MAPLEBE_MDGEN_INCLUDE_MDPARSER_H */