1 // =================================
 2 // Copyright (c) 2021 Seppo Laakko
 3 // Distributed under the MIT license
 4 // =================================
 5 
 6 #ifndef SNGCM_AST_AST_READER_INCLUDED
 7 #define SNGCM_AST_AST_READER_INCLUDED
 8 #include <sngcm/ast/AstApi.hpp>
 9 #include <sngcm/ast/Specifier.hpp>
10 #include <soulng/util/BinaryReader.hpp>
11 #include <soulng/lexer/Span.hpp>
12 #include <unordered_map>
13 
14 namespace sngcm { namespace ast {
15 
16 using namespace soulng::util;
17 using soulng::lexer::Span;
18 class Node;
19 class IdentifierNode;
20 class LabelNode;
21 class StatementNode;
22 class DefaultStatementNode;
23 class CompoundStatementNode;
24 class ConstraintNode;
25 class WhereConstraintNode;
26 class ConceptIdNode;
27 class ConceptNode;
28 class TemplateIdNode;
29 class ConditionalCompilationExpressionNode;
30 class ConditionalCompilationPartNode;
31 class AttributesNode;
32 class AttributeNode;
33 
34 class AstReader 
35 {
36 public:
37     AstReader(const std::string& fileName_);
38     BinaryReader& GetBinaryReader() { return binaryReader; }
39     Node* ReadNode();
40     AttributeNode* ReadAttributeNode();
41     AttributesNode* ReadAttributesNode();
42     IdentifierNode* ReadIdentifierNode();
43     LabelNode* ReadLabelNode();
44     StatementNode* ReadStatementNode();
45     DefaultStatementNode* ReadDefaultStatementNode();
46     CompoundStatementNode* ReadCompoundStatementNode();
47     ConstraintNode* ReadConstraintNode();
48     WhereConstraintNode* ReadWhereConstraintNode();
49     ConceptIdNode* ReadConceptIdNode();
50     ConceptNode* ReadConceptNode();
51     TemplateIdNode* ReadTemplateIdNode();
52     ConditionalCompilationExpressionNode* ReadConditionalCompilationExpressionNode();
53     ConditionalCompilationPartNode* ReadConditionalCompilationPartNode();
54     Specifiers ReadSpecifiers();
55     Span ReadSpan();
56     void SetModuleMaps(const boost::uuids::uuid& rootModuleIdstd::std::unordered_map<int16_tstd::string>*moduleNameTable_std::std::unordered_map<std::stringint16_t>*moduleIdMap_);
57 private:
58     BinaryReader binaryReader;
59     boost::uuids::uuid rootModuleId;
60     std::std::unordered_map<int16_tstd::string>*moduleNameTable;
61     std::std::unordered_map<std::stringint16_t>*moduleIdMap;
62 };
63 
64 } } // namespace sngcm::ast
65 
66 #endif // SNGCM_AST_AST_READER_INCLUDED