asm: implement an asm parser and emitter
This commit is contained in:
42
asm/parse/unit.c
Normal file
42
asm/parse/unit.c
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "parse.h"
|
||||
|
||||
struct unit_parser_state {
|
||||
struct parser_state s_base;
|
||||
};
|
||||
|
||||
static enum ivy_status parse_constpool(struct ivy_asm_parser* ctx, struct ivy_asm_token* tok)
|
||||
{
|
||||
asm_parser_push_state(ctx, ASM_PARSER_CONSTPOOL);
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
static enum ivy_status parse_import(
|
||||
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
|
||||
{
|
||||
asm_parser_push_state(ctx, ASM_PARSER_IMPORT);
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
static enum ivy_status parse_block(
|
||||
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
|
||||
{
|
||||
asm_parser_push_state(ctx, ASM_PARSER_BLOCK);
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
static enum ivy_status parse_class(
|
||||
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
|
||||
{
|
||||
asm_parser_push_state(ctx, ASM_PARSER_CLASS);
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
struct parser_state_type unit_parser_state_type = {
|
||||
.n_state_size = sizeof(struct unit_parser_state),
|
||||
.n_keyword_parsers = {
|
||||
KW_PARSER(CONSTPOOL, parse_constpool),
|
||||
KW_PARSER(IMPORT, parse_import),
|
||||
KW_PARSER(CLASS, parse_class),
|
||||
KW_PARSER(BLOCK, parse_block),
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user