8 typedef struct Scope Scope;
13 // TODO(#321): get rid of gc argument from expr macros (just assume that it's `gc` in the current scope)
14 #define NUMBER(G, X) atom_as_expr(create_number_atom(G, X))
15 #define STRING(G, S) atom_as_expr(create_string_atom(G, S, NULL))
16 #define SYMBOL(G, S) atom_as_expr(create_symbol_atom(G, S, NULL))
17 #define NATIVE(G, F) atom_as_expr(create_native_atom(G, F))
18 #define CONS(G, CAR, CDR) cons_as_expr(create_cons(G, CAR, CDR))
19 #define NIL(G) SYMBOL(G, "nil")
28 // TODO(#285): there is no way to execute struct Expr
38 struct Expr atom_as_expr(struct Atom *atom);
39 struct Expr cons_as_expr(struct Cons *cons);
40 struct Expr void_expr(void);
42 void destroy_expr(struct Expr expr);
43 void print_expr_as_sexpr(struct Expr expr);
45 // TODO(#337): EvalResult does not belong to expr unit
52 typedef struct EvalResult (*NativeFunction)(Gc *gc, struct Scope *scope, struct Expr args);
67 // TODO(#330): Atom doesn't support floats
68 long int num; // ATOM_NUMBER
69 char *sym; // ATOM_SYMBOL
70 char *str; // ATOM_STRING
71 NativeFunction fun; // ATOM_NATIVE
75 struct Atom *create_number_atom(Gc *gc, long int num);
76 struct Atom *create_string_atom(Gc *gc, const char *str, const char *str_end);
77 struct Atom *create_symbol_atom(Gc *gc, const char *sym, const char *sym_end);
78 struct Atom *create_native_atom(Gc *gc, NativeFunction fun);
79 void destroy_atom(struct Atom *atom);
80 void print_atom_as_sexpr(struct Atom *atom);
88 struct Cons *create_cons(Gc *gc, struct Expr car, struct Expr cdr);
89 void destroy_cons(struct Cons *cons);
90 void print_cons_as_sexpr(struct Cons *cons);