Files
ivy/asm/lex.h

55 lines
922 B
C
Raw Normal View History

2024-11-19 22:08:58 +00:00
#ifndef _LEX_H_
#define _LEX_H_
2026-03-16 14:07:33 +00:00
#include <fx/core/queue.h>
#include <fx/ds/dict.h>
#include <fx/ds/string.h>
2024-11-22 22:30:15 +00:00
#include <ivy/asm/lex.h>
2024-11-19 22:08:58 +00:00
#include <stdint.h>
enum lexer_state_type {
STATE_NORMAL,
STATE_STRING,
STATE_DSTRING,
};
struct lexer_state {
enum lexer_state_type s_type;
2026-03-16 14:07:33 +00:00
fx_queue_entry s_entry;
2024-11-19 22:08:58 +00:00
};
struct ivy_asm_lexer_symbol_node {
char s_char;
2024-11-22 22:30:15 +00:00
enum ivy_asm_symbol s_id;
2024-11-19 22:08:58 +00:00
2026-03-16 14:07:33 +00:00
fx_queue_entry s_entry;
fx_queue s_children;
2024-11-19 22:08:58 +00:00
};
struct lex_token_def {
int id;
const char *name;
uint64_t name_hash;
};
struct ivy_asm_lexer {
struct ivy_asm_lexer_symbol_node *lex_sym_tree;
struct ivy_line_source *lex_source;
2026-03-16 14:07:33 +00:00
fx_dict *lex_keywords;
2024-11-19 22:08:58 +00:00
enum ivy_status lex_status;
2026-03-16 14:07:33 +00:00
fx_queue lex_queue;
2024-11-19 22:08:58 +00:00
enum ivy_asm_token_type lex_prev_token;
2026-03-16 14:07:33 +00:00
fx_string *lex_temp;
fx_queue lex_state;
2024-11-19 22:08:58 +00:00
unsigned int lex_brace_depth;
char *lex_linebuf;
size_t lex_linebuf_len;
size_t lex_linebuf_cap;
size_t lex_linebuf_ptr;
};
2024-11-22 22:30:15 +00:00
#endif