+added a range of integer syntax.
+Added a range of integer syntax for the LIST statement, eg. LIST(m TO n).
This commit is contained in:
parent
76671ecfa9
commit
74f6f054b4
3
HISTORY
3
HISTORY
@ -1,3 +1,6 @@
|
|||||||
|
Jan. 16 2016
|
||||||
|
Added a range of integer syntax for the LIST statement, eg. LIST(m TO n)
|
||||||
|
|
||||||
Jan. 15 2016
|
Jan. 15 2016
|
||||||
Added a REFLECT statement
|
Added a REFLECT statement
|
||||||
Added an MB_ENABLE_USERTYPE_REF macro
|
Added an MB_ENABLE_USERTYPE_REF macro
|
||||||
|
@ -44,7 +44,7 @@ MY-BASIC is a dynamic typed programming language with BASIC syntax and has a ver
|
|||||||
* Collection implementation and manipulation functions for **`LIST`** and **`DICT`**
|
* Collection implementation and manipulation functions for **`LIST`** and **`DICT`**
|
||||||
* Automatic releasing of referenced objects (list, dictionary, referenced usertype, prototype, lambda, etc.) benefited from **Reference Counting** and **Garbage Collection**
|
* Automatic releasing of referenced objects (list, dictionary, referenced usertype, prototype, lambda, etc.) benefited from **Reference Counting** and **Garbage Collection**
|
||||||
* Multiple file support by `IMPORT` statement
|
* Multiple file support by `IMPORT` statement
|
||||||
* Structured user customizable **sub routine** definition by **`DEF/ENDDEF`** support, including tail recursion optimization
|
* Structured user customizable **sub routine** definition by **`DEF-ENDDEF`** support, including tail recursion optimization
|
||||||
* Structured `IF-THEN-ELSEIF-ELSE-ENDIF` support
|
* Structured `IF-THEN-ELSEIF-ELSE-ENDIF` support
|
||||||
* Structured `FOR-TO-STEP-NEXT/WHILE-WEND/DO-UNTIL` support
|
* Structured `FOR-TO-STEP-NEXT/WHILE-WEND/DO-UNTIL` support
|
||||||
* Reserved retro `GOTO/GOSUB-RETURN` support
|
* Reserved retro `GOTO/GOSUB-RETURN` support
|
||||||
|
@ -13511,11 +13511,38 @@ int _coll_list(mb_interpreter_t* s, void** l) {
|
|||||||
|
|
||||||
coll = _create_list(s);
|
coll = _create_list(s);
|
||||||
|
|
||||||
|
if(mb_has_arg(s, l)) {
|
||||||
|
_ls_node_t* ast = 0;
|
||||||
|
_object_t* obj = 0;
|
||||||
|
mb_make_nil(arg);
|
||||||
|
_mb_check_mark(mb_pop_value(s, l, &arg), result, _error);
|
||||||
|
ast = (_ls_node_t*)*l;
|
||||||
|
if(ast) obj = (_object_t*)ast->data;
|
||||||
|
if(arg.type == MB_DT_INT && obj && _IS_FUNC(obj, _core_to)) {
|
||||||
|
/* Push a range of integer */
|
||||||
|
int_t begin = arg.value.integer;
|
||||||
|
int_t end = 0;
|
||||||
|
int_t step = 0;
|
||||||
|
ast = ast->next;
|
||||||
|
_mb_check_mark(mb_pop_int(s, (void**)&ast, &end), result, _error);
|
||||||
|
step = sgn(end - begin);
|
||||||
|
end += step;
|
||||||
|
do {
|
||||||
|
mb_make_int(arg, begin);
|
||||||
|
_push_list(coll, &arg, 0);
|
||||||
|
begin += step;
|
||||||
|
} while(begin != end);
|
||||||
|
*l = ast;
|
||||||
|
} else {
|
||||||
|
/* Push arguments */
|
||||||
|
_push_list(coll, &arg, 0);
|
||||||
while(mb_has_arg(s, l)) {
|
while(mb_has_arg(s, l)) {
|
||||||
mb_make_nil(arg);
|
mb_make_nil(arg);
|
||||||
_mb_check_mark(mb_pop_value(s, l, &arg), result, _error);
|
_mb_check_mark(mb_pop_value(s, l, &arg), result, _error);
|
||||||
_push_list(coll, &arg, 0);
|
_push_list(coll, &arg, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_mb_check_mark(mb_attempt_close_bracket(s, l), result, _error);
|
_mb_check_mark(mb_attempt_close_bracket(s, l), result, _error);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user