Compare commits
2 Commits
c4a7117704
...
5617484aff
Author | SHA1 | Date |
---|---|---|
Danila Fedorin | 5617484aff | |
Danila Fedorin | b311c854ee |
|
@ -232,6 +232,13 @@ void libab_get_false_value(libab* ab, libab_ref* into);
|
||||||
*/
|
*/
|
||||||
void libab_get_bool_value(libab* ab, int val, libab_ref* into);
|
void libab_get_bool_value(libab* ab, int val, libab_ref* into);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the given piece of code using the given libabacus instance.
|
||||||
|
* @param ab the instance to use to parse the code.
|
||||||
|
* @param string the source code to parse.
|
||||||
|
* @param into the value to store the newly parsed tree into.
|
||||||
|
*/
|
||||||
|
libab_result libab_parse(libab* ab, const char* string, libab_tree** into);
|
||||||
/**
|
/**
|
||||||
* Executes the given string of code.
|
* Executes the given string of code.
|
||||||
* @param ab the libabacus instance to use for executing code.
|
* @param ab the libabacus instance to use for executing code.
|
||||||
|
|
|
@ -406,7 +406,7 @@ void libab_get_bool_value(libab* ab, int val, libab_ref* into) {
|
||||||
val ? libab_get_true_value(ab, into) : libab_get_false_value(ab, into);
|
val ? libab_get_true_value(ab, into) : libab_get_false_value(ab, into);
|
||||||
}
|
}
|
||||||
|
|
||||||
libab_result _create_tree(libab* ab, const char* string, libab_tree** into) {
|
libab_result libab_parse(libab* ab, const char* string, libab_tree** into) {
|
||||||
libab_result result = LIBAB_SUCCESS;
|
libab_result result = LIBAB_SUCCESS;
|
||||||
ll tokens;
|
ll tokens;
|
||||||
|
|
||||||
|
@ -442,7 +442,7 @@ libab_result libab_run(libab* ab, const char* string, libab_ref* value) {
|
||||||
libab_tree* root;
|
libab_tree* root;
|
||||||
|
|
||||||
libab_ref_null(value);
|
libab_ref_null(value);
|
||||||
result = _create_tree(ab, string, &root);
|
result = libab_parse(ab, string, &root);
|
||||||
|
|
||||||
if (result == LIBAB_SUCCESS) {
|
if (result == LIBAB_SUCCESS) {
|
||||||
libab_ref_free(value);
|
libab_ref_free(value);
|
||||||
|
@ -483,7 +483,7 @@ libab_result libab_run_scoped(libab* ab, const char* string, libab_ref* scope, l
|
||||||
libab_tree* root;
|
libab_tree* root;
|
||||||
|
|
||||||
libab_ref_null(into);
|
libab_ref_null(into);
|
||||||
result = _create_tree(ab, string, &root);
|
result = libab_parse(ab, string, &root);
|
||||||
if(result == LIBAB_SUCCESS) {
|
if(result == LIBAB_SUCCESS) {
|
||||||
libab_ref_free(into);
|
libab_ref_free(into);
|
||||||
result = libab_interpreter_run(&ab->intr, root, scope, SCOPE_NONE, into);
|
result = libab_interpreter_run(&ab->intr, root, scope, SCOPE_NONE, into);
|
||||||
|
|
|
@ -525,6 +525,7 @@ libab_result _parse_fun(struct parser_state* state, libab_tree** store_into) {
|
||||||
libab_result result = LIBAB_SUCCESS;
|
libab_result result = LIBAB_SUCCESS;
|
||||||
int is_parenth, is_comma;
|
int is_parenth, is_comma;
|
||||||
libab_tree* temp;
|
libab_tree* temp;
|
||||||
|
*store_into = NULL;
|
||||||
result = _parser_consume_type(state, TOKEN_KW_FUN);
|
result = _parser_consume_type(state, TOKEN_KW_FUN);
|
||||||
if (result == LIBAB_SUCCESS) {
|
if (result == LIBAB_SUCCESS) {
|
||||||
if (_parser_is_type(state, TOKEN_ID)) {
|
if (_parser_is_type(state, TOKEN_ID)) {
|
||||||
|
|
Loading…
Reference in New Issue