From c3c4aa3c74a7c9ae2d23b11c8c684fd47c8d342c Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Wed, 3 Jul 2019 13:55:47 +0200 Subject: [PATCH] :art: Improve Grammar --- ast | 2 +- src/emit/emit.c | 4 ++-- src/lib/import.c | 11 ++++++----- src/parse/check.c | 2 +- tests/error/typeof_error.gw | 2 +- tests/import/extend_array.c | 2 +- tests/import/extend_event.c | 2 +- tests/import/extend_pair.c | 6 +++--- tests/tree/decl_exp_array.gw | 2 +- util | 2 +- 10 files changed, 18 insertions(+), 17 deletions(-) diff --git a/ast b/ast index d85f0930..f2f84ac0 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit d85f0930b632be859189dae9ca42829458052016 +Subproject commit f2f84ac0731632c4b03de9535b169ca483d03113 diff --git a/src/emit/emit.c b/src/emit/emit.c index 473590b7..965a8375 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1420,8 +1420,8 @@ ANN static m_bool emit_stmt_union(const Emitter emit, const Stmt_Union stmt) { if(stmt->xid) { union_allocdata(emit->gwion->mp, stmt); Type_Decl *type_decl = new_type_decl(emit->gwion->mp, - new_id_list(emit->gwion->mp, stmt->xid, loc_cpy(emit->gwion->mp, stmt_self(stmt)->pos)), - stmt->flag); + new_id_list(emit->gwion->mp, stmt->xid, loc_cpy(emit->gwion->mp, stmt_self(stmt)->pos))); + type_decl->flag = stmt->flag; const Var_Decl var_decl = new_var_decl(emit->gwion->mp, stmt->xid, NULL, loc_cpy(emit->gwion->mp, stmt_self(stmt)->pos)); const Var_Decl_List var_decl_list = new_var_decl_list(emit->gwion->mp, var_decl, NULL); const Exp exp = new_exp_decl(emit->gwion->mp, type_decl, var_decl_list); diff --git a/src/lib/import.c b/src/lib/import.c index acbc8f2a..03da5720 100644 --- a/src/lib/import.c +++ b/src/lib/import.c @@ -320,7 +320,8 @@ ANN2(1) m_int gwi_item_end(const Gwi gwi, const ae_flag flag, const m_uint* addr dl_var_set(gwi->gwion->mp, v, flag | ae_flag_builtin); v->var.addr = (void*)addr; if(gwi->gwion->env->class_def && GET_FLAG(gwi->gwion->env->class_def, template)) { - Type_Decl *type_decl = new_type_decl(gwi->gwion->mp, v->t.xid, flag); + Type_Decl *type_decl = new_type_decl(gwi->gwion->mp, v->t.xid); + type_decl->flag = flag; const Var_Decl var_decl = new_var_decl(gwi->gwion->mp, v->var.xid, v->var.array, loc_cpy(gwi->gwion->mp, gwi->loc)); const Var_Decl_List var_decl_list = new_var_decl_list(gwi->gwion->mp, var_decl, NULL); const Exp exp = new_exp_decl(gwi->gwion->mp, type_decl, var_decl_list); @@ -363,7 +364,7 @@ ANN Type_Decl* str2decl(const Env env, const m_str s, m_uint *depth) { m_uint i = 0; DECL_OO(m_str, type_name, = get_type_name(env, s, i++)) DECL_OO(ID_List, id, = str2list(env, type_name, depth)) - Type_Decl* td = new_type_decl(env->gwion->mp, id, 0); + Type_Decl* td = new_type_decl(env->gwion->mp, id); Type_List tmp = NULL; if(!td) { free_id_list(env->gwion->mp, id); @@ -415,7 +416,7 @@ ANN Type_Decl* import_td(const Gwi gwi, const m_str name) { const Env env = gwi->gwion->env; m_uint array_depth; DECL_OO(const ID_List, type_path, = str2list(env, name, &array_depth)) - Type_Decl* type_decl = new_type_decl(env->gwion->mp, type_path, 0); + Type_Decl* type_decl = new_type_decl(env->gwion->mp, type_path); if(!type_decl) { free_id_list(env->gwion->mp, type_path); return NULL; @@ -530,7 +531,7 @@ ANN static Stmt import_fptr(const Gwi gwi, DL_Func* dl_fun, ae_flag flag) { const Arg_List args = make_dll_arg_list(gwi, dl_fun); flag |= ae_flag_builtin; if(!(type_path = str2list(env, dl_fun->type, &array_depth)) || - !(type_decl = new_type_decl(env->gwion->mp, type_path, 0))) + !(type_decl = new_type_decl(env->gwion->mp, type_path))) GWI_ERR_O(_(" ... during fptr import '%s' (type)."), dl_fun->name); struct Func_Base_ *base = new_func_base(env->gwion->mp, type_decl, insert_symbol(env->gwion->st, dl_fun->name), args); return new_stmt_fptr(env->gwion->mp, base, flag); @@ -578,7 +579,7 @@ ANN static Exp make_exp(const Gwi gwi, const m_str type, const m_str name) { array = new_array_sub(env->gwion->mp, NULL); array->depth = array_depth; } - type_decl = new_type_decl(env->gwion->mp, id_list, 0); + type_decl = new_type_decl(env->gwion->mp, id_list); const Var_Decl var_decl = new_var_decl(env->gwion->mp, insert_symbol(env->gwion->st, name), array, loc_cpy(env->gwion->mp, gwi->loc)); const Var_Decl_List var_decl_list = new_var_decl_list(env->gwion->mp, var_decl, NULL); diff --git a/src/parse/check.c b/src/parse/check.c index 06444a7e..ac074915 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -330,7 +330,7 @@ ANN static Type_List mk_type_list(const Env env, const Type type) { id = prepend_id_list(env->gwion->mp, (Symbol)vector_at(&v, i - 1), id, new_loc(env->gwion->mp, __LINE__)); vector_release(&v); assert(id); - Type_Decl* td = new_type_decl(env->gwion->mp, id, 0); + Type_Decl* td = new_type_decl(env->gwion->mp, id); return new_type_list(env->gwion->mp, td, NULL); } diff --git a/tests/error/typeof_error.gw b/tests/error/typeof_error.gw index fcfd2054..7c727c8d 100644 --- a/tests/error/typeof_error.gw +++ b/tests/error/typeof_error.gw @@ -1 +1 @@ -~~ 1 + 2 ~~ i; \ No newline at end of file +` 1 + 2 ` i; \ No newline at end of file diff --git a/tests/import/extend_array.c b/tests/import/extend_array.c index e72c24f2..21000199 100644 --- a/tests/import/extend_array.c +++ b/tests/import/extend_array.c @@ -16,7 +16,7 @@ GWION_IMPORT(extend_array_test) { Type t_array_ext; CHECK_OB((t_array_ext = gwi_mk_type(gwi, "ArrayExt", SZ_INT, NULL))) CHECK_BB(gwi_class_ini(gwi, t_array_ext, NULL, NULL)) - Type_Decl* td = new_type_decl(gwi->gwion->st->p, new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "float"), GWI_LOC), 0); + Type_Decl* td = new_type_decl(gwi->gwion->st->p, new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "float"), GWI_LOC)); Exp e = new_exp_prim_int(gwi->gwion->st->p, 1, GWI_LOC); Array_Sub array = new_array_sub(gwi->gwion->st->p, e); add_type_decl_array(td, array); diff --git a/tests/import/extend_event.c b/tests/import/extend_event.c index 2f2cb06f..ba273475 100644 --- a/tests/import/extend_event.c +++ b/tests/import/extend_event.c @@ -18,7 +18,7 @@ GWION_IMPORT(extend_event_test) { Type t_ev ; CHECK_OB((t_ev = gwi_mk_type(gwi, "Ev", SZ_INT , NULL))) CHECK_BB(gwi_class_ini(gwi, t_ev, ev_ctor, NULL)) - Type_Decl* td = new_type_decl(gwi->gwion->st->p, new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "Event"), GWI_LOC), 0); + Type_Decl* td = new_type_decl(gwi->gwion->st->p, new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "Event"), GWI_LOC)); CHECK_BB(gwi_class_ext(gwi, td)) CHECK_BB(gwi_class_end(gwi)) return GW_OK; diff --git a/tests/import/extend_pair.c b/tests/import/extend_pair.c index 33dfae1e..02e27f91 100644 --- a/tests/import/extend_pair.c +++ b/tests/import/extend_pair.c @@ -19,9 +19,9 @@ GWION_IMPORT(extend_pair_test) { CHECK_BB(gwi_tmpl_ini(gwi, 2, types)) CHECK_BB(gwi_class_ini(gwi, t_pair_ext, NULL, NULL)) CHECK_BB(gwi_tmpl_end(gwi)) - Type_Decl* td = new_type_decl(gwi->gwion->st->p, new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "Pair"), GWI_LOC), 0); - Type_Decl* td0 = new_type_decl(gwi->gwion->st->p ,new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "A"), GWI_LOC), 0); - Type_Decl* td1 = new_type_decl(gwi->gwion->st->p ,new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "B"), GWI_LOC), 0); + Type_Decl* td = new_type_decl(gwi->gwion->st->p, new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "Pair"), GWI_LOC)); + Type_Decl* td0 = new_type_decl(gwi->gwion->st->p ,new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "A"), GWI_LOC)); + Type_Decl* td1 = new_type_decl(gwi->gwion->st->p ,new_id_list(gwi->gwion->st->p, insert_symbol(gwi->gwion->st, "B"), GWI_LOC)); Type_List tl1 = new_type_list(gwi->gwion->st->p, td1, NULL); Type_List tl0 = new_type_list(gwi->gwion->st->p,td0, tl1); td->types = tl0; diff --git a/tests/tree/decl_exp_array.gw b/tests/tree/decl_exp_array.gw index 2a9d80ae..b5049f7c 100644 --- a/tests/tree/decl_exp_array.gw +++ b/tests/tree/decl_exp_array.gw @@ -1,2 +1,2 @@ -<<<~~ new int[2] ~~ i>>>; +<<<` new int[2] ` i>>>; <<>>; \ No newline at end of file diff --git a/util b/util index 5972a5f0..106fc5bb 160000 --- a/util +++ b/util @@ -1 +1 @@ -Subproject commit 5972a5f02aeece3745389531c3eed06aa1cee33b +Subproject commit 106fc5bb87ddb51c9ce44714f23383b78c339ce7 -- 2.43.0