- FEAT: add source code length field in `fzl_reader_t` struct - FIX: check name, lpair (lparen) and rpair (rparen) when lexing call - FIX: check string literal termination - FIX: increment position even on empty string to prevent infinite lexing loop - FIX: add string terminator in `fzl_mktoken` when allocating space for string value - FIX: add check for errors in recursevly called `walk` - FIX: change source code holder from stack-stored `char[8192]` to dynamically allocated with actual file size holder - FIX: correct constant hasing util to hash actual string value instead of link
41 lines
718 B
C
41 lines
718 B
C
#ifndef FZL_READER_H
|
|
#define FZL_READER_H
|
|
|
|
#include <compiler/fzl_token.h>
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
// Tokens linked list descriptor
|
|
typedef struct fzl_reader_ll
|
|
{
|
|
fzl_token_t *token;
|
|
struct fzl_reader_ll *next;
|
|
} fzl_reader_ll_t;
|
|
|
|
// Source reader description
|
|
typedef struct
|
|
{
|
|
fzl_reader_ll_t *first;
|
|
fzl_reader_ll_t *last;
|
|
|
|
char *source;
|
|
size_t size;
|
|
size_t position;
|
|
bool at_end;
|
|
} fzl_reader_t;
|
|
|
|
// Allocate new reader
|
|
fzl_reader_t *fzl_mkreader(char *source);
|
|
|
|
// Read source file
|
|
int fzl_read(fzl_reader_t *reader);
|
|
|
|
// Get last error from reader
|
|
char *fzl_reader_geterror();
|
|
|
|
// Free reader
|
|
void fzl_freereader(fzl_reader_t *reader);
|
|
|
|
#endif // FZL_READER_H
|