*fixed a wrong token position marking issue with interactive mode
This commit is contained in:
parent
8d50fa5f83
commit
424f394432
3
HISTORY
3
HISTORY
@ -1,3 +1,6 @@
|
|||||||
|
Jun. 15 2015
|
||||||
|
Fixed a wrong token position marking issue with interactive mode, thanks to Daniel Haensse for pointing it out
|
||||||
|
|
||||||
May. 6 2015
|
May. 6 2015
|
||||||
Removed redundant EOS tokens
|
Removed redundant EOS tokens
|
||||||
Polished data precision related macros
|
Polished data precision related macros
|
||||||
|
@ -78,7 +78,7 @@ extern "C" {
|
|||||||
/** Macros */
|
/** Macros */
|
||||||
#define _VER_MAJOR 1
|
#define _VER_MAJOR 1
|
||||||
#define _VER_MINOR 1
|
#define _VER_MINOR 1
|
||||||
#define _VER_REVISION 54
|
#define _VER_REVISION 55
|
||||||
#define _MB_VERSION ((_VER_MAJOR * 0x01000000) + (_VER_MINOR * 0x00010000) + (_VER_REVISION))
|
#define _MB_VERSION ((_VER_MAJOR * 0x01000000) + (_VER_MINOR * 0x00010000) + (_VER_REVISION))
|
||||||
|
|
||||||
/* Uncomment this line to treat warnings as error */
|
/* Uncomment this line to treat warnings as error */
|
||||||
@ -307,6 +307,9 @@ typedef struct _parsing_context_t {
|
|||||||
_object_t* last_symbol;
|
_object_t* last_symbol;
|
||||||
_parsing_state_e parsing_state;
|
_parsing_state_e parsing_state;
|
||||||
_symbol_state_e symbol_state;
|
_symbol_state_e symbol_state;
|
||||||
|
int parsing_pos;
|
||||||
|
unsigned short parsing_row;
|
||||||
|
unsigned short parsing_col;
|
||||||
} _parsing_context_t;
|
} _parsing_context_t;
|
||||||
|
|
||||||
/* Running context */
|
/* Running context */
|
||||||
@ -3314,6 +3317,7 @@ int mb_open(struct mb_interpreter_t** s) {
|
|||||||
|
|
||||||
context = (_parsing_context_t*)mb_malloc(sizeof(_parsing_context_t));
|
context = (_parsing_context_t*)mb_malloc(sizeof(_parsing_context_t));
|
||||||
memset(context, 0, sizeof(_parsing_context_t));
|
memset(context, 0, sizeof(_parsing_context_t));
|
||||||
|
context->parsing_row = 1;
|
||||||
(*s)->parsing_context = context;
|
(*s)->parsing_context = context;
|
||||||
|
|
||||||
running = (_running_context_t*)mb_malloc(sizeof(_running_context_t));
|
running = (_running_context_t*)mb_malloc(sizeof(_running_context_t));
|
||||||
@ -3413,6 +3417,7 @@ int mb_reset(struct mb_interpreter_t** s, bool_t clrf/* = false*/) {
|
|||||||
(*s)->parsing_context = context;
|
(*s)->parsing_context = context;
|
||||||
}
|
}
|
||||||
memset(context, 0, sizeof(_parsing_context_t));
|
memset(context, 0, sizeof(_parsing_context_t));
|
||||||
|
context->parsing_row = 1;
|
||||||
|
|
||||||
ast = (*s)->ast;
|
ast = (*s)->ast;
|
||||||
_ls_foreach(ast, _destroy_object);
|
_ls_foreach(ast, _destroy_object);
|
||||||
@ -3799,8 +3804,6 @@ int mb_load_string(struct mb_interpreter_t* s, const char* l) {
|
|||||||
char ch = 0;
|
char ch = 0;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
unsigned short row = 1;
|
|
||||||
unsigned short col = 0;
|
|
||||||
unsigned short _row = 0;
|
unsigned short _row = 0;
|
||||||
unsigned short _col = 0;
|
unsigned short _col = 0;
|
||||||
char wrapped = '\0';
|
char wrapped = '\0';
|
||||||
@ -3814,16 +3817,16 @@ int mb_load_string(struct mb_interpreter_t* s, const char* l) {
|
|||||||
ch = l[i];
|
ch = l[i];
|
||||||
if((ch == '\n' || ch == '\r') && (!wrapped || wrapped == ch)) {
|
if((ch == '\n' || ch == '\r') && (!wrapped || wrapped == ch)) {
|
||||||
wrapped = ch;
|
wrapped = ch;
|
||||||
++row;
|
++context->parsing_row;
|
||||||
col = 0;
|
context->parsing_col = 0;
|
||||||
} else {
|
} else {
|
||||||
wrapped = '\0';
|
wrapped = '\0';
|
||||||
++col;
|
++context->parsing_col;
|
||||||
}
|
}
|
||||||
status = _parse_char(s, ch, i, _row, _col);
|
status = _parse_char(s, ch, context->parsing_pos, _row, _col);
|
||||||
result = status;
|
result = status;
|
||||||
if(status) {
|
if(status) {
|
||||||
_set_error_pos(s, i, _row, _col);
|
_set_error_pos(s, context->parsing_pos, _row, _col);
|
||||||
if(s->error_handler) {
|
if(s->error_handler) {
|
||||||
(s->error_handler)(s, s->last_error, (char*)mb_get_error_desc(s->last_error),
|
(s->error_handler)(s, s->last_error, (char*)mb_get_error_desc(s->last_error),
|
||||||
s->last_error_pos,
|
s->last_error_pos,
|
||||||
@ -3834,11 +3837,12 @@ int mb_load_string(struct mb_interpreter_t* s, const char* l) {
|
|||||||
|
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
_row = row;
|
_row = context->parsing_row;
|
||||||
_col = col;
|
_col = context->parsing_col;
|
||||||
++i;
|
++i;
|
||||||
|
++context->parsing_pos;
|
||||||
};
|
};
|
||||||
status = _parse_char(s, MB_EOS, i, row, col);
|
status = _parse_char(s, MB_EOS, context->parsing_pos, context->parsing_row, context->parsing_col);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
context->parsing_state = _PS_NORMAL;
|
context->parsing_state = _PS_NORMAL;
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -36,8 +36,8 @@
|
|||||||
IDI_ICON_MAIN ICON "icon.ico"
|
IDI_ICON_MAIN ICON "icon.ico"
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 1,1,54,0
|
FILEVERSION 1,1,55,0
|
||||||
PRODUCTVERSION 1,1,54,0
|
PRODUCTVERSION 1,1,55,0
|
||||||
FILEFLAGSMASK 0x17L
|
FILEFLAGSMASK 0x17L
|
||||||
# ifdef _DEBUG
|
# ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
@ -55,13 +55,13 @@
|
|||||||
VALUE "Comments", "MY-BASIC"
|
VALUE "Comments", "MY-BASIC"
|
||||||
VALUE "CompanyName", "W. Renxin"
|
VALUE "CompanyName", "W. Renxin"
|
||||||
VALUE "FileDescription", "MY-BASIC interpreter"
|
VALUE "FileDescription", "MY-BASIC interpreter"
|
||||||
VALUE "FileVersion", "1, 1, 54, 0"
|
VALUE "FileVersion", "1, 1, 55, 0"
|
||||||
VALUE "InternalName", "my_basic"
|
VALUE "InternalName", "my_basic"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2011 - 2015 W. Renxin"
|
VALUE "LegalCopyright", "Copyright (C) 2011 - 2015 W. 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"
|
||||||
VALUE "ProductVersion", "1, 1, 54, 0"
|
VALUE "ProductVersion", "1, 1, 55, 0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
@ -103,12 +103,19 @@ static void _clear_code(_code_line_t* code) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void _append_line(_code_line_t* code, char* txt) {
|
static void _append_line(_code_line_t* code, char* txt) {
|
||||||
|
int l = 0;
|
||||||
|
char* buf = 0;
|
||||||
mb_assert(code && txt);
|
mb_assert(code && txt);
|
||||||
if(code->count + 1 == code->size) {
|
if(code->count + 1 == code->size) {
|
||||||
code->size += _LINE_INC_STEP;
|
code->size += _LINE_INC_STEP;
|
||||||
code->lines = (char**)realloc(code->lines, sizeof(char*) * code->size);
|
code->lines = (char**)realloc(code->lines, sizeof(char*) * code->size);
|
||||||
}
|
}
|
||||||
code->lines[code->count++] = strdup(txt);
|
l = strlen(txt);
|
||||||
|
buf = (char*)malloc(l + 2);
|
||||||
|
memcpy(buf, txt, l);
|
||||||
|
buf[l] = '\n';
|
||||||
|
buf[l + 1] = '\0';
|
||||||
|
code->lines[code->count++] = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* _get_code(_code_line_t* code) {
|
static char* _get_code(_code_line_t* code) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user