asm: implement asembly lexer
This commit is contained in:
@@ -1,8 +1,89 @@
|
||||
#ifndef IVY_ASM_LEX_H_
|
||||
#define IVY_ASM_LEX_H_
|
||||
|
||||
#include <ivy/line-source.h>
|
||||
#include <ivy/misc.h>
|
||||
#include <ivy/status.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
IVY_API void placeholder12(void);
|
||||
enum ivy_asm_token_type {
|
||||
IVY_ASM_TOK_NONE = 0,
|
||||
IVY_ASM_TOK_KEYWORD,
|
||||
IVY_ASM_TOK_SYMBOL,
|
||||
IVY_ASM_TOK_INT,
|
||||
IVY_ASM_TOK_DOUBLE,
|
||||
IVY_ASM_TOK_LABEL,
|
||||
IVY_ASM_TOK_IDENT,
|
||||
IVY_ASM_TOK_STRING,
|
||||
IVY_ASM_TOK_LINEFEED,
|
||||
};
|
||||
|
||||
#endif
|
||||
enum ivy_asm_keyword {
|
||||
IVY_ASM_KW_NONE = 0,
|
||||
IVY_ASM_KW_USE,
|
||||
IVY_ASM_KW_IDENT,
|
||||
IVY_ASM_KW_SELECTOR,
|
||||
IVY_ASM_KW_ATOM,
|
||||
IVY_ASM_KW_LAMBDA,
|
||||
IVY_ASM_KW_CONSTPOOL,
|
||||
IVY_ASM_KW_CLASS,
|
||||
IVY_ASM_KW_MSGH,
|
||||
IVY_ASM_KW_END,
|
||||
};
|
||||
|
||||
enum ivy_asm_symbol {
|
||||
IVY_ASM_SYM_NONE = 0,
|
||||
IVY_ASM_SYM_DOT,
|
||||
IVY_ASM_SYM_COMMA,
|
||||
IVY_ASM_SYM_LEFT_PAREN,
|
||||
IVY_ASM_SYM_RIGHT_PAREN,
|
||||
IVY_ASM_SYM_LEFT_BRACKET,
|
||||
IVY_ASM_SYM_RIGHT_BRACKET,
|
||||
IVY_ASM_SYM_COLON,
|
||||
IVY_ASM_SYM_SEMICOLON,
|
||||
IVY_ASM_SYM_DOLLAR,
|
||||
IVY_ASM_SYM_HYPHEN,
|
||||
IVY_ASM_SYM_SQUOTE,
|
||||
IVY_ASM_SYM_DQUOTE,
|
||||
IVY_ASM_SYM_FORWARD_SLASH_ASTERISK,
|
||||
IVY_ASM_SYM_ASTERISK_FORWARD_SLASH,
|
||||
};
|
||||
|
||||
struct ivy_asm_token {
|
||||
enum ivy_asm_token_type t_type;
|
||||
struct ivy_asm_token *t_next;
|
||||
|
||||
union {
|
||||
enum ivy_asm_keyword t_keyword;
|
||||
enum ivy_asm_symbol t_symbol;
|
||||
struct {
|
||||
long long v;
|
||||
unsigned long long uv;
|
||||
bool sign;
|
||||
} t_int;
|
||||
double t_double;
|
||||
char *t_str;
|
||||
};
|
||||
};
|
||||
|
||||
struct ivy_asm_lexer_symbol_node;
|
||||
struct ivy_asm_lexer_state;
|
||||
struct ivy_asm_lexer;
|
||||
|
||||
IVY_API enum ivy_status ivy_asm_lexer_create(struct ivy_asm_lexer **lex);
|
||||
IVY_API void ivy_asm_lexer_destroy(struct ivy_asm_lexer *lex);
|
||||
|
||||
IVY_API void ivy_asm_lexer_set_source(
|
||||
struct ivy_asm_lexer *lex, struct ivy_line_source *src);
|
||||
IVY_API enum ivy_status ivy_asm_lexer_get_status(struct ivy_asm_lexer *lex);
|
||||
|
||||
IVY_API struct ivy_asm_token *ivy_asm_lexer_peek(struct ivy_asm_lexer *lex);
|
||||
IVY_API struct ivy_asm_token *ivy_asm_lexer_read(struct ivy_asm_lexer *lex);
|
||||
|
||||
IVY_API void ivy_asm_token_destroy(struct ivy_asm_token *tok);
|
||||
|
||||
IVY_API const char *ivy_asm_token_type_to_string(enum ivy_asm_token_type type);
|
||||
IVY_API const char *ivy_asm_keyword_to_string(enum ivy_asm_keyword keyword);
|
||||
IVY_API const char *ivy_asm_symbol_to_string(enum ivy_asm_symbol sym);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user