1
0
Fork 0

Add special syntax for REPL and scripts

This commit is contained in:
Alex Kotov 2023-05-07 17:42:07 +04:00
parent 5b2c5af17f
commit dc8d81a382
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
3 changed files with 21 additions and 4 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -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);