xlang/bootstrap/emit.hh

31 lines
805 B
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-05 16:44:30 +00:00
int blockcount;
int tmpcount;
2023-01-05 18:52:27 +00:00
std::string last;
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;
std::any visitSum(xlangParser::SumContext *ctx) override;
std::any visitTerm(xlangParser::TermContext *ctx) override;
std::any visitFactor(xlangParser::FactorContext *ctx) override;
};
} // namespace xlang