#include #include #include "lisp.h" typedef struct { size_t line; size_t col; char *context; char *desc; void *next; } ParseError; typedef struct { FILE *src; size_t line; size_t col; ParseError *error_head; ParseError *error_tail; size_t error_count; } TokenStream; typedef enum { TOKEN_TYPE_EOF, TOKEN_TYPE_UNKNOWN, TOKEN_TYPE_COMMENT, TOKEN_TYPE_PAREN, TOKEN_TYPE_BRACKET, TOKEN_TYPE_SYMBOL, TOKEN_TYPE_PROPERTY, TOKEN_TYPE_QUOTE, TOKEN_TYPE_CHAR, TOKEN_TYPE_NUMBER, TOKEN_TYPE_STRING, } TokenType; typedef struct { TokenType type; char *text; size_t buf_len; size_t len; size_t line; size_t col; } Token; // src is taken by this function TokenStream *make_token_stream(FILE *src); void destroy_token_stream(TokenStream *stream); // return the number of errors after parsing size_t token_stream_next(TokenStream *stream, Token *token); void token_free(Token *token); // return the number of errors left ParseError *token_stream_error(TokenStream *stream); void parse_error_free(ParseError *error); void read_native(FILE *src, LispObject ***result, size_t *result_len, ParseError *errors, size_t *error_count);