-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathirgen.h
41 lines (33 loc) · 801 Bytes
/
irgen.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
#include <memory>
#include <sstream>
#include "mytypes.h"
#include "symboltable.h"
#include "ast.h"
class IRGenVisitor : public ASTVisitorBase
{
public:
void visit(const ASTNode &v) override;
std::string getErrors() const
{
return m_errors.str();
}
std::string getCode() const
{
return m_code.str();
}
constexpr bool hasErrors() const noexcept
{
return m_hasErrors;
}
protected:
void error(const std::string &txt, const LinePos &pos)
{
m_errors << "Error: " << pos.m_line << "," << pos.m_col << " " << txt << "\n";
m_hasErrors = true;
}
bool m_hasErrors = false;
std::stringstream m_errors;
std::stringstream m_code;
SymbolTable m_symTable;
};