diff --git a/LICENSE b/LICENSE index eb2e6c8..78fbaf5 100755 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License -Copyright (C) 2011 - 2016 Wang Renxin +Copyright (C) 2011 - 2017 Wang Renxin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/MY-BASIC Quick Reference.pdf b/MY-BASIC Quick Reference.pdf index 3d715d4..5c34506 100644 Binary files a/MY-BASIC Quick Reference.pdf and b/MY-BASIC Quick Reference.pdf differ diff --git a/README.md b/README.md index 931868f..de977a1 100755 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ | ||_|| | | | | |_| || _ | _____| || | | |_ |_| |_| |___| |_______||__| |__||_______||___| |_______| -**Copyright (C) 2011 - 2016 [Wang Renxin](https://cn.linkedin.com/pub/wang-renxin/43/494/20). All rights reserved.** +**Copyright (C) 2011 - 2017 [Wang Renxin](https://cn.linkedin.com/pub/wang-renxin/43/494/20). All rights reserved.** [简体中文](https://github.com/paladin-t/my_basic/wiki/%E7%94%B1%E7%BA%AF-C-%E8%AF%AD%E8%A8%80%E7%BC%96%E5%86%99%E7%9A%84-BASIC-%E8%84%9A%E6%9C%AC%E8%A7%A3%E9%87%8A%E5%99%A8) diff --git a/core/my_basic.c b/core/my_basic.c index 6e61ee2..7654e6d 100755 --- a/core/my_basic.c +++ b/core/my_basic.c @@ -3,7 +3,7 @@ ** ** For the latest info, see https://github.com/paladin-t/my_basic/ ** -** Copyright (C) 2011 - 2016 Wang Renxin +** Copyright (C) 2011 - 2017 Wang Renxin ** ** Permission is hereby granted, free of charge, to any person obtaining a copy of ** this software and associated documentation files (the "Software"), to deal in @@ -10845,7 +10845,7 @@ static int _close_coll_lib(mb_interpreter_t* s) { */ /* Get the version number of this MY-BASIC system */ -unsigned mb_ver(void) { +unsigned long mb_ver(void) { return _MB_VERSION; } @@ -10856,9 +10856,9 @@ const char* mb_ver_string(void) { /* Initialize the MY-BASIC system */ int mb_init(void) { - int result = MB_FUNC_OK; + if(_exp_assign) + return MB_FUNC_ERR; - mb_assert(!_exp_assign); _exp_assign = _create_object(); _exp_assign->type = _DT_FUNC; _exp_assign->data.func = (_func_t*)mb_malloc(sizeof(_func_t)); @@ -10880,14 +10880,14 @@ int mb_init(void) { bvar->data->data.integer = 0; } - return result; + return MB_FUNC_OK; } /* Close the MY-BASIC system */ int mb_dispose(void) { - int result = MB_FUNC_OK; + if(!_exp_assign) + return MB_FUNC_ERR; - mb_assert(_exp_assign); safe_free(_exp_assign->data.func->name); safe_free(_exp_assign->data.func); safe_free(_exp_assign); @@ -10910,7 +10910,7 @@ int mb_dispose(void) { _OBJ_BOOL_FALSE = 0; } - return result; + return MB_FUNC_OK; } /* Open a MY-BASIC environment */ @@ -10920,7 +10920,8 @@ int mb_open(struct mb_interpreter_t** s) { _ht_node_t* global_scope = 0; _running_context_t* running = 0; - mb_assert(s); + if(!s) + return MB_FUNC_ERR; *s = (mb_interpreter_t*)mb_malloc(sizeof(mb_interpreter_t)); memset(*s, 0, sizeof(mb_interpreter_t)); @@ -10977,12 +10978,12 @@ int mb_open(struct mb_interpreter_t** s) { /* Close a MY-BASIC environment */ int mb_close(struct mb_interpreter_t** s) { - int result = MB_FUNC_OK; _ht_node_t* local_scope = 0; _ht_node_t* global_scope = 0; _ls_node_t* ast; - mb_assert(s); + if(!s || !(*s)) + return MB_FUNC_ERR; (*s)->valid = false; @@ -11042,7 +11043,7 @@ int mb_close(struct mb_interpreter_t** s) { safe_free(*s); - return result; + return MB_FUNC_OK; } /* Reset a MY-BASIC environment */ @@ -11053,7 +11054,8 @@ int mb_reset(struct mb_interpreter_t** s, bool_t clrf) { _parsing_context_t* context = 0; _running_context_t* running = 0; - mb_assert(s); + if(!s || !(*s)) + return MB_FUNC_ERR; (*s)->jump_set = _JMP_NIL; (*s)->last_routine = 0; @@ -12947,7 +12949,7 @@ _exit: return result; } -/* Operator - */ +/* Operator - (minus) */ static int _core_min(mb_interpreter_t* s, void** l) { int result = MB_FUNC_OK; diff --git a/core/my_basic.h b/core/my_basic.h index d44ab31..6eb6b7d 100755 --- a/core/my_basic.h +++ b/core/my_basic.h @@ -3,7 +3,7 @@ ** ** For the latest info, see https://github.com/paladin-t/my_basic/ ** -** Copyright (C) 2011 - 2016 Wang Renxin +** Copyright (C) 2011 - 2017 Wang Renxin ** ** Permission is hereby granted, free of charge, to any person obtaining a copy of ** this software and associated documentation files (the "Software"), to deal in @@ -551,7 +551,7 @@ typedef mb_meta_status_u (* mb_meta_func_t)(struct mb_interpreter_t*, void**, co typedef char* (* mb_memory_allocate_func_t)(unsigned); typedef void (* mb_memory_free_func_t)(char*); -MBAPI unsigned mb_ver(void); +MBAPI unsigned long mb_ver(void); MBAPI const char* mb_ver_string(void); MBAPI int mb_init(void); diff --git a/donate.html b/donate.html index f06913d..7efdceb 100644 --- a/donate.html +++ b/donate.html @@ -1,6 +1,6 @@ diff --git a/output/my_basic.exe b/output/my_basic.exe index 0ab5247..de72523 100755 Binary files a/output/my_basic.exe and b/output/my_basic.exe differ diff --git a/resource/my_basic.rc b/resource/my_basic.rc index 7198e2e..0515d24 100755 --- a/resource/my_basic.rc +++ b/resource/my_basic.rc @@ -57,7 +57,7 @@ VALUE "FileDescription", "MY-BASIC Interpreter for Windows" VALUE "FileVersion", "1, 2, 0, 0" VALUE "InternalName", "my_basic" - VALUE "LegalCopyright", "Copyright (C) 2011 - 2016 Wang Renxin" + VALUE "LegalCopyright", "Copyright (C) 2011 - 2017 Wang Renxin" VALUE "LegalTrademarks", "MY-BASIC" VALUE "OriginalFilename", "my_basic.exe" VALUE "ProductName", "MY-BASIC" diff --git a/sample/README.md b/sample/README.md index 5088ff8..637cf3c 100644 --- a/sample/README.md +++ b/sample/README.md @@ -1,6 +1,6 @@ ## Samples of MY-BASIC -**Copyright (C) 2011 - 2016 Wang Renxin. All rights reserved.** +**Copyright (C) 2011 - 2017 Wang Renxin. All rights reserved.** This folder contains severial sample code of MY-BASIC. diff --git a/sample/sample01.bas b/sample/sample01.bas index 5868e60..d39ce94 100755 --- a/sample/sample01.bas +++ b/sample/sample01.bas @@ -1,5 +1,5 @@ ' This script is an example of MY-BASIC -' Copyright (c) 2011 - 2016 Wang Renxin. All rights reserved. +' Copyright (c) 2011 - 2017 Wang Renxin. All rights reserved. ' For more information, see https://github.com/paladin-t/my_basic/ s$ = "Hello" diff --git a/sample/sample02.bas b/sample/sample02.bas index fd65963..d3e2332 100755 --- a/sample/sample02.bas +++ b/sample/sample02.bas @@ -1,5 +1,5 @@ ' This script is an example of MY-BASIC -' Copyright (c) 2011 - 2016 Wang Renxin. All rights reserved. +' Copyright (c) 2011 - 2017 Wang Renxin. All rights reserved. ' For more information, see https://github.com/paladin-t/my_basic/ e = 50 diff --git a/sample/sample03.bas b/sample/sample03.bas index 9f145f4..65cf91e 100755 --- a/sample/sample03.bas +++ b/sample/sample03.bas @@ -1,5 +1,5 @@ ' This script is an example of MY-BASIC -' Copyright (c) 2011 - 2016 Wang Renxin. All rights reserved. +' Copyright (c) 2011 - 2017 Wang Renxin. All rights reserved. ' For more information, see https://github.com/paladin-t/my_basic/ input "Input: ", ns$ diff --git a/sample/sample04.bas b/sample/sample04.bas index 2cb6654..8a0bfbd 100755 --- a/sample/sample04.bas +++ b/sample/sample04.bas @@ -1,5 +1,5 @@ ' This script is an example of MY-BASIC -' Copyright (c) 2011 - 2016 Wang Renxin. All rights reserved. +' Copyright (c) 2011 - 2017 Wang Renxin. All rights reserved. ' For more information, see https://github.com/paladin-t/my_basic/ begin: diff --git a/sample/sample05.bas b/sample/sample05.bas index e260a52..c310d20 100755 --- a/sample/sample05.bas +++ b/sample/sample05.bas @@ -1,5 +1,5 @@ ' This script is an example of MY-BASIC -' Copyright (c) 2011 - 2016 Wang Renxin. All rights reserved. +' Copyright (c) 2011 - 2017 Wang Renxin. All rights reserved. ' For more information, see https://github.com/paladin-t/my_basic/ def area(a, b) diff --git a/sample/sample06.bas b/sample/sample06.bas index 37b61cc..0ae88c3 100644 --- a/sample/sample06.bas +++ b/sample/sample06.bas @@ -1,8 +1,8 @@ ' This script is an example of MY-BASIC -' Copyright (c) 2011 - 2016 Wang Renxin. All rights reserved. +' Copyright (c) 2011 - 2017 Wang Renxin. All rights reserved. ' For more information, see https://github.com/paladin-t/my_basic/ -class animal +Class animal def speak(a) print "Default" + a; enddef diff --git a/sample/sample07.bas b/sample/sample07.bas index 9cea725..457a5c1 100644 --- a/sample/sample07.bas +++ b/sample/sample07.bas @@ -1,5 +1,5 @@ ' This script is an example of MY-BASIC -' Copyright (c) 2011 - 2016 Wang Renxin. All rights reserved. +' Copyright (c) 2011 - 2017 Wang Renxin. All rights reserved. ' For more information, see https://github.com/paladin-t/my_basic/ def reserve(m, n) diff --git a/sample/yard/README.md b/sample/yard/README.md index 1bfafa5..d9566d6 100644 --- a/sample/yard/README.md +++ b/sample/yard/README.md @@ -1,6 +1,6 @@ ## YARD (Yet Another RPG Dungeon) -**Copyright (C) 2016 Wang Renxin. All rights reserved.** +**Copyright (C) 2011 - 2017 Wang Renxin. All rights reserved.** "Yet Another RPG Dungeon" is a text based game. It's a simple comprehensive example and a tutorial which demonstrates lots of concepts of MY-BASIC. diff --git a/sample/yard/entity.bas b/sample/yard/entity.bas index 51292ef..eaf1ed7 100644 --- a/sample/yard/entity.bas +++ b/sample/yard/entity.bas @@ -1,9 +1,9 @@ ' Yet Another RPG Dungeon is a text based game. ' It's aimed to be a comprehensive example and or a tutorial of MY-BASIC. -' Copyright (C) 2016 Wang Renxin. All rights reserved. +' Copyright (C) 2011 - 2017 Wang Renxin. All rights reserved. ' For more information about MY-BASIC, see https://github.com/paladin-t/my_basic/ -class entity +Class entity var name = "" var alive = true diff --git a/sample/yard/goal.bas b/sample/yard/goal.bas index 43cf864..59049c4 100644 --- a/sample/yard/goal.bas +++ b/sample/yard/goal.bas @@ -1,6 +1,6 @@ ' Yet Another RPG Dungeon is a text based game. ' It's aimed to be a comprehensive example and or a tutorial of MY-BASIC. -' Copyright (C) 2016 Wang Renxin. All rights reserved. +' Copyright (C) 2011 - 2017 Wang Renxin. All rights reserved. ' For more information about MY-BASIC, see https://github.com/paladin-t/my_basic/ import "entity.bas" diff --git a/sample/yard/level.bas b/sample/yard/level.bas index 903fb6a..f5cb8e9 100644 --- a/sample/yard/level.bas +++ b/sample/yard/level.bas @@ -1,6 +1,6 @@ ' Yet Another RPG Dungeon is a text based game. ' It's aimed to be a comprehensive example and or a tutorial of MY-BASIC. -' Copyright (C) 2016 Wang Renxin. All rights reserved. +' Copyright (C) 2011 - 2017 Wang Renxin. All rights reserved. ' For more information about MY-BASIC, see https://github.com/paladin-t/my_basic/ import "goal.bas" diff --git a/sample/yard/map.bas b/sample/yard/map.bas index 259570c..cbb56e5 100644 --- a/sample/yard/map.bas +++ b/sample/yard/map.bas @@ -1,6 +1,6 @@ ' Yet Another RPG Dungeon is a text based game. ' It's aimed to be a comprehensive example and or a tutorial of MY-BASIC. -' Copyright (C) 2016 Wang Renxin. All rights reserved. +' Copyright (C) 2011 - 2017 Wang Renxin. All rights reserved. ' For more information about MY-BASIC, see https://github.com/paladin-t/my_basic/ import "utils.bas" diff --git a/sample/yard/monster.bas b/sample/yard/monster.bas index b03e819..1d560ba 100644 --- a/sample/yard/monster.bas +++ b/sample/yard/monster.bas @@ -1,6 +1,6 @@ ' Yet Another RPG Dungeon is a text based game. ' It's aimed to be a comprehensive example and or a tutorial of MY-BASIC. -' Copyright (C) 2016 Wang Renxin. All rights reserved. +' Copyright (C) 2011 - 2017 Wang Renxin. All rights reserved. ' For more information about MY-BASIC, see https://github.com/paladin-t/my_basic/ import "entity.bas" diff --git a/sample/yard/npc.bas b/sample/yard/npc.bas index e14b67f..0f48c42 100644 --- a/sample/yard/npc.bas +++ b/sample/yard/npc.bas @@ -1,6 +1,6 @@ ' Yet Another RPG Dungeon is a text based game. ' It's aimed to be a comprehensive example and or a tutorial of MY-BASIC. -' Copyright (C) 2016 Wang Renxin. All rights reserved. +' Copyright (C) 2011 - 2017 Wang Renxin. All rights reserved. ' For more information about MY-BASIC, see https://github.com/paladin-t/my_basic/ import "entity.bas" diff --git a/sample/yard/player.bas b/sample/yard/player.bas index 8fb3a5b..9c3e2f3 100644 --- a/sample/yard/player.bas +++ b/sample/yard/player.bas @@ -1,6 +1,6 @@ ' Yet Another RPG Dungeon is a text based game. ' It's aimed to be a comprehensive example and or a tutorial of MY-BASIC. -' Copyright (C) 2016 Wang Renxin. All rights reserved. +' Copyright (C) 2011 - 2017 Wang Renxin. All rights reserved. ' For more information about MY-BASIC, see https://github.com/paladin-t/my_basic/ import "entity.bas" diff --git a/sample/yard/start.bas b/sample/yard/start.bas index 8ad3bea..615c2eb 100644 --- a/sample/yard/start.bas +++ b/sample/yard/start.bas @@ -1,6 +1,6 @@ ' Yet Another RPG Dungeon is a text based game. ' It's aimed to be a comprehensive example and or a tutorial of MY-BASIC. -' Copyright (C) 2016 Wang Renxin. All rights reserved. +' Copyright (C) 2011 - 2017 Wang Renxin. All rights reserved. ' For more information about MY-BASIC, see https://github.com/paladin-t/my_basic/ import "level.bas" diff --git a/sample/yard/utils.bas b/sample/yard/utils.bas index 0c1bceb..4d83c49 100644 --- a/sample/yard/utils.bas +++ b/sample/yard/utils.bas @@ -1,6 +1,6 @@ ' Yet Another RPG Dungeon is a text based game. ' It's aimed to be a comprehensive example and or a tutorial of MY-BASIC. -' Copyright (C) 2016 Wang Renxin. All rights reserved. +' Copyright (C) 2011 - 2017 Wang Renxin. All rights reserved. ' For more information about MY-BASIC, see https://github.com/paladin-t/my_basic/ def cls() diff --git a/shell/main.c b/shell/main.c index 14e7209..0dc9638 100755 --- a/shell/main.c +++ b/shell/main.c @@ -3,7 +3,7 @@ ** ** For the latest info, see https://github.com/paladin-t/my_basic/ ** -** Copyright (C) 2011 - 2016 Wang Renxin +** Copyright (C) 2011 - 2017 Wang Renxin ** ** Permission is hereby granted, free of charge, to any person obtaining a copy of ** this software and associated documentation files (the "Software"), to deal in @@ -974,7 +974,7 @@ static void _list_directory(const char* path) { static void _show_tip(void) { _printf("MY-BASIC Interpreter Shell - %s\n", mb_ver_string()); - _printf("Copyright (C) 2011 - 2016 Wang Renxin. All Rights Reserved.\n"); + _printf("Copyright (C) 2011 - 2017 Wang Renxin. All Rights Reserved.\n"); _printf("For more information, see https://github.com/paladin-t/my_basic/.\n"); _printf("Input HELP and hint enter to view help information.\n"); } @@ -1451,14 +1451,14 @@ static void _on_error(struct mb_interpreter_t* s, mb_error_e e, char* m, char* f if(f) { if(e == SE_RN_WRONG_FUNCTION_REACHED) { _printf( - "Error:\n Line %d, Col %d in Func: %s\n Code %d, Abort Code %d\n Message: %s.\n", + "Error:\n Ln %d, Col %d in Func: %s\n Code %d, Abort Code %d\n Message: %s.\n", row, col, f, e, abort_code, m ); } else { _printf( - "Error:\n Line %d, Col %d in File: %s\n Code %d, Abort Code %d\n Message: %s.\n", + "Error:\n Ln %d, Col %d in File: %s\n Code %d, Abort Code %d\n Message: %s.\n", row, col, f, e, e == SE_EA_EXTENDED_ABORT ? abort_code - MB_EXTENDED_ABORT : abort_code, m @@ -1466,7 +1466,7 @@ static void _on_error(struct mb_interpreter_t* s, mb_error_e e, char* m, char* f } } else { _printf( - "Error:\n Line %d, Col %d\n Code %d, Abort Code %d\n Message: %s.\n", + "Error:\n Ln %d, Col %d\n Code %d, Abort Code %d\n Message: %s.\n", row, col, e, e == SE_EA_EXTENDED_ABORT ? abort_code - MB_EXTENDED_ABORT : abort_code, m