xlang/bootstrap/typecheck.hh

30 lines
834 B
C++

#pragma once
#include <error.hh>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <xlangBaseVisitor.h>
namespace xlang {
class TypeCheckVisitor : public xlangBaseVisitor {
ErrorListener &errorlistener;
std::unordered_map<std::string, unsigned int> function_arity;
std::vector<std::unordered_set<std::string>> scope;
bool inScope(const std::string &name);
public:
TypeCheckVisitor(ErrorListener &errorlistener);
std::any visitFile(xlangParser::FileContext *ctx) override;
std::any visitFunction(xlangParser::FunctionContext *ctx) override;
std::any visitBlock(xlangParser::BlockContext *ctx) override;
std::any visitStatement(xlangParser::StatementContext *ctx) override;
std::any visitFactor(xlangParser::FactorContext *ctx) override;
};
} // namespace xlang