53 lines
1.0 KiB
C
53 lines
1.0 KiB
C
|
|
#ifndef IFC_LEX_H_
|
||
|
|
#define IFC_LEX_H_
|
||
|
|
|
||
|
|
#include "status.h"
|
||
|
|
#include "token.h"
|
||
|
|
|
||
|
|
#include <blue/core/queue.h>
|
||
|
|
#include <blue/ds/dict.h>
|
||
|
|
#include <blue/ds/string.h>
|
||
|
|
#include <stdint.h>
|
||
|
|
|
||
|
|
struct lex {
|
||
|
|
struct lex_symbol_node *lex_sym_tree;
|
||
|
|
struct line_source *lex_source;
|
||
|
|
enum status lex_status;
|
||
|
|
|
||
|
|
b_queue lex_queue;
|
||
|
|
|
||
|
|
b_string *lex_temp;
|
||
|
|
b_queue lex_state;
|
||
|
|
unsigned int lex_brace_depth;
|
||
|
|
|
||
|
|
struct file_cell lex_token_start, lex_token_end;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct lex_symbol_node {
|
||
|
|
char s_char;
|
||
|
|
struct lex_token_def *s_def;
|
||
|
|
|
||
|
|
b_queue_entry s_entry;
|
||
|
|
b_queue s_children;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct lex_token_def {
|
||
|
|
int id;
|
||
|
|
const char *name;
|
||
|
|
uint64_t name_hash;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct token;
|
||
|
|
struct line_source;
|
||
|
|
|
||
|
|
extern struct lex *lex_create(struct line_source *src);
|
||
|
|
extern void lex_destroy(struct lex *lex);
|
||
|
|
|
||
|
|
extern enum status lex_get_status(const struct lex *lex);
|
||
|
|
extern struct line_source *lex_get_line_source(const struct lex *lex);
|
||
|
|
extern const struct file_cell *lex_get_cursor(const struct lex *lex);
|
||
|
|
extern struct token *lex_peek(struct lex *lex);
|
||
|
|
extern void lex_advance(struct lex *lex);
|
||
|
|
|
||
|
|
#endif
|