asm: implement parsing of classes, dot-mnemonics
This commit is contained in:
@@ -1,14 +1,7 @@
|
||||
#include "parse.h"
|
||||
#include <ivy/asm/assembler.h>
|
||||
#include <blue/core/hash.h>
|
||||
|
||||
#define HASH_IDENT 0x684f633b2528fc75
|
||||
#define HASH_INDEX 0x83cf8e8f9081468b
|
||||
#define HASH_RECIPIENT 0x3d0abea328337078
|
||||
#define HASH_SELECTOR 0x03b0355a1af4ac9c
|
||||
#define HASH_GET 0xd4e26318faaa79f7
|
||||
#define HASH_SET 0x823b87195ce20e23
|
||||
#define HASH_PACKAGE 0x53cf3eec39cf731b
|
||||
#include <blue/core/hash.h>
|
||||
#include <ivy/asm/assembler.h>
|
||||
|
||||
struct unit_parser_state {
|
||||
struct parser_state s_base;
|
||||
@@ -63,6 +56,11 @@ static enum ivy_status push_attrib(struct unit_parser_state *state)
|
||||
state->s_next_scope_attrib[IVY_ASM_ATTRIB_PACKAGE] = v;
|
||||
}
|
||||
break;
|
||||
case HASH_BLOCK:
|
||||
if (!strcmp(s, "block")) {
|
||||
state->s_next_scope_attrib[IVY_ASM_ATTRIB_BLOCK] = v;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
@@ -76,9 +74,11 @@ static enum ivy_status push_attrib(struct unit_parser_state *state)
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
static enum ivy_status parse_constpool(struct ivy_asm_parser* ctx, struct ivy_asm_token* tok)
|
||||
static enum ivy_status parse_constpool(
|
||||
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
|
||||
{
|
||||
struct unit_parser_state *state = (struct unit_parser_state *)asm_parser_get_state(ctx);
|
||||
struct unit_parser_state *state
|
||||
= (struct unit_parser_state *)asm_parser_get_state(ctx);
|
||||
|
||||
if (state->s_prev_token != IVY_ASM_TOK_NONE) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
@@ -180,7 +180,8 @@ static enum ivy_status parse_label(
|
||||
struct unit_parser_state *state
|
||||
= (struct unit_parser_state *)asm_parser_get_state(ctx);
|
||||
|
||||
if (state->s_prev_token != IVY_ASM_SYM_LEFT_BRACKET && state->s_prev_token != IVY_ASM_TOK_INT) {
|
||||
if (state->s_prev_token != IVY_ASM_SYM_LEFT_BRACKET
|
||||
&& state->s_prev_token != IVY_ASM_TOK_INT) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
@@ -230,7 +231,8 @@ static enum ivy_status parse_linefeed(
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
if (state->s_prev_token != IVY_ASM_TOK_KEYWORD && state->s_prev_token != IVY_ASM_SYM_RIGHT_BRACKET) {
|
||||
if (state->s_prev_token != IVY_ASM_TOK_KEYWORD
|
||||
&& state->s_prev_token != IVY_ASM_SYM_RIGHT_BRACKET) {
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
@@ -262,4 +264,4 @@ struct parser_state_type unit_parser_state_type = {
|
||||
TOK_PARSER(INT, parse_int),
|
||||
TOK_PARSER(LINEFEED, parse_linefeed),
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user