From ac0f2ba85e47b527813cd9127ccc5b075d5bc90e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Tue, 24 Oct 2023 04:29:01 +0200 Subject: [PATCH] Make "%>" a keyword for syntax analyze of gambas code embedded into a WebPage. Some other fixes in the interpreter and the compiler. [INTERPRETER] * BUG: A global class find does now a global class lookup. It seems more logical. * BUG: When loading a class fails, display an accurate error message. [COMPILER] * BUG: Embedded arrays do not raise warnings on being uninitialized anymore. * NEW: Make "%>" a keyword for syntax analyze of gambas code embedded into a WebPage. --- main/gbc/gbc_class.c | 9 +++++++++ main/gbx/gbx_class.c | 7 ++++++- main/gbx/gbx_class_load.c | 2 +- main/share/gb_reserved_keyword.h | 1 + main/share/gb_reserved_temp.h | 1 + 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/main/gbc/gbc_class.c b/main/gbc/gbc_class.c index 46654f105..baff159ac 100644 --- a/main/gbc/gbc_class.c +++ b/main/gbc/gbc_class.c @@ -731,7 +731,16 @@ void CLASS_init_global_declaration(CLASS *class, TRANS_DECL *decl, CLASS_SYMBOL bool is_static; if (!TRANS_has_init_var(decl)) + { + if (decl->is_embedded) + { + if (sym->local.value) + sym->local_assigned = TRUE; + else + sym->global_assigned = TRUE; + } return; + } is_static = TYPE_is_static(decl->type); prev_func = CLASS_set_current_init_function(class, is_static ? FUNC_INIT_STATIC : FUNC_INIT_DYNAMIC); diff --git a/main/gbx/gbx_class.c b/main/gbx/gbx_class.c index 0a4fb64ba..09ae54830 100644 --- a/main/gbx/gbx_class.c +++ b/main/gbx/gbx_class.c @@ -518,9 +518,14 @@ CLASS *CLASS_find_do(const char *name, bool global) fprintf(stderr, "CLASS_find: %s (%d)\n", name, global); #endif - class = CLASS_look(name, len); + class = CLASS_look_do(name, len, global); if (class) + { + #if DEBUG_LOAD + fprintf(stderr, "--> %p\n", class); + #endif return class; + } //if (CP && CP->component && CP->component->archive) if (!global && !ARCHIVE_get_current(&arch)) diff --git a/main/gbx/gbx_class_load.c b/main/gbx/gbx_class_load.c index 830f8a86e..32bcd0720 100644 --- a/main/gbx/gbx_class_load.c +++ b/main/gbx/gbx_class_load.c @@ -1047,7 +1047,7 @@ static void load_without_inits(CLASS *class) CATCH { COMPONENT_current = save; - THROW_CLASS(class, ERROR_last.msg, ""); + THROW_CLASS(class, ERROR_current->info.msg, ""); } END_TRY } diff --git a/main/share/gb_reserved_keyword.h b/main/share/gb_reserved_keyword.h index 29235ea00..5b6f7141e 100644 --- a/main/share/gb_reserved_keyword.h +++ b/main/share/gb_reserved_keyword.h @@ -225,6 +225,7 @@ COMP_INFO COMP_res_info[] = { "&=", RSF_ASGN, RS_AMP }, { "&/=", RSF_ASGN, RS_FILE }, { "^=", RSF_ASGN, RS_FLEX }, + { "%>" }, // Webpage delimiter { NULL } }; diff --git a/main/share/gb_reserved_temp.h b/main/share/gb_reserved_temp.h index f4d702084..bc205fe5d 100644 --- a/main/share/gb_reserved_temp.h +++ b/main/share/gb_reserved_temp.h @@ -184,6 +184,7 @@ __24: return -1; __25: if (len == 2 && word[1] == '=') return 190; + if (len == 2 && word[1] == '>') return 194; return -1; __26: if (len == 2 && word[1] == '/') return 151;