*changed the return type of mb_ver;

*polished.
This commit is contained in:
Wang Renxin 2016-12-31 17:38:45 +08:00
parent 57d5a3175e
commit f362d0adb3
27 changed files with 47 additions and 45 deletions

View File

@ -1,6 +1,6 @@
The MIT License 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 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 this software and associated documentation files (the "Software"), to deal in

Binary file not shown.

View File

@ -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) [简体中文](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)

View File

@ -3,7 +3,7 @@
** **
** For the latest info, see https://github.com/paladin-t/my_basic/ ** 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 ** 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 ** 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 */ /* Get the version number of this MY-BASIC system */
unsigned mb_ver(void) { unsigned long mb_ver(void) {
return _MB_VERSION; return _MB_VERSION;
} }
@ -10856,9 +10856,9 @@ const char* mb_ver_string(void) {
/* Initialize the MY-BASIC system */ /* Initialize the MY-BASIC system */
int mb_init(void) { 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 = _create_object();
_exp_assign->type = _DT_FUNC; _exp_assign->type = _DT_FUNC;
_exp_assign->data.func = (_func_t*)mb_malloc(sizeof(_func_t)); _exp_assign->data.func = (_func_t*)mb_malloc(sizeof(_func_t));
@ -10880,14 +10880,14 @@ int mb_init(void) {
bvar->data->data.integer = 0; bvar->data->data.integer = 0;
} }
return result; return MB_FUNC_OK;
} }
/* Close the MY-BASIC system */ /* Close the MY-BASIC system */
int mb_dispose(void) { 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->name);
safe_free(_exp_assign->data.func); safe_free(_exp_assign->data.func);
safe_free(_exp_assign); safe_free(_exp_assign);
@ -10910,7 +10910,7 @@ int mb_dispose(void) {
_OBJ_BOOL_FALSE = 0; _OBJ_BOOL_FALSE = 0;
} }
return result; return MB_FUNC_OK;
} }
/* Open a MY-BASIC environment */ /* Open a MY-BASIC environment */
@ -10920,7 +10920,8 @@ int mb_open(struct mb_interpreter_t** s) {
_ht_node_t* global_scope = 0; _ht_node_t* global_scope = 0;
_running_context_t* running = 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)); *s = (mb_interpreter_t*)mb_malloc(sizeof(mb_interpreter_t));
memset(*s, 0, 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 */ /* Close a MY-BASIC environment */
int mb_close(struct mb_interpreter_t** s) { int mb_close(struct mb_interpreter_t** s) {
int result = MB_FUNC_OK;
_ht_node_t* local_scope = 0; _ht_node_t* local_scope = 0;
_ht_node_t* global_scope = 0; _ht_node_t* global_scope = 0;
_ls_node_t* ast; _ls_node_t* ast;
mb_assert(s); if(!s || !(*s))
return MB_FUNC_ERR;
(*s)->valid = false; (*s)->valid = false;
@ -11042,7 +11043,7 @@ int mb_close(struct mb_interpreter_t** s) {
safe_free(*s); safe_free(*s);
return result; return MB_FUNC_OK;
} }
/* Reset a MY-BASIC environment */ /* 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; _parsing_context_t* context = 0;
_running_context_t* running = 0; _running_context_t* running = 0;
mb_assert(s); if(!s || !(*s))
return MB_FUNC_ERR;
(*s)->jump_set = _JMP_NIL; (*s)->jump_set = _JMP_NIL;
(*s)->last_routine = 0; (*s)->last_routine = 0;
@ -12947,7 +12949,7 @@ _exit:
return result; return result;
} }
/* Operator - */ /* Operator - (minus) */
static int _core_min(mb_interpreter_t* s, void** l) { static int _core_min(mb_interpreter_t* s, void** l) {
int result = MB_FUNC_OK; int result = MB_FUNC_OK;

View File

@ -3,7 +3,7 @@
** **
** For the latest info, see https://github.com/paladin-t/my_basic/ ** 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 ** 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 ** 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 char* (* mb_memory_allocate_func_t)(unsigned);
typedef void (* mb_memory_free_func_t)(char*); 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 const char* mb_ver_string(void);
MBAPI int mb_init(void); MBAPI int mb_init(void);

View File

@ -1,6 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- <!--
COPYRIGHT 2016 WANG RENXIN. ALL RIGHTS REESERVED. COPYRIGHT 2011 - 2017 WANG RENXIN. ALL RIGHTS REESERVED.
THIS PAGE IS NOT OPEN SOURCE LICENSED. THIS PAGE IS NOT OPEN SOURCE LICENSED.
DO NOT CHANGE THIS FILE. DO NOT CHANGE THIS FILE.
--> -->

Binary file not shown.

View File

@ -57,7 +57,7 @@
VALUE "FileDescription", "MY-BASIC Interpreter for Windows" VALUE "FileDescription", "MY-BASIC Interpreter for Windows"
VALUE "FileVersion", "1, 2, 0, 0" VALUE "FileVersion", "1, 2, 0, 0"
VALUE "InternalName", "my_basic" 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 "LegalTrademarks", "MY-BASIC"
VALUE "OriginalFilename", "my_basic.exe" VALUE "OriginalFilename", "my_basic.exe"
VALUE "ProductName", "MY-BASIC" VALUE "ProductName", "MY-BASIC"

View File

@ -1,6 +1,6 @@
## Samples of MY-BASIC ## 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. This folder contains severial sample code of MY-BASIC.

View File

@ -1,5 +1,5 @@
' This script is an example of MY-BASIC ' 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/ ' For more information, see https://github.com/paladin-t/my_basic/
s$ = "Hello" s$ = "Hello"

View File

@ -1,5 +1,5 @@
' This script is an example of MY-BASIC ' 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/ ' For more information, see https://github.com/paladin-t/my_basic/
e = 50 e = 50

View File

@ -1,5 +1,5 @@
' This script is an example of MY-BASIC ' 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/ ' For more information, see https://github.com/paladin-t/my_basic/
input "Input: ", ns$ input "Input: ", ns$

View File

@ -1,5 +1,5 @@
' This script is an example of MY-BASIC ' 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/ ' For more information, see https://github.com/paladin-t/my_basic/
begin: begin:

View File

@ -1,5 +1,5 @@
' This script is an example of MY-BASIC ' 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/ ' For more information, see https://github.com/paladin-t/my_basic/
def area(a, b) def area(a, b)

View File

@ -1,8 +1,8 @@
' This script is an example of MY-BASIC ' 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/ ' For more information, see https://github.com/paladin-t/my_basic/
class animal Class animal
def speak(a) def speak(a)
print "Default" + a; print "Default" + a;
enddef enddef

View File

@ -1,5 +1,5 @@
' This script is an example of MY-BASIC ' 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/ ' For more information, see https://github.com/paladin-t/my_basic/
def reserve(m, n) def reserve(m, n)

View File

@ -1,6 +1,6 @@
## YARD (Yet Another RPG Dungeon) ## 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. "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.

View File

@ -1,9 +1,9 @@
' Yet Another RPG Dungeon is a text based game. ' Yet Another RPG Dungeon is a text based game.
' It's aimed to be a comprehensive example and or a tutorial of MY-BASIC. ' 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/ ' For more information about MY-BASIC, see https://github.com/paladin-t/my_basic/
class entity Class entity
var name = "" var name = ""
var alive = true var alive = true

View File

@ -1,6 +1,6 @@
' Yet Another RPG Dungeon is a text based game. ' Yet Another RPG Dungeon is a text based game.
' It's aimed to be a comprehensive example and or a tutorial of MY-BASIC. ' 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/ ' For more information about MY-BASIC, see https://github.com/paladin-t/my_basic/
import "entity.bas" import "entity.bas"

View File

@ -1,6 +1,6 @@
' Yet Another RPG Dungeon is a text based game. ' Yet Another RPG Dungeon is a text based game.
' It's aimed to be a comprehensive example and or a tutorial of MY-BASIC. ' 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/ ' For more information about MY-BASIC, see https://github.com/paladin-t/my_basic/
import "goal.bas" import "goal.bas"

View File

@ -1,6 +1,6 @@
' Yet Another RPG Dungeon is a text based game. ' Yet Another RPG Dungeon is a text based game.
' It's aimed to be a comprehensive example and or a tutorial of MY-BASIC. ' 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/ ' For more information about MY-BASIC, see https://github.com/paladin-t/my_basic/
import "utils.bas" import "utils.bas"

View File

@ -1,6 +1,6 @@
' Yet Another RPG Dungeon is a text based game. ' Yet Another RPG Dungeon is a text based game.
' It's aimed to be a comprehensive example and or a tutorial of MY-BASIC. ' 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/ ' For more information about MY-BASIC, see https://github.com/paladin-t/my_basic/
import "entity.bas" import "entity.bas"

View File

@ -1,6 +1,6 @@
' Yet Another RPG Dungeon is a text based game. ' Yet Another RPG Dungeon is a text based game.
' It's aimed to be a comprehensive example and or a tutorial of MY-BASIC. ' 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/ ' For more information about MY-BASIC, see https://github.com/paladin-t/my_basic/
import "entity.bas" import "entity.bas"

View File

@ -1,6 +1,6 @@
' Yet Another RPG Dungeon is a text based game. ' Yet Another RPG Dungeon is a text based game.
' It's aimed to be a comprehensive example and or a tutorial of MY-BASIC. ' 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/ ' For more information about MY-BASIC, see https://github.com/paladin-t/my_basic/
import "entity.bas" import "entity.bas"

View File

@ -1,6 +1,6 @@
' Yet Another RPG Dungeon is a text based game. ' Yet Another RPG Dungeon is a text based game.
' It's aimed to be a comprehensive example and or a tutorial of MY-BASIC. ' 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/ ' For more information about MY-BASIC, see https://github.com/paladin-t/my_basic/
import "level.bas" import "level.bas"

View File

@ -1,6 +1,6 @@
' Yet Another RPG Dungeon is a text based game. ' Yet Another RPG Dungeon is a text based game.
' It's aimed to be a comprehensive example and or a tutorial of MY-BASIC. ' 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/ ' For more information about MY-BASIC, see https://github.com/paladin-t/my_basic/
def cls() def cls()

View File

@ -3,7 +3,7 @@
** **
** For the latest info, see https://github.com/paladin-t/my_basic/ ** 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 ** 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 ** 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) { static void _show_tip(void) {
_printf("MY-BASIC Interpreter Shell - %s\n", mb_ver_string()); _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("For more information, see https://github.com/paladin-t/my_basic/.\n");
_printf("Input HELP and hint enter to view help information.\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(f) {
if(e == SE_RN_WRONG_FUNCTION_REACHED) { if(e == SE_RN_WRONG_FUNCTION_REACHED) {
_printf( _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, row, col, f,
e, abort_code, e, abort_code,
m m
); );
} else { } else {
_printf( _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, row, col, f,
e, e == SE_EA_EXTENDED_ABORT ? abort_code - MB_EXTENDED_ABORT : abort_code, e, e == SE_EA_EXTENDED_ABORT ? abort_code - MB_EXTENDED_ABORT : abort_code,
m m
@ -1466,7 +1466,7 @@ static void _on_error(struct mb_interpreter_t* s, mb_error_e e, char* m, char* f
} }
} else { } else {
_printf( _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, row, col,
e, e == SE_EA_EXTENDED_ABORT ? abort_code - MB_EXTENDED_ABORT : abort_code, e, e == SE_EA_EXTENDED_ABORT ? abort_code - MB_EXTENDED_ABORT : abort_code,
m m