xlang/bootstrap/emit.hh

36 lines
1 KiB
C++
Raw Normal View History

#pragma once
#include <fstream>
2023-01-05 18:52:27 +00:00
#include <string>
#include <string_view>
2023-01-05 16:44:30 +00:00
#include <xlangBaseVisitor.h>
namespace xlang {
2023-01-05 16:44:30 +00:00
class EmitVisitor : public xlangBaseVisitor {
std::ofstream output;
2023-01-07 08:56:27 +00:00
size_t blockcount;
size_t tmpcount;
2023-01-05 18:52:27 +00:00
std::string last;
2023-01-07 08:56:27 +00:00
std::vector<size_t> loopstack;
2023-01-05 18:52:27 +00:00
std::string tmp();
public:
2023-01-05 16:44:30 +00:00
EmitVisitor(std::string_view outputfile);
2023-01-05 16:44:30 +00:00
std::any visitFile(xlangParser::FileContext *ctx) override;
std::any visitFunction(xlangParser::FunctionContext *ctx) override;
std::any visitStatement(xlangParser::StatementContext *ctx) override;
std::any visitExpr(xlangParser::ExprContext *ctx) override;
2023-01-12 23:07:00 +00:00
std::any visitBooleanExpr(xlangParser::BooleanExprContext *ctx) override;
std::any visitComparisonExpr(
xlangParser::ComparisonExprContext *ctx) override;
std::any visitAdditiveExpr(xlangParser::AdditiveExprContext *ctx) override;
std::any visitMultiplicativeExpr(
xlangParser::MultiplicativeExprContext *ctx) override;
2023-01-05 16:44:30 +00:00
std::any visitFactor(xlangParser::FactorContext *ctx) override;
};
} // namespace xlang