sdkhjfdsv

This commit is contained in:
Lobo 2026-01-11 13:25:58 -03:00
parent 1aec6085d9
commit 537aa6e404
16 changed files with 683 additions and 71 deletions

View file

@ -1,6 +1,7 @@
#ifndef WOLFLISP_H
#define WOLFLISP_H
#include <setjmp.h>
#include <stddef.h>
#include <stdint.h>
@ -107,13 +108,48 @@ typedef struct Gc {
} roots;
} Gc;
// Error context
typedef struct Er {
jmp_buf handler;
int active;
char message[512];
struct {
const char *frames[32];
int count;
} stack;
} Er;
// Interpreter context
typedef struct In {
Gc gc;
St symtab;
O env;
Er err;
O t; // the T symbol
} In;
enum {
TOK_EOF = 0,
TOK_COMMENT = ';',
TOK_WORD = 'a',
TOK_LPAREN = '(',
TOK_RPAREN = ')',
TOK_STRING = '"',
TOK_QUOTE = '\'',
TOK_DOT = '.',
};
#include <stdio.h>
#define LEXER_CAP 1024
typedef struct Lx {
int kind;
int cursor;
FILE *input;
char buffer[1024];
} Lx;
/// * Function declarations
// Get the type of an object
@ -136,6 +172,12 @@ V gc_init(Gc *gc);
// Finalize a GC context.
V gc_finalize(Gc *gc);
void error_init(Er *err);
void error_throw(In *in, const char *fmt, ...);
void error_push_frame(In *in, const char *frame);
void error_pop_frame(In *in);
void error_print(In *in);
// Initialize an interpreter context.
V interp_init(In *in);
// Finalize an interpreter context.
@ -151,7 +193,7 @@ O interp_eval(In *in, O obj, O env);
Sy *intern(St *tab, const char *str, Z len);
// Create a pair
O pair_make(Gc *gc, O head, O tail);
O pair_make(In *in, O head, O tail);
// Unwrap a pair
Pa *pair_unwrap(O obj);
@ -164,4 +206,6 @@ O prim_make(In *in, const char *name, O (*fn)(In *, O, O));
O list_assoc(O key, O alist);
O list_reverse(O list);
int nexttoken(Lx *lex);
#endif