aboutsummaryrefslogtreecommitdiff
path: root/include/symbol.hpp
diff options
context:
space:
mode:
authorCori Barker <coribarker2@gmail.com>2026-03-10 22:53:50 +0000
committerCori Barker <coribarker2@gmail.com>2026-03-10 22:53:50 +0000
commit32a1609b59fcbbfe24e223c078d51f8bfa08566f (patch)
tree0aafc1e1d19ab0a3e610ee227f92ab6a8a327813 /include/symbol.hpp
parentc364efa08dff0abef9e043e2e28cf2d8dc6b95b3 (diff)
continued development of the semantic analyzer and symbol table generation
Diffstat (limited to 'include/symbol.hpp')
-rw-r--r--include/symbol.hpp26
1 files changed, 12 insertions, 14 deletions
diff --git a/include/symbol.hpp b/include/symbol.hpp
index d7be206..9b48a0a 100644
--- a/include/symbol.hpp
+++ b/include/symbol.hpp
@@ -1,30 +1,28 @@
#pragma once
-#include "symbol_type.hpp"
#include "type.hpp"
#include <variant>
#include <vector>
#include <string>
+enum SymbolType {
+ VARIABLE,
+ FUNCTION,
+};
+
class Symbol {
public:
std::string identifier;
+ SymbolType symbol_type;
+ Type data_type;
+ Type return_type;
+ std::vector<std::string> parameter_identifiers;
+ std::vector<Type> parameter_types;
int line;
int column;
- virtual ~Symbol() = default;
-};
-
-class FunctionDeclarationSymbol : public Symbol {
- Type return_type;
- std::vector<std::string> parameters;
-
- FunctionDeclarationSymbol(std::string identifier, Type return_type, std::vector<std::string> parameters, int line, int column) : identifier(identifier), return_type(return_type), parameters(parameters), line(line), column(column) { }
-};
-
-class VariableDeclarationSymbol : public Symbol {
- Type type;
+ Symbol(std::string identifier, Type data_type, int line, int column) : identifier(identifier), data_type(data_type), line(line), column(column), symbol_type(SymbolType::VARIABLE) { }
- VariableDeclarationSymbol
+ Symbol(std::string identifier, Type return_type, std::vector<std::string> parameter_identifiers, std::vector<Type> parameter_types, int line, int column) : identifier(identifier), data_type(data_type), return_type(return_type), parameter_identifiers(parameter_identifiers), parameter_types(parameter_types), line(line), column(column), symbol_type(SymbolType::FUNCTION) { }
};