+added some error raising when met incomplete routine or class.

This commit is contained in:
paladin-t 2016-04-15 14:01:04 +08:00
parent 8eaf8c1d43
commit b1345f2305
5 changed files with 27 additions and 3 deletions

View File

@ -1,3 +1,6 @@
Apr. 15 2016
Added some error raising when met incomplete routine or class
Apr. 13 2016
Fixed a negative calculation issue with brackets

View File

@ -31,7 +31,7 @@ MY-BASIC is a lightweight cross-platform easy extendable BASIC interpreter writt
## Compatibility
It fits well with Workstation, PC, Tablet, Pad, Mobile Phone, PDA, Video Game Console, Raspberry Pi, Intel Edison, Arduino and even MCU; totally portable to Windows, OS X, Unix, Linux, iOS, Android, RTOS, etc.
It fits well with Workstation, PC, Tablet, Pad, Mobile Phone, PDA, Video Game Console, Raspberry Pi, Intel Edison, Arduino and even MCU; totally portable to Windows, MacOS, Unix, Linux, iOS, Android, RTOS, etc.
## Main features
@ -91,10 +91,10 @@ More detail are issued in the [Wiki](https://github.com/paladin-t/my_basic/wiki)
### Use standalone interpreter binary
This repository contains precompiled binaries for [Windows](output/my_basic.exe) and [OS X](output/my_basic_mac), it's efficient to download it and have a first impressive playground. Or you could make a build as follow:
This repository contains precompiled binaries for [Windows](output/my_basic.exe) and [MacOS](output/my_basic_mac), it's efficient to download it and have a first impressive playground. Or you could make a build as follow:
* Open the Visual Studio solution `my_basic.sln` on Windows to build an executable
* Open the Xcode solution `my_basic_mac.xcodeproj` on OS X to build an OS X executable
* Open the Xcode solution `my_basic_mac.xcodeproj` on MacOS to build an MacOS executable
* If you were using a *nix OS, then use the `makefile` with a "make" toolchain to build an interpreter binary according to your specific platform
To compile an interpreter binary for your own platform manually, please follow the steps:

View File

@ -265,9 +265,11 @@ static const char* _ERR_DESC[] = {
"Don't suspend in a routine",
"Don't mix instructional and structured sub routines",
"Invalid routine",
"Incomplete routine",
"Routine expected",
"Duplicate routine",
"Invalid class",
"Incomplete class",
"Class expected",
"Duplicate class",
"Wrong meta class",
@ -11854,6 +11856,23 @@ int mb_run(struct mb_interpreter_t* s) {
mb_assert(s);
if(s->parsing_context) {
if(s->parsing_context->routine_state) {
result = MB_FUNC_ERR;
_handle_error_now(s, SE_RN_INCOMPLETE_ROUTINE, s->source_file, MB_FUNC_ERR);
goto _exit;
}
#ifdef MB_ENABLE_CLASS
if(s->parsing_context->class_state != _CLASS_STATE_NONE) {
result = MB_FUNC_ERR;
_handle_error_now(s, SE_RN_INCOMPLETE_CLASS, s->source_file, MB_FUNC_ERR);
goto _exit;
}
#endif /* MB_ENABLE_CLASS */
}
_destroy_parsing_context(&s->parsing_context);
s->handled_error = false;

View File

@ -391,9 +391,11 @@ typedef enum mb_error_e {
SE_RN_DONT_SUSPEND_IN_A_ROUTINE,
SE_RN_DONT_MIX_INSTRUCTIONAL_AND_STRUCTURED,
SE_RN_INVALID_ROUTINE,
SE_RN_INCOMPLETE_ROUTINE,
SE_RN_ROUTINE_EXPECTED,
SE_RN_DUPLICATE_ROUTINE,
SE_RN_INVALID_CLASS,
SE_RN_INCOMPLETE_CLASS,
SE_RN_CLASS_EXPECTED,
SE_RN_DUPLICATE_CLASS,
SE_RN_WRONG_META_CLASS,

Binary file not shown.