aboutsummaryrefslogtreecommitdiff
path: root/include/semantic/scope.h
blob: aa13fe393ca3c02144a1769b516603878d1b361f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#pragma once

#include <string>
#include <memory>

class Scope {
public:
    explicit Scope(std::string name, int level, std::unique_ptr<Scope> parent);
    std::string getScopeName();
    int getScopeLevel();
    std::unique_ptr<Scope> getParentScope();
    void define(Symbol symbol);
    std::unique_ptr<Symbol> lookup(std::string name);
    bool isDeclared(std::string name);
    std::unordered_map<std::string, Symbol> getAllSymbols();
    std::string toString();

private:
    std::string scope_name;
    int scope_level
    std::unique_ptr<Scope> parent_scope;
    std::unordered_map<std::string, Symbol>;
};