Minor restructure for platformio compatibility

This commit is contained in:
2022-11-25 21:59:10 -05:00
parent 6cc27427cf
commit d965ca142d
8 changed files with 41 additions and 12 deletions

View File

@@ -7,7 +7,7 @@ from dataclasses import dataclass
# File lists
#
PROGRAM_SOURCES = ["src/main.c"]
PROGRAM_SOURCES = ["examples/repl/main.c"]
LIB_SRCS = [
"src/arena.c",
"src/builtins.c",
@@ -67,7 +67,8 @@ class BuildVariant:
repl_env = self.env.Clone()
repl_env.Append(LIBS=[self.static_lib])
self.repl_program = repl_env.Program(
self.built("uclisp"), pgm_objs,
self.built("uclisp"),
pgm_objs,
)
def configure_tests(self):

View File

@@ -51,10 +51,8 @@ int main(int argc, const char **argv) {
struct ucl_object *sexp = ucl_parse(ucl, argv[1]);
struct ucl_object *result = ucl_evaluate(ucl, ucl_car(ucl, sexp));
if (result->type == UCL_TYPE_ERROR) {
printf("%s", result->error);
return -1;
}
ucl_print_obj(result);
printf("\n");
return 0;
}

26
library.json Normal file
View File

@@ -0,0 +1,26 @@
{
"name": "ucLISP",
"version": "0.1.0",
"description": "A toy LISP implementation for microcontrollers",
"keywords": "lisp, language, scripting, garbage collector",
"repository":
{
"type": "git",
"url": "https://gitlab.maxregan.me/max/uclisp.git"
},
"authors":
[
{
"name": "Max Regan",
"email": "mgregan2@gmail.com",
"url": "https://www.gitlab.maxregan.me/max",
"maintainer": true
}
],
"license": "MIT",
"homepage": "https://gitlab.maxregan.me/max/uclisp",
"dependencies": {
},
"frameworks": "*",
"platforms": "*"
}

View File

@@ -272,8 +272,7 @@ LISP_FUNC_2(ucl_builtin_append, state, scope, list, elem) {
return list;
}
// TODO: publicize
static void ucl_add_builtin(struct ucl* ucl, const char *name, ucl_lisp fun) {
void ucl_add_builtin(struct ucl* ucl, const char *name, ucl_lisp fun) {
ucl_scope_put(ucl, ucl->global_scope, name, ucl_builtin_create(ucl, fun));
}

View File

@@ -68,6 +68,7 @@ struct ucl_object *ucl_evaluate_list(struct ucl* state, struct ucl_scope *scope,
return ucl_evaluate_builtin_form(state, scope, list);
} else {
assert(0);
UCL_COND_OR_RET_ERROR(false, "Unreachable error in ucl_evaluate_list");
}
}

View File

@@ -5,6 +5,9 @@
#define UNUSED __attribute__((unused))
void ucl_add_builtin(struct ucl *state, const char *name, ucl_lisp fun);
void ucl_add_special(struct ucl *state, const char *name, ucl_lisp fun);
#define LISP_FUNC_0(func_name, ucl_name, scope_name) \
static struct ucl_object *func_name##_impl(struct ucl* ucl, struct ucl_scope *scope); \
struct ucl_object *func_name(struct ucl* ucl, struct ucl_scope *scope, struct ucl_object *args) { \

View File

@@ -90,10 +90,11 @@ struct ucl_object *ucl_token_next(struct ucl* state, const char **curr_src) {
goto symbol_case;
}
*curr_src = end;
if (!ucl_is_delimiter(*end)) {
return ucl_error_create(state, "Integer value contained non-digits");
goto symbol_case;
//return ucl_error_create(state, "Integer value contained non-digits");
}
*curr_src = end;
return ucl_int_create(state, value);
}
default:

View File

@@ -23,9 +23,9 @@ struct ucl_object *ucl_progn(struct ucl* state, struct ucl_scope *scope, struct
void ucl_print_obj(struct ucl_object *obj);
struct ucl_object* ucl_evaluate_in_scope(struct ucl *state, struct ucl_scope *scope, struct ucl_object* sexp);
void ucl_add_builtins(struct ucl *state);
void ucl_add_specials(struct ucl *state);
struct ucl_object* ucl_evaluate_in_scope(struct ucl *state, struct ucl_scope *scope, struct ucl_object* sexp);
#endif