Skip to content

Commit

Permalink
parsing : add command line arguments to load files
Browse files Browse the repository at this point in the history
  • Loading branch information
gagbo committed May 21, 2018
1 parent 5ff2654 commit 57999c2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions example.lspy
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
; This is a test file for the load command of Lispy
(fun {is_x_1 x} {cond (== x 1) {t} {f}})
13 changes: 13 additions & 0 deletions src/parsing.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ main(int argc, char* argv[]) {
struct lenv* e = lenv_new(Lispy);
lenv_add_builtins(e);

/* Load input files if given as arguments */
if (argc >= 2) {
for (int i = 1; i < argc; ++i) {
struct lval* args = lval_add(lval_sexpr(), lval_str(argv[i]));

struct lval* x = builtin_load(e, args);

if (x->type == LVAL_ERR) {
lval_println(x);
}
lval_del(x);
}
}
while (1) {
char* input = readline("lispy> ");

Expand Down

0 comments on commit 57999c2

Please sign in to comment.