1
2
3
4
5
6 #ifndef SNGCPP_SYMBOLS_SYMBOL_INCLUDED
7 #define SNGCPP_SYMBOLS_SYMBOL_INCLUDED
8 #include <sngcpp/symbols/SymbolsApi.hpp>
9 #include <sngcpp/ast/Specifier.hpp>
10 #include <sngxml/dom/Element.hpp>
11 #include <soulng/lexer/Span.hpp>
12
13 namespace sngcpp { namespace symbols {
14
15 using soulng::lexer::Span;
16
17 using namespace sngcpp::ast;
18
19 class ContainerSymbol;
20 class ContainerScope;
21 class TypeSymbol;
22 class ClassTypeSymbol;
23
24 enum class SymbolAccess : uint8_t
25 {
26 public_, protected_, private_
27 };
28
29 std::u32string ToString(SymbolAccess access);
30
31 class Symbol
32 {
33 public:
34 Symbol(const Span& span_, const std::u32string& name_);
35 Symbol(const Symbol&) = delete;
36 Symbol(Symbol&&) = delete;
37 Symbol& operator=(const Symbol&) = delete;
38 Symbol& operator=(Symbol&&) = delete;
39 virtual ~Symbol();
40 const Span& GetSpan() const { return span; }
41 const std::u32string& Name() const { return name; }
42 void SetName(const std::u32string& name_) { name = name_; }
43 virtual bool NameBefore(Symbol* that) { return name < that->Name(); }
44 virtual const std::u32string& SimpleName() const { return name; }
45 virtual TypeSymbol* GetType() { return nullptr; }
46 virtual bool IsParentSymbol() const { return false; }
47 std::u32string FullName();
48 SymbolAccess Access() const { return access; }
49 void SetAccess(Specifier accessSpecifier);
50 virtual ContainerScope* GetContainerScope() { return nullptr; }
51 virtual std::u32string KindStr() = 0;
52 virtual std::u32string IdStr();
53 virtual std::u32string Id();
54 virtual std::unique_ptr<sngxml::dom::Element> CreateElement() = 0;
55 std::unique_ptr<sngxml::dom::Element> ToDomElement();
56 virtual std::unique_ptr<sngxml::dom::Element> Namespaces();
57 virtual std::unique_ptr<sngxml::dom::Element> Classes();
58 virtual std::unique_ptr<sngxml::dom::Element> Constructors();
59 virtual std::unique_ptr<sngxml::dom::Element> Functions();
60 virtual std::unique_ptr<sngxml::dom::Element> EnumTypes();
61 virtual std::unique_ptr<sngxml::dom::Element> Enumerators();
62 virtual std::unique_ptr<sngxml::dom::Element> Typedefs();
63 virtual std::unique_ptr<sngxml::dom::Element> Variables();
64 virtual std::unique_ptr<sngxml::dom::Element> Grammars();
65 ContainerSymbol* Parent() { return parent; }
66 void SetParent(ContainerSymbol* parent_) { parent = parent_; }
67 ClassTypeSymbol* Class();
68 virtual bool IsInstallSymbol() const { return true; }
69 virtual bool IsNamespaceSymbol() const { return false; }
70 virtual bool IsContainerSymbol() const { return false; }
71 virtual bool IsTypeSymbol() const { return false; }
72 virtual bool IsClassTypeSymbol() const { return false; }
73 virtual bool IsClassTemplateSpecializationSymbol() const { return false; }
74 virtual bool IsConstructorSymbol() const { return false; }
75 virtual bool IsDestructorSymbol() const { return false; }
76 virtual bool IsCallableSymbol() const { return false; }
77 virtual bool IsFunctionSymbol() const { return false; }
78 virtual bool IsFunctionDeclarationSymbol() const { return false; }
79 virtual bool IsConstructorDeclarationSymbol() const { return false; }
80 virtual bool IsFunctionGroupSymbol() const { return false; }
81 virtual bool IsClassGroupSymbol() const { return false; }
82 virtual bool IsClassGroupTypeSymbol() const { return false; }
83 virtual bool IsEnumTypeSymbol() const { return false; }
84 virtual bool IsEnumeratorSymbol() const { return false; }
85 virtual bool IsTypedefSymbol() const { return false; }
86 virtual bool IsParameterSymbol() const { return false; }
87 virtual bool IsVariableSymbol() const { return false; }
88 virtual bool IsDeclarationBlockSymbol() const { return false; }
89 virtual bool IsGrammarSymbol() const { return false; }
90 virtual bool IsRuleSymbol() const { return false; }
91 void SetProjectName(const std::u32string& projectName_);
92 const std::u32string& ProjectName() const { return projectName; }
93 private:
94 Span span;
95 std::u32string name;
96 ContainerSymbol* parent;
97 SymbolAccess access;
98 std::u32string projectName;
99 };
100
101 } }
102
103 #endif // SNGCPP_SYMBOLS_SYMBOL_INCLUDED