forked from NUDT-compiler/nudt-compiler-cpp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
364 B
17 lines
364 B
// 极简符号表:记录局部变量是否定义。
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
class SymbolTable {
|
|
public:
|
|
void Add(const std::string& name) { table_[name] = true; }
|
|
bool Contains(const std::string& name) const {
|
|
return table_.find(name) != table_.end();
|
|
}
|
|
|
|
private:
|
|
std::unordered_map<std::string, bool> table_;
|
|
};
|