Update ASTs to actually take in locations.
Didn't realize I broke the build by leaving this out.
This commit is contained in:
parent
a6839c548e
commit
5a9d4c1e92
35
13/ast.hpp
35
13/ast.hpp
|
@ -8,11 +8,14 @@
|
||||||
#include "instruction.hpp"
|
#include "instruction.hpp"
|
||||||
#include "env.hpp"
|
#include "env.hpp"
|
||||||
#include "definition.hpp"
|
#include "definition.hpp"
|
||||||
|
#include "location.hh"
|
||||||
#include "global_scope.hpp"
|
#include "global_scope.hpp"
|
||||||
|
|
||||||
struct ast {
|
struct ast {
|
||||||
type_env_ptr env;
|
type_env_ptr env;
|
||||||
|
yy::location loc;
|
||||||
|
|
||||||
|
ast(yy::location l) : env(nullptr), loc(std::move(l)) {}
|
||||||
virtual ~ast() = default;
|
virtual ~ast() = default;
|
||||||
|
|
||||||
virtual void print(int indent, std::ostream& to) const = 0;
|
virtual void print(int indent, std::ostream& to) const = 0;
|
||||||
|
@ -48,8 +51,8 @@ using branch_ptr = std::unique_ptr<branch>;
|
||||||
struct ast_int : public ast {
|
struct ast_int : public ast {
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
explicit ast_int(int v)
|
explicit ast_int(int v, yy::location l = yy::location())
|
||||||
: value(v) {}
|
: ast(std::move(l)), value(v) {}
|
||||||
|
|
||||||
void print(int indent, std::ostream& to) const;
|
void print(int indent, std::ostream& to) const;
|
||||||
void find_free(std::set<std::string>& into);
|
void find_free(std::set<std::string>& into);
|
||||||
|
@ -61,8 +64,8 @@ struct ast_int : public ast {
|
||||||
struct ast_lid : public ast {
|
struct ast_lid : public ast {
|
||||||
std::string id;
|
std::string id;
|
||||||
|
|
||||||
explicit ast_lid(std::string i)
|
explicit ast_lid(std::string i, yy::location l = yy::location())
|
||||||
: id(std::move(i)) {}
|
: ast(std::move(l)), id(std::move(i)) {}
|
||||||
|
|
||||||
void print(int indent, std::ostream& to) const;
|
void print(int indent, std::ostream& to) const;
|
||||||
void find_free(std::set<std::string>& into);
|
void find_free(std::set<std::string>& into);
|
||||||
|
@ -74,8 +77,8 @@ struct ast_lid : public ast {
|
||||||
struct ast_uid : public ast {
|
struct ast_uid : public ast {
|
||||||
std::string id;
|
std::string id;
|
||||||
|
|
||||||
explicit ast_uid(std::string i)
|
explicit ast_uid(std::string i, yy::location l = yy::location())
|
||||||
: id(std::move(i)) {}
|
: ast(std::move(l)), id(std::move(i)) {}
|
||||||
|
|
||||||
void print(int indent, std::ostream& to) const;
|
void print(int indent, std::ostream& to) const;
|
||||||
void find_free(std::set<std::string>& into);
|
void find_free(std::set<std::string>& into);
|
||||||
|
@ -89,8 +92,8 @@ struct ast_binop : public ast {
|
||||||
ast_ptr left;
|
ast_ptr left;
|
||||||
ast_ptr right;
|
ast_ptr right;
|
||||||
|
|
||||||
ast_binop(binop o, ast_ptr l, ast_ptr r)
|
ast_binop(binop o, ast_ptr l, ast_ptr r, yy::location lc = yy::location())
|
||||||
: op(o), left(std::move(l)), right(std::move(r)) {}
|
: ast(std::move(lc)), op(o), left(std::move(l)), right(std::move(r)) {}
|
||||||
|
|
||||||
void print(int indent, std::ostream& to) const;
|
void print(int indent, std::ostream& to) const;
|
||||||
void find_free(std::set<std::string>& into);
|
void find_free(std::set<std::string>& into);
|
||||||
|
@ -103,8 +106,8 @@ struct ast_app : public ast {
|
||||||
ast_ptr left;
|
ast_ptr left;
|
||||||
ast_ptr right;
|
ast_ptr right;
|
||||||
|
|
||||||
ast_app(ast_ptr l, ast_ptr r)
|
ast_app(ast_ptr l, ast_ptr r, yy::location lc = yy::location())
|
||||||
: left(std::move(l)), right(std::move(r)) {}
|
: ast(std::move(lc)), left(std::move(l)), right(std::move(r)) {}
|
||||||
|
|
||||||
void print(int indent, std::ostream& to) const;
|
void print(int indent, std::ostream& to) const;
|
||||||
void find_free(std::set<std::string>& into);
|
void find_free(std::set<std::string>& into);
|
||||||
|
@ -118,8 +121,8 @@ struct ast_case : public ast {
|
||||||
type_ptr input_type;
|
type_ptr input_type;
|
||||||
std::vector<branch_ptr> branches;
|
std::vector<branch_ptr> branches;
|
||||||
|
|
||||||
ast_case(ast_ptr o, std::vector<branch_ptr> b)
|
ast_case(ast_ptr o, std::vector<branch_ptr> b, yy::location l = yy::location())
|
||||||
: of(std::move(o)), branches(std::move(b)) {}
|
: ast(std::move(l)), of(std::move(o)), branches(std::move(b)) {}
|
||||||
|
|
||||||
void print(int indent, std::ostream& to) const;
|
void print(int indent, std::ostream& to) const;
|
||||||
void find_free(std::set<std::string>& into);
|
void find_free(std::set<std::string>& into);
|
||||||
|
@ -136,8 +139,8 @@ struct ast_let : public ast {
|
||||||
|
|
||||||
std::vector<basic_definition> translated_definitions;
|
std::vector<basic_definition> translated_definitions;
|
||||||
|
|
||||||
ast_let(definition_group g, ast_ptr i)
|
ast_let(definition_group g, ast_ptr i, yy::location l = yy::location())
|
||||||
: definitions(std::move(g)), in(std::move(i)) {}
|
: ast(std::move(l)), definitions(std::move(g)), in(std::move(i)) {}
|
||||||
|
|
||||||
void print(int indent, std::ostream& to) const;
|
void print(int indent, std::ostream& to) const;
|
||||||
void find_free(std::set<std::string>& into);
|
void find_free(std::set<std::string>& into);
|
||||||
|
@ -155,8 +158,8 @@ struct ast_lambda : public ast {
|
||||||
std::set<std::string> free_variables;
|
std::set<std::string> free_variables;
|
||||||
ast_ptr translated;
|
ast_ptr translated;
|
||||||
|
|
||||||
ast_lambda(std::vector<std::string> ps, ast_ptr b)
|
ast_lambda(std::vector<std::string> ps, ast_ptr b, yy::location l = yy::location())
|
||||||
: params(std::move(ps)), body(std::move(b)) {}
|
: ast(std::move(l)), params(std::move(ps)), body(std::move(b)) {}
|
||||||
|
|
||||||
void print(int indent, std::ostream& to) const;
|
void print(int indent, std::ostream& to) const;
|
||||||
void find_free(std::set<std::string>& into);
|
void find_free(std::set<std::string>& into);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user