Mana
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SemanticAnalyzer.h
Go to the documentation of this file.
1 
8 #pragma once
9 #include "../runner/common/Setup.h"
10 #include "Symbol.h"
11 #include "SymbolFactory.h"
12 #include "SyntaxNode.h"
13 
14 namespace mana
15 {
17  {
18  public:
19  explicit SemanticAnalyzer(
20  const std::shared_ptr<SymbolFactory>& symbolFactory,
21  const std::shared_ptr<TypeDescriptorFactory>& typeDescriptorFactory);
22 
23  virtual ~SemanticAnalyzer() = default;
24 
25  void SetCurrentFileInformation(const std::shared_ptr<SyntaxNode>& node);
26 
31  bool SearchSymbolFromName(const std::shared_ptr<SyntaxNode>& node);
32 
37  void ResolveTypeDescription(const std::shared_ptr<SyntaxNode>& node);
38 
44  std::shared_ptr<TypeDescriptor> ResolveVariableSize(const std::shared_ptr<SyntaxNode>& node);
45 
52  void ResolveDeclarator(const std::shared_ptr<SyntaxNode>& node, const bool isStaticVariable);
53 
61  void ResolveVariableDescription(const std::shared_ptr<SyntaxNode>& node, const Symbol::MemoryTypeId memoryTypeId, const bool isStaticVariable);
62 
67  void ResolveTypeFromChildNode(const std::shared_ptr<SyntaxNode>& node) const;
68 
69  protected:
70  [[nodiscard]] std::shared_ptr<Symbol> Lookup(const std::string_view name) const;
71 
72  const std::shared_ptr<SymbolFactory>& GetSymbolFactory();
73  const std::shared_ptr<TypeDescriptorFactory>& GetTypeDescriptorFactory();
74 
75  private:
76  std::shared_ptr<SymbolFactory> mSymbolFactory;
77  std::shared_ptr<TypeDescriptorFactory> mTypeDescriptorFactory;
78  };
79 }
Definition: SemanticAnalyzer.h:17
void ResolveTypeFromChildNode(const std::shared_ptr< SyntaxNode > &node) const
Definition: SemanticAnalyzer.cpp:147
void SetCurrentFileInformation(const std::shared_ptr< SyntaxNode > &node)
Definition: SemanticAnalyzer.cpp:22
const std::shared_ptr< SymbolFactory > & GetSymbolFactory()
Definition: SemanticAnalyzer.cpp:180
void ResolveTypeDescription(const std::shared_ptr< SyntaxNode > &node)
Definition: SemanticAnalyzer.cpp:52
void ResolveDeclarator(const std::shared_ptr< SyntaxNode > &node, const bool isStaticVariable)
Definition: SemanticAnalyzer.cpp:71
std::shared_ptr< Symbol > Lookup(const std::string_view name) const
Definition: SemanticAnalyzer.cpp:175
SemanticAnalyzer(const std::shared_ptr< SymbolFactory > &symbolFactory, const std::shared_ptr< TypeDescriptorFactory > &typeDescriptorFactory)
Definition: SemanticAnalyzer.cpp:14
const std::shared_ptr< TypeDescriptorFactory > & GetTypeDescriptorFactory()
Definition: SemanticAnalyzer.cpp:185
bool SearchSymbolFromName(const std::shared_ptr< SyntaxNode > &node)
Definition: SemanticAnalyzer.cpp:29
void ResolveVariableDescription(const std::shared_ptr< SyntaxNode > &node, const Symbol::MemoryTypeId memoryTypeId, const bool isStaticVariable)
Definition: SemanticAnalyzer.cpp:134
std::shared_ptr< TypeDescriptor > ResolveVariableSize(const std::shared_ptr< SyntaxNode > &node)
Definition: SemanticAnalyzer.cpp:91
virtual ~SemanticAnalyzer()=default
MemoryTypeId
Definition: Symbol.h:62
Definition: CodeBuffer.cpp:12
Definition: Noncopyable.h:18