Implement new ordered typing in compiler series

This commit is contained in:
2020-03-24 22:00:09 -07:00
parent 0efa05142f
commit ae3e661d7a
3 changed files with 54 additions and 31 deletions

View File

@@ -1,12 +1,13 @@
%{
#include <string>
#include <iostream>
#include <map>
#include "ast.hpp"
#include "definition.hpp"
#include "parser.hpp"
std::vector<definition_data_ptr> defs_data;
std::vector<definition_defn_ptr> defs_defn;
std::map<std::string, definition_data_ptr> defs_data;
std::map<std::string, definition_defn_ptr> defs_defn;
extern yy::parser::symbol_type yylex();
@@ -59,8 +60,8 @@ definitions
;
definition
: defn { defs_defn.push_back(std::move($1)); }
| data { defs_data.push_back(std::move($1)); }
: defn { auto name = $1->name; defs_defn[name] = std::move($1); }
| data { auto name = $1->name; defs_data[name] = std::move($1); }
;
defn