Compare commits

...

10 Commits

Author SHA1 Message Date
Andrew Pamment
571c3f9c0d Updates for quinn 2021-12-12 12:00:24 +10:00
Wang Renxin
82a3acfcce #43 *Clarified error of assigning to reserved words. 2021-06-28 10:01:47 +08:00
Wang Renxin
789019fb4a *fixed a compiling issue. 2021-03-12 14:07:02 +08:00
Wang Renxin
dbd7acdc9d #41 *Fixed a locale issue. 2021-03-12 13:46:00 +08:00
Wang Renxin
1094cadc55 *refactored str(...). 2021-03-09 13:42:18 +08:00
Tony Wang
e5536eb091
Merge pull request #39 from iUltimateLP/master
Added handling of strings in STR() too
2021-03-09 13:39:06 +08:00
Johnny
255eb52602
Added handling of strings in STR() too 2021-03-08 17:55:48 +01:00
Wang Renxin
5de031245d +added an "HTML" return value to the os() function. 2021-03-02 14:06:38 +08:00
Wang Renxin
08b30667e1 *updated the donors list. 2021-02-27 20:57:19 +08:00
Wang Renxin
ea5df60d17 *updated the donors list. 2021-02-18 12:18:50 +08:00
7 changed files with 44 additions and 28 deletions

View File

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

11
Makefile.quinn Executable file
View File

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

View File

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

View File

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

Binary file not shown.

View File

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