1
2
3
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
13 namespace sngcm { namespace ast {
14
15 using namespace soulng::util;
16 using soulng::lexer::Span;
17 class Node;
18 class IdentifierNode;
19 class LabelNode;
20 class StatementNode;
21 class DefaultStatementNode;
22 class CompoundStatementNode;
23 class ConstraintNode;
24 class WhereConstraintNode;
25 class ConceptIdNode;
26 class ConceptNode;
27 class ConditionalCompilationExpressionNode;
28 class ConditionalCompilationPartNode;
29
30 inline int32_t MakeFileIndex(int16_t moduleId, int16_t fileId)
31 {
32 return (static_cast<int32_t>(moduleId) << 16) | fileId;
33 }
34
35 inline int16_t GetModuleId(int32_t fileIndex)
36 {
37 return static_cast<int16_t>((fileIndex >> 16) & 0xFFFF);
38 }
39
40 inline int16_t GetFileId(int32_t fileIndex)
41 {
42 return static_cast<int16_t>(fileIndex & 0xFFFF);
43 }
44
45 class AstReader
46 {
47 public:
48 AstReader(const std::string& fileName_);
49 BinaryReader& GetBinaryReader() { return binaryReader; }
50 Node* ReadNode();
51 IdentifierNode* ReadIdentifierNode();
52 LabelNode* ReadLabelNode();
53 StatementNode* ReadStatementNode();
54 DefaultStatementNode* ReadDefaultStatementNode();
55 CompoundStatementNode* ReadCompoundStatementNode();
56 ConstraintNode* ReadConstraintNode();
57 WhereConstraintNode* ReadWhereConstraintNode();
58 ConceptIdNode* ReadConceptIdNode();
59 ConceptNode* ReadConceptNode();
60 ConditionalCompilationExpressionNode* ReadConditionalCompilationExpressionNode();
61 ConditionalCompilationPartNode* ReadConditionalCompilationPartNode();
62 Specifiers ReadSpecifiers();
63 Span ReadSpan();
64 void SetModuleId(int16_t moduleId_) { moduleId = moduleId_; }
65 private:
66 BinaryReader binaryReader;
67 int16_t moduleId;
68 };
69
70 } }
71
72 #endif // SNGCM_AST_AST_READER_INCLUDED