31 lines
805 B
C++
31 lines
805 B
C++
#pragma once
|
|
|
|
#include <fstream>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <xlangBaseVisitor.h>
|
|
|
|
namespace xlang {
|
|
|
|
class EmitVisitor : public xlangBaseVisitor {
|
|
std::ofstream output;
|
|
int blockcount;
|
|
int tmpcount;
|
|
std::string last;
|
|
|
|
std::string tmp();
|
|
|
|
public:
|
|
EmitVisitor(std::string_view outputfile);
|
|
|
|
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
|