tiny scheme compiler that aims to be fast and correct
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

76 lines
1.3 KiB

10 years ago
#define STACK_SIZE 4096
#define GROWTH_SIZE 65536
10 years ago
typedef char* source_t;
typedef enum {
SYMBOL = 0,
IDENTIFIER = 1,
INTEGER = 2,
FLOATING = 3,
QUOTE = 4,
WSPACE = 5,
PAREN = 6 ,
EMPTY = 7,
STRING = 8
10 years ago
} tok_t;
typedef union {
const char *symbol;
const char *identifier;
const char *integer;
const char *floating;
const char *parenthesis;
const char *string;
10 years ago
bool quote;
bool whitespace;
bool null_token;
} token_val_t;
typedef struct {
tok_t token_type;
token_val_t token;
} token_t;
typedef struct {
size_t length; /* Number of current elements */
size_t max_length; /* Maximum length of the stack */
token_t *tokens;
hsh_HashTable memo;
10 years ago
} token_stream;
bool
push_token(token_stream*, token_t);
10 years ago
bool
pop_token(token_stream*);
10 years ago
token_t
peek_token(token_stream*);
10 years ago
token_stream
tokenize(source_t, uint32_t, const uint32_t);
10 years ago
bool
release_tokens(token_stream*);
10 years ago
#ifndef LIB
static uint32_t
match_int(source_t, uint32_t, const uint32_t);
static uint32_t
match_float(source_t, uint32_t, const uint32_t);
static uint32_t
match_identifier(source_t, uint32_t, const uint32_t);
static uint32_t
match_symbol(source_t, uint32_t, const uint32_t);
#endif
int
free_token(const void *,
const void *);
token_t
testfunc(void);