Keep track of locations in definitions.
This commit is contained in:
parent
578d580683
commit
67cb61c93f
|
@ -7,6 +7,7 @@
|
||||||
#include "llvm_context.hpp"
|
#include "llvm_context.hpp"
|
||||||
#include "parsed_type.hpp"
|
#include "parsed_type.hpp"
|
||||||
#include "type_env.hpp"
|
#include "type_env.hpp"
|
||||||
|
#include "location.hh"
|
||||||
#include "global_scope.hpp"
|
#include "global_scope.hpp"
|
||||||
|
|
||||||
struct ast;
|
struct ast;
|
||||||
|
@ -27,6 +28,7 @@ struct definition_defn {
|
||||||
std::string name;
|
std::string name;
|
||||||
std::vector<std::string> params;
|
std::vector<std::string> params;
|
||||||
ast_ptr body;
|
ast_ptr body;
|
||||||
|
yy::location loc;
|
||||||
|
|
||||||
type_env_ptr env;
|
type_env_ptr env;
|
||||||
type_env_ptr var_env;
|
type_env_ptr var_env;
|
||||||
|
@ -35,8 +37,12 @@ struct definition_defn {
|
||||||
type_ptr full_type;
|
type_ptr full_type;
|
||||||
type_ptr return_type;
|
type_ptr return_type;
|
||||||
|
|
||||||
definition_defn(std::string n, std::vector<std::string> p, ast_ptr b)
|
definition_defn(
|
||||||
: name(std::move(n)), params(std::move(p)), body(std::move(b)) {
|
std::string n,
|
||||||
|
std::vector<std::string> p,
|
||||||
|
ast_ptr b,
|
||||||
|
yy::location l = yy::location())
|
||||||
|
: name(std::move(n)), params(std::move(p)), body(std::move(b)), loc(std::move(l)) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,14 +59,16 @@ struct definition_data {
|
||||||
std::string name;
|
std::string name;
|
||||||
std::vector<std::string> vars;
|
std::vector<std::string> vars;
|
||||||
std::vector<constructor_ptr> constructors;
|
std::vector<constructor_ptr> constructors;
|
||||||
|
yy::location loc;
|
||||||
|
|
||||||
type_env_ptr env;
|
type_env_ptr env;
|
||||||
|
|
||||||
definition_data(
|
definition_data(
|
||||||
std::string n,
|
std::string n,
|
||||||
std::vector<std::string> vs,
|
std::vector<std::string> vs,
|
||||||
std::vector<constructor_ptr> cs)
|
std::vector<constructor_ptr> cs,
|
||||||
: name(std::move(n)), vars(std::move(vs)), constructors(std::move(cs)) {}
|
yy::location l = yy::location())
|
||||||
|
: name(std::move(n)), vars(std::move(vs)), constructors(std::move(cs)), loc(std::move(l)) {}
|
||||||
|
|
||||||
void insert_types(type_env_ptr& env);
|
void insert_types(type_env_ptr& env);
|
||||||
void insert_constructors() const;
|
void insert_constructors() const;
|
||||||
|
|
|
@ -75,7 +75,7 @@ definitions
|
||||||
defn
|
defn
|
||||||
: DEFN LID lowercaseParams EQUAL OCURLY aAdd CCURLY
|
: DEFN LID lowercaseParams EQUAL OCURLY aAdd CCURLY
|
||||||
{ $$ = definition_defn_ptr(
|
{ $$ = definition_defn_ptr(
|
||||||
new definition_defn(std::move($2), std::move($3), std::move($6))); }
|
new definition_defn(std::move($2), std::move($3), std::move($6), @$)); }
|
||||||
;
|
;
|
||||||
|
|
||||||
lowercaseParams
|
lowercaseParams
|
||||||
|
@ -143,7 +143,7 @@ pattern
|
||||||
|
|
||||||
data
|
data
|
||||||
: DATA UID lowercaseParams EQUAL OCURLY constructors CCURLY
|
: DATA UID lowercaseParams EQUAL OCURLY constructors CCURLY
|
||||||
{ $$ = definition_data_ptr(new definition_data(std::move($2), std::move($3), std::move($6))); }
|
{ $$ = definition_data_ptr(new definition_data(std::move($2), std::move($3), std::move($6), @$)); }
|
||||||
;
|
;
|
||||||
|
|
||||||
constructors
|
constructors
|
||||||
|
|
Loading…
Reference in New Issue
Block a user