feat: implement lexer+parser for example program
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#ifndef FZL_TOKEN_H
|
||||
#define FZL_TOKEN_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
// Token type
|
||||
typedef enum {
|
||||
FZL_TOKTYPE_NAME,
|
||||
FZL_TOKTYPE_LPAIR,
|
||||
FZL_TOKTYPE_RPAIR,
|
||||
FZL_TOKTYPE_COMMA,
|
||||
FZL_TOKTYPE_STR_LITERAL
|
||||
} fzl_toktype_t;
|
||||
|
||||
// Token descriptor
|
||||
typedef struct {
|
||||
fzl_toktype_t type;
|
||||
uint16_t i0;
|
||||
uint16_t i1;
|
||||
bool store_value;
|
||||
void *value;
|
||||
uint16_t value_sz;
|
||||
} fzl_token_t;
|
||||
|
||||
// Allocate new token
|
||||
fzl_token_t *fzl_mktoken(
|
||||
const fzl_toktype_t type, uint16_t from, uint16_t to,
|
||||
void *value, size_t value_sz);
|
||||
|
||||
// Free token and its contents
|
||||
void fzl_freetoken(fzl_token_t *token);
|
||||
|
||||
#endif//FZL_TOKEN_H
|
||||
|
||||
Reference in New Issue
Block a user