Add special syntax for REPL and scripts
This commit is contained in:
parent
5b2c5af17f
commit
dc8d81a382
3 changed files with 21 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
|||
#include "eval.h"
|
||||
#include "lexer.h"
|
||||
#include "object.h"
|
||||
#include "parser.h"
|
||||
#include "syntax.h"
|
||||
#include "tokens.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -62,10 +62,10 @@ void repl()
|
|||
struct Object *const program = parse(tokens);
|
||||
TOKENS_DELETE(tokens);
|
||||
|
||||
struct Object *const result = eval(program, environment);
|
||||
struct Object *const result = syntax_repl(program, environment);
|
||||
|
||||
printf("=> ");
|
||||
eval(
|
||||
syntax_repl(
|
||||
Object_build_list(
|
||||
2,
|
||||
Object_new_symbol("displayln"),
|
||||
|
@ -98,5 +98,5 @@ void script()
|
|||
TOKENS_DELETE(tokens);
|
||||
|
||||
struct Object *const environment = Object_new_pair(NULL, NULL);
|
||||
eval(program, environment);
|
||||
syntax_script(program, environment);
|
||||
}
|
||||
|
|
14
src/syntax.c
14
src/syntax.c
|
@ -5,6 +5,20 @@
|
|||
|
||||
#include <assert.h>
|
||||
|
||||
struct Object *syntax_repl(
|
||||
struct Object *args,
|
||||
struct Object *const environment
|
||||
) {
|
||||
return eval(args, environment);
|
||||
}
|
||||
|
||||
struct Object *syntax_script(
|
||||
struct Object *args,
|
||||
struct Object *const environment
|
||||
) {
|
||||
return eval(args, environment);
|
||||
}
|
||||
|
||||
struct Object *syntax_begin(
|
||||
struct Object *args,
|
||||
struct Object *const environment
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include "object.h"
|
||||
|
||||
struct Object *syntax_repl(struct Object *args, struct Object *environment);
|
||||
struct Object *syntax_script(struct Object *args, struct Object *environment);
|
||||
|
||||
struct Object *syntax_begin(struct Object *args, struct Object *environment);
|
||||
struct Object *syntax_define(struct Object *args, struct Object *environment);
|
||||
struct Object *syntax_if(struct Object *args, struct Object *environment);
|
||||
|
|
Loading…
Reference in a new issue