Files
glisp/src/read.h
T
2026-08-13 14:10:29 -07:00

36 lines
733 B
C

#ifndef INCLUDED_READ_H
#define INCLUDED_READ_H
#include "base.h"
#include <stddef.h>
#define READ_EOS -1
static ALWAYS_INLINE bool WHITESPACEP(int c) {
return c == ' ' || c == '\t' || c == '\n';
}
static ALWAYS_INLINE bool SYMBOL_END_P(int c) {
return WHITESPACEP(c) || c == READ_EOS || c == '(' || c == ')' || c == '['
|| c == ']' || c == '\'' || c == '\"' || c == ',' || c == '@'
|| c == '`' || c == ';';
}
typedef struct {
const char *buffer;
size_t len;
size_t off;
size_t line;
size_t col;
size_t backquote_level;
} ReadStream;
void read_stream_init(ReadStream *stream, const char *buffer, size_t length);
// NULL on eof
LispVal *read(ReadStream *stream);
#endif