#pragma once

#include <string>
#include <unordered_map>
#include <vector>

#include "SysYParser.h"

struct Symbol {
  enum class Kind { Variable, Constant, Function, Parameter };
  Kind kind;
  antlr4::ParserRuleContext* def_ctx;
  bool is_const = false;
  bool is_array = false;
  // For functions, we can store pointers to their parameter types or just the
  // FuncDefContext*
};

class SymbolTable {
 public:
  SymbolTable();
  void PushScope();
  void PopScope();
  bool Add(const std::string& name, const Symbol& symbol);
  Symbol* Lookup(const std::string& name);
  bool IsInCurrentScope(const std::string& name) const;

 private:
  std::vector<std::unordered_map<std::string, Symbol>> scopes_;
};
