2023-01-04 22:32:55 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <fstream>
|
2023-01-05 18:52:27 +00:00
|
|
|
#include <string>
|
2023-01-04 22:32:55 +00:00
|
|
|
#include <string_view>
|
2023-01-05 16:44:30 +00:00
|
|
|
#include <xlangBaseVisitor.h>
|
2023-01-04 22:32:55 +00:00
|
|
|
|
|
|
|
namespace xlang {
|
|
|
|
|
2023-01-05 16:44:30 +00:00
|
|
|
class EmitVisitor : public xlangBaseVisitor {
|
2023-01-04 22:32:55 +00:00
|
|
|
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();
|
2023-01-04 22:32:55 +00:00
|
|
|
|
|
|
|
public:
|
2023-01-05 16:44:30 +00:00
|
|
|
EmitVisitor(std::string_view outputfile);
|
2023-01-04 22:32:55 +00:00
|
|
|
|
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;
|
2023-01-04 22:32:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace xlang
|