Compare commits

..

No commits in common. "571c3f9c0d5fe0f468875d5fa88e8951839435e2" and "281a292d9460bddd9a96e425d6e26ddf5f9f6d64" have entirely different histories.

7 changed files with 28 additions and 44 deletions

View File

@ -1,8 +1,5 @@
Jun. 28 2021
Improved error prompting of assigning to reserved word
Apr. 9 2020 Apr. 9 2020
Improved error prompting of incomplete IF structure Improved incomplete IF structure error prompting
Mar. 16 2019 Mar. 16 2019
Fixed a memory leak when reassigning an array element with string, thanks to Jacques Diederik for pointing it out Fixed a memory leak when reassigning an array element with string, thanks to Jacques Diederik for pointing it out

View File

@ -1,11 +0,0 @@
my_basic : main.o my_basic.o
i686-quinn-gcc -o output/my_basic.exe main.o my_basic.o -lm
main.o : shell/main.c core/my_basic.h
i686-quinn-gcc -Os -c shell/main.c -Wno-unused-result
my_basic.o : core/my_basic.c core/my_basic.h
i686-quinn-gcc -Os -c core/my_basic.c -Wno-multichar -Wno-overflow -Wno-unused-result
clean :
rm -f main.o my_basic.o output/my_basic_bin output/my_basic.exe

View File

@ -43,6 +43,7 @@
#endif /* MB_CP_ARDUINO */ #endif /* MB_CP_ARDUINO */
#ifdef MB_CP_VC #ifdef MB_CP_VC
# include <conio.h> # include <conio.h>
# include <locale.h>
# include <malloc.h> # include <malloc.h>
# include <Windows.h> # include <Windows.h>
#else /* MB_CP_VC */ #else /* MB_CP_VC */
@ -160,6 +161,14 @@ extern "C" {
# define _LAMBDA_NAME_MAX_LENGTH 32 # define _LAMBDA_NAME_MAX_LENGTH 32
#endif /* _LAMBDA_NAME_MAX_LENGTH */ #endif /* _LAMBDA_NAME_MAX_LENGTH */
/* Localization specifier */
#ifndef _LOCALIZATION_USEING
# define _LOCALIZATION_USEING 1
#endif /* _LOCALIZATION_USEING */
#ifndef _LOCALIZATION_STR
# define _LOCALIZATION_STR ""
#endif /* _LOCALIZATION_STR */
/* Helper */ /* Helper */
#ifdef MB_COMPACT_MODE #ifdef MB_COMPACT_MODE
# define _PACK1 : 1 # define _PACK1 : 1
@ -271,7 +280,6 @@ MBCONST static const char* const _ERR_DESC[] = {
"Too many dimensions", "Too many dimensions",
"Rank out of bound", "Rank out of bound",
"Invalid identifier usage", "Invalid identifier usage",
"Cannot assign to reserved word",
"Duplicate identifier", "Duplicate identifier",
"Incomplete structure", "Incomplete structure",
"Label not exists", "Label not exists",
@ -4880,12 +4888,18 @@ static mb_input_func_t _get_inputer(mb_interpreter_t* s) {
/* Print a string */ /* Print a string */
static void _print_string(mb_interpreter_t* s, _object_t* obj) { static void _print_string(mb_interpreter_t* s, _object_t* obj) {
#if defined MB_CP_VC && defined MB_ENABLE_UNICODE #if defined MB_CP_VC && defined MB_ENABLE_UNICODE
#if _LOCALIZATION_USEING
char* loc = 0;
#endif /* _LOCALIZATION_USEING */
char* str = 0; char* str = 0;
_dynamic_buffer_t buf; _dynamic_buffer_t buf;
size_t lbuf = 0; size_t lbuf = 0;
mb_assert(s && obj); mb_assert(s && obj);
#if _LOCALIZATION_USEING
loc = setlocale(LC_ALL, _LOCALIZATION_STR);
#endif /* _LOCALIZATION_USEING */
str = obj->data.string ? obj->data.string : MB_NULL_STRING; str = obj->data.string ? obj->data.string : MB_NULL_STRING;
_INIT_BUF(buf); _INIT_BUF(buf);
while((lbuf = (size_t)mb_bytes_to_wchar(str, &_WCHAR_BUF_PTR(buf), _WCHARS_OF_BUF(buf))) > _WCHARS_OF_BUF(buf)) { while((lbuf = (size_t)mb_bytes_to_wchar(str, &_WCHAR_BUF_PTR(buf), _WCHARS_OF_BUF(buf))) > _WCHARS_OF_BUF(buf)) {
@ -4893,6 +4907,9 @@ static void _print_string(mb_interpreter_t* s, _object_t* obj) {
} }
_get_printer(s)("%ls", _WCHAR_BUF_PTR(buf)); _get_printer(s)("%ls", _WCHAR_BUF_PTR(buf));
_DISPOSE_BUF(buf); _DISPOSE_BUF(buf);
#if _LOCALIZATION_USEING
setlocale(LC_ALL, loc);
#endif /* _LOCALIZATION_USEING */
#else /* MB_CP_VC && MB_ENABLE_UNICODE */ #else /* MB_CP_VC && MB_ENABLE_UNICODE */
mb_assert(s && obj); mb_assert(s && obj);
@ -15427,7 +15444,7 @@ static int _core_let(mb_interpreter_t* s, void** l) {
goto _exit; goto _exit;
} else if(obj->type == _DT_VAR) { } else if(obj->type == _DT_VAR) {
if(_IS_ME(obj->data.variable)) { if(_IS_ME(obj->data.variable)) {
_handle_error_on_obj(s, SE_RN_CANNOT_ASSIGN_TO_RESERVED_WORD, s->source_file, DON(ast), MB_FUNC_ERR, _exit, result); _handle_error_on_obj(s, SE_RN_INVALID_ID_USAGE, s->source_file, DON(ast), MB_FUNC_ERR, _exit, result);
} else { } else {
evar = obj->data.variable; evar = obj->data.variable;
var = _search_var_in_scope_chain(s, obj->data.variable, 0); var = _search_var_in_scope_chain(s, obj->data.variable, 0);
@ -15436,11 +15453,11 @@ static int _core_let(mb_interpreter_t* s, void** l) {
if(evar && evar->pathing == _PATHING_UPVALUE) evar = 0; if(evar && evar->pathing == _PATHING_UPVALUE) evar = 0;
#endif /* MB_ENABLE_CLASS */ #endif /* MB_ENABLE_CLASS */
if(var == _OBJ_BOOL_TRUE->data.variable || var == _OBJ_BOOL_FALSE->data.variable) { if(var == _OBJ_BOOL_TRUE->data.variable || var == _OBJ_BOOL_FALSE->data.variable) {
_handle_error_on_obj(s, SE_RN_CANNOT_ASSIGN_TO_RESERVED_WORD, s->source_file, DON(ast), MB_FUNC_ERR, _exit, result); _handle_error_on_obj(s, SE_RN_INVALID_ID_USAGE, s->source_file, DON(ast), MB_FUNC_ERR, _exit, result);
} }
} }
} else { } else {
_handle_error_on_obj(s, SE_RN_CANNOT_ASSIGN_TO_RESERVED_WORD, s->source_file, DON(ast), MB_FUNC_ERR, _exit, result); _handle_error_on_obj(s, SE_RN_INVALID_ID_USAGE, s->source_file, DON(ast), MB_FUNC_ERR, _exit, result);
} }
ast = ast->next; ast = ast->next;
@ -17752,12 +17769,6 @@ static int _std_str(mb_interpreter_t* s, void** l) {
#endif /* MB_MANUAL_REAL_FORMATTING */ #endif /* MB_MANUAL_REAL_FORMATTING */
break; break;
case MB_DT_STRING: {
char* ret = mb_strdup(arg.value.string, strlen(arg.value.string) + 1);
mb_check(mb_push_string(s, l, ret));
goto _exit;
}
case MB_DT_TYPE: { case MB_DT_TYPE: {
const char* sp = mb_get_type_string(arg.value.type); const char* sp = mb_get_type_string(arg.value.type);
char* ret = mb_strdup(sp, strlen(sp) + 1); char* ret = mb_strdup(sp, strlen(sp) + 1);

View File

@ -86,8 +86,6 @@ extern "C" {
# define MB_OS_ANDROID # define MB_OS_ANDROID
#elif defined __linux__ #elif defined __linux__
# define MB_OS_LINUX # define MB_OS_LINUX
#elif defined __quinn__
# define MB_OS_QUINN
#elif defined __unix__ #elif defined __unix__
# define MB_OS_UNIX # define MB_OS_UNIX
#else #else
@ -427,7 +425,6 @@ typedef enum mb_error_e {
SE_RN_TOO_MANY_DIMENSIONS, SE_RN_TOO_MANY_DIMENSIONS,
SE_RN_RANK_OUT_OF_BOUND, SE_RN_RANK_OUT_OF_BOUND,
SE_RN_INVALID_ID_USAGE, SE_RN_INVALID_ID_USAGE,
SE_RN_CANNOT_ASSIGN_TO_RESERVED_WORD,
SE_RN_DUPLICATE_ID, SE_RN_DUPLICATE_ID,
SE_RN_INCOMPLETE_STRUCTURE, SE_RN_INCOMPLETE_STRUCTURE,
SE_RN_LABEL_NOT_EXISTS, SE_RN_LABEL_NOT_EXISTS,

View File

@ -55,8 +55,6 @@ LIST OF DONORS.
</p> </p>
<p> <p>
<ul type="none"> <ul type="none">
<li>Otero Fernandez Juan</li>
<li>Jonathan Verbeek</li>
<li>Carlin Wiegner</li> <li>Carlin Wiegner</li>
<li>Ken Seergobin</li> <li>Ken Seergobin</li>
<li>Francesco De Simone</li> <li>Francesco De Simone</li>

BIN
output/my_basic.exe Executable file

Binary file not shown.

View File

@ -33,6 +33,7 @@
#ifdef MB_CP_VC #ifdef MB_CP_VC
# include <conio.h> # include <conio.h>
# include <crtdbg.h> # include <crtdbg.h>
# include <locale.h>
# include <Windows.h> # include <Windows.h>
#elif !defined MB_CP_BORLANDC && !defined MB_CP_TCC #elif !defined MB_CP_BORLANDC && !defined MB_CP_TCC
# include <unistd.h> # include <unistd.h>
@ -47,7 +48,6 @@
# include <sys/time.h> # include <sys/time.h>
#endif /* MB_CP_CLANG */ #endif /* MB_CP_CLANG */
#include <assert.h> #include <assert.h>
#include <locale.h>
#include <setjmp.h> #include <setjmp.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
@ -84,8 +84,6 @@ extern "C" {
# define _BIN_FILE_NAME "my_basic" # define _BIN_FILE_NAME "my_basic"
#elif defined MB_OS_MAC #elif defined MB_OS_MAC
# define _BIN_FILE_NAME "my_basic_mac" # define _BIN_FILE_NAME "my_basic_mac"
#elif defined MB_OS_QUINN
# define _BIN_FILE_NAME "my_basic.exe"
#else #else
# define _BIN_FILE_NAME "my_basic_bin" # define _BIN_FILE_NAME "my_basic_bin"
#endif #endif
@ -786,10 +784,12 @@ static void _list_one_line(bool_t nl, long l, const char* ln) {
#if defined MB_CP_VC && defined MB_ENABLE_UNICODE #if defined MB_CP_VC && defined MB_ENABLE_UNICODE
wchar_t wstr[16]; wchar_t wstr[16];
wchar_t* wstrp = wstr; wchar_t* wstrp = wstr;
char* loc = setlocale(LC_ALL, "");
_bytes_to_wchar(ln, &wstrp, countof(wstr)); _bytes_to_wchar(ln, &wstrp, countof(wstr));
_printf(nl ? "%ld]%ls\n" : "%ld]%ls", l, wstrp); _printf(nl ? "%ld]%ls\n" : "%ld]%ls", l, wstrp);
if(wstrp != wstr) if(wstrp != wstr)
free(wstrp); free(wstrp);
setlocale(LC_ALL, loc);
#else /* MB_CP_VC && MB_ENABLE_UNICODE */ #else /* MB_CP_VC && MB_ENABLE_UNICODE */
_printf(nl ? "%ld]%s\n" : "%ld]%s", l, ln); _printf(nl ? "%ld]%s\n" : "%ld]%s", l, ln);
#endif /* MB_CP_VC && MB_ENABLE_UNICODE */ #endif /* MB_CP_VC && MB_ENABLE_UNICODE */
@ -1218,9 +1218,7 @@ static bool_t _process_parameters(int argc, char* argv[]) {
** Scripting interfaces ** Scripting interfaces
*/ */
#if defined MB_OS_HTML #ifdef MB_OS_WIN
# define _OS "HTML"
#elif defined MB_OS_WIN
# define _OS "WINDOWS" # define _OS "WINDOWS"
#elif defined MB_OS_IOS || MB_OS_IOS_SIM #elif defined MB_OS_IOS || MB_OS_IOS_SIM
# define _OS "IOS" # define _OS "IOS"
@ -1232,8 +1230,6 @@ static bool_t _process_parameters(int argc, char* argv[]) {
# define _OS "LINUX" # define _OS "LINUX"
#elif defined MB_OS_UNIX #elif defined MB_OS_UNIX
# define _OS "UNIX" # define _OS "UNIX"
#elif defined MB_OS_QUINN
# define _OS "QUINN"
#else #else
# define _OS "UNKNOWN" # define _OS "UNKNOWN"
#endif /* MB_OS_WIN */ #endif /* MB_OS_WIN */
@ -1252,7 +1248,7 @@ static int_t _ticks(void) {
return ret; return ret;
} }
#elif defined MB_CP_CLANG || defined MB_OS_QUINN #elif defined MB_CP_CLANG
static int_t _ticks(void) { static int_t _ticks(void) {
struct timespec ts; struct timespec ts;
struct timeval now; struct timeval now;
@ -1516,10 +1512,6 @@ static void _on_startup(void) {
srand((unsigned)_ticks()); srand((unsigned)_ticks());
#endif /* _HAS_TICKS */ #endif /* _HAS_TICKS */
setlocale(LC_ALL, "");
setlocale(LC_NUMERIC, "C");
setlocale(LC_TIME, "C");
mb_init(); mb_init();
mb_open(&bas); mb_open(&bas);