asm: implement parsing of classes, dot-mnemonics
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
enum instr_component {
|
||||
INSTR_NONE = 0,
|
||||
INSTR_OPCODE,
|
||||
INSTR_OPCODE_DOT,
|
||||
INSTR_OPERAND,
|
||||
INSTR_OPERAND_SEPARATOR,
|
||||
INSTR_OPERAND_INDEX_LEFT,
|
||||
@@ -38,17 +39,25 @@ enum index_base {
|
||||
enum arg_type {
|
||||
ARG_NONE = 0,
|
||||
ARG_CONST,
|
||||
ARG_LABEL,
|
||||
ARG_REG,
|
||||
ARG_INDEX_REG,
|
||||
ARG_INDEX_CONST,
|
||||
};
|
||||
|
||||
struct label {
|
||||
b_queue_entry l_entry;
|
||||
struct ivy_asm_token *l_name;
|
||||
unsigned long long l_offset;
|
||||
};
|
||||
|
||||
struct arg {
|
||||
enum arg_type arg_type;
|
||||
b_queue_entry arg_entry;
|
||||
|
||||
union {
|
||||
struct ivy_asm_token *arg_const;
|
||||
struct ivy_asm_token *arg_label;
|
||||
struct {
|
||||
struct ivy_asm_token *reg_token;
|
||||
unsigned long long reg_index;
|
||||
@@ -75,7 +84,9 @@ struct block_parser_state {
|
||||
unsigned int s_prev_token;
|
||||
enum instr_component s_prev_component;
|
||||
|
||||
struct ivy_asm_token *s_mnemonic;
|
||||
b_queue s_labels;
|
||||
|
||||
b_queue s_mnemonic;
|
||||
|
||||
b_queue s_args;
|
||||
struct arg *s_current_arg;
|
||||
@@ -165,6 +176,42 @@ static enum ivy_status push_const_arg(
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
static enum ivy_status push_label(
|
||||
struct block_parser_state *state, struct ivy_asm_token *tok)
|
||||
{
|
||||
struct label *label = malloc(sizeof *label);
|
||||
if (!label) {
|
||||
return IVY_ERR_NO_MEMORY;
|
||||
}
|
||||
|
||||
memset(label, 0x0, sizeof *label);
|
||||
|
||||
label->l_name = tok;
|
||||
/* TODO */
|
||||
label->l_offset = 0;
|
||||
|
||||
b_queue_push_back(&state->s_labels, &label->l_entry);
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
static enum ivy_status push_label_arg(
|
||||
struct block_parser_state *state, struct ivy_asm_token *tok,
|
||||
unsigned long long reg_index)
|
||||
{
|
||||
struct arg *arg = malloc(sizeof *arg);
|
||||
if (!arg) {
|
||||
return IVY_ERR_NO_MEMORY;
|
||||
}
|
||||
|
||||
memset(arg, 0x0, sizeof *arg);
|
||||
|
||||
arg->arg_type = ARG_LABEL;
|
||||
arg->arg_label = tok;
|
||||
|
||||
b_queue_push_back(&state->s_args, &arg->arg_entry);
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
static enum ivy_status push_reg_arg(
|
||||
struct block_parser_state *state, struct ivy_asm_token *tok,
|
||||
unsigned long long reg_index)
|
||||
@@ -235,18 +282,20 @@ static enum ivy_status parse_ident(
|
||||
|
||||
switch (state->s_prev_component) {
|
||||
case INSTR_NONE:
|
||||
state->s_mnemonic = tok;
|
||||
case INSTR_OPCODE_DOT:
|
||||
b_queue_push_back(&state->s_mnemonic, &tok->t_entry);
|
||||
state->s_prev_component = INSTR_OPCODE;
|
||||
return IVY_OK;
|
||||
case INSTR_OPCODE:
|
||||
case INSTR_OPERAND_SEPARATOR:
|
||||
x = get_register_index(tok);
|
||||
if (x == REG_INDEX_INVALID) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
state->s_prev_component = INSTR_OPERAND;
|
||||
return push_reg_arg(state, tok, x);
|
||||
|
||||
if (x == REG_INDEX_INVALID) {
|
||||
return push_label_arg(state, tok, x);
|
||||
} else {
|
||||
return push_reg_arg(state, tok, x);
|
||||
}
|
||||
case INSTR_OPERAND_INDEX_LEFT:
|
||||
x = get_index_base(tok);
|
||||
if (x == INDEX_NONE) {
|
||||
@@ -266,14 +315,32 @@ static enum ivy_status parse_ident(
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
static enum ivy_status parse_dot(
|
||||
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
|
||||
{
|
||||
struct block_parser_state *state
|
||||
= (struct block_parser_state *)asm_parser_get_state(ctx);
|
||||
|
||||
if (state->s_prev_component != INSTR_OPCODE) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
state->s_prev_component = INSTR_OPCODE_DOT;
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
static enum ivy_status parse_label(
|
||||
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
|
||||
{
|
||||
struct block_parser_state *state
|
||||
= (struct block_parser_state *)asm_parser_get_state(ctx);
|
||||
|
||||
/* not sure what this is but we aren't expecting it. */
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
if (state->s_prev_component != INSTR_NONE) {
|
||||
/* not sure what this is but we aren't expecting it. */
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
return push_label(state, tok);
|
||||
}
|
||||
|
||||
static enum ivy_status parse_comma(
|
||||
@@ -355,10 +422,13 @@ static enum ivy_status parse_end(
|
||||
|
||||
static void init_state(struct ivy_asm_parser *ctx, struct parser_state *state)
|
||||
{
|
||||
ivy_assembler_begin_scope(
|
||||
ctx->p_assembler, IVY_ASM_SCOPE_BLOCK, state->s_attrib);
|
||||
}
|
||||
|
||||
static void finish_state(struct ivy_asm_parser *ctx, struct parser_state *state)
|
||||
{
|
||||
ivy_assembler_end_scope(ctx->p_assembler);
|
||||
}
|
||||
|
||||
struct parser_state_type block_parser_state_type = {
|
||||
@@ -375,6 +445,7 @@ struct parser_state_type block_parser_state_type = {
|
||||
SYM_PARSER(LEFT_BRACKET, parse_left_bracket),
|
||||
SYM_PARSER(RIGHT_BRACKET, parse_right_bracket),
|
||||
SYM_PARSER(COMMA, parse_comma),
|
||||
SYM_PARSER(DOT, parse_dot),
|
||||
},
|
||||
.n_keyword_parsers = {
|
||||
KW_PARSER(END, parse_end),
|
||||
|
||||
@@ -0,0 +1,315 @@
|
||||
#include "parse.h"
|
||||
|
||||
#include <blue/core/hash.h>
|
||||
#include <ivy/asm/assembler.h>
|
||||
|
||||
enum item_type {
|
||||
ITEM_NONE = 0,
|
||||
ITEM_PROPERTY,
|
||||
ITEM_VAR,
|
||||
ITEM_MSGH,
|
||||
};
|
||||
|
||||
struct class_parser_state {
|
||||
struct parser_state s_base;
|
||||
|
||||
unsigned int s_prev_token;
|
||||
enum item_type s_current_item;
|
||||
ivy_assembler_attrib_table s_current_item_attrib;
|
||||
|
||||
bool s_in_attrib_list;
|
||||
struct ivy_asm_token *s_attrib_name, *s_attrib_value;
|
||||
};
|
||||
|
||||
static enum ivy_status push_attrib(struct class_parser_state *state)
|
||||
{
|
||||
uint64_t hash = b_hash_string(state->s_attrib_name->t_str);
|
||||
const char *s = state->s_attrib_name->t_str;
|
||||
unsigned long long v = state->s_attrib_value->t_int.uv;
|
||||
|
||||
switch (hash) {
|
||||
case HASH_IDENT:
|
||||
if (!strcmp(s, "ident")) {
|
||||
state->s_current_item_attrib[IVY_ASM_ATTRIB_IDENT] = v;
|
||||
}
|
||||
break;
|
||||
case HASH_INDEX:
|
||||
if (!strcmp(s, "index")) {
|
||||
state->s_current_item_attrib[IVY_ASM_ATTRIB_INDEX] = v;
|
||||
}
|
||||
break;
|
||||
case HASH_RECIPIENT:
|
||||
if (!strcmp(s, "recipient")) {
|
||||
state->s_current_item_attrib[IVY_ASM_ATTRIB_RECIPIENT] = v;
|
||||
}
|
||||
break;
|
||||
case HASH_SELECTOR:
|
||||
if (!strcmp(s, "selector")) {
|
||||
state->s_current_item_attrib[IVY_ASM_ATTRIB_SELECTOR] = v;
|
||||
}
|
||||
break;
|
||||
case HASH_GET:
|
||||
if (!strcmp(s, "get")) {
|
||||
state->s_current_item_attrib[IVY_ASM_ATTRIB_GET] = v;
|
||||
}
|
||||
break;
|
||||
case HASH_SET:
|
||||
if (!strcmp(s, "set")) {
|
||||
state->s_current_item_attrib[IVY_ASM_ATTRIB_SET] = v;
|
||||
}
|
||||
break;
|
||||
case HASH_PACKAGE:
|
||||
if (!strcmp(s, "package")) {
|
||||
state->s_current_item_attrib[IVY_ASM_ATTRIB_PACKAGE] = v;
|
||||
}
|
||||
break;
|
||||
case HASH_BLOCK:
|
||||
if (!strcmp(s, "block")) {
|
||||
state->s_current_item_attrib[IVY_ASM_ATTRIB_BLOCK] = v;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
ivy_asm_token_destroy(state->s_attrib_name);
|
||||
ivy_asm_token_destroy(state->s_attrib_value);
|
||||
|
||||
state->s_attrib_name = NULL;
|
||||
state->s_attrib_value = NULL;
|
||||
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
static enum ivy_status parse_property(
|
||||
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
|
||||
{
|
||||
struct class_parser_state *state
|
||||
= (struct class_parser_state *)asm_parser_get_state(ctx);
|
||||
|
||||
if (state->s_prev_token != IVY_ASM_TOK_NONE) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
state->s_prev_token = IVY_ASM_TOK_KEYWORD;
|
||||
state->s_current_item = ITEM_PROPERTY;
|
||||
memset(state->s_current_item_attrib, 0x0,
|
||||
sizeof state->s_current_item_attrib);
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
static enum ivy_status parse_var(
|
||||
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
|
||||
{
|
||||
struct class_parser_state *state
|
||||
= (struct class_parser_state *)asm_parser_get_state(ctx);
|
||||
|
||||
if (state->s_prev_token != IVY_ASM_TOK_NONE) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
state->s_prev_token = IVY_ASM_TOK_KEYWORD;
|
||||
state->s_current_item = ITEM_VAR;
|
||||
memset(state->s_current_item_attrib, 0x0,
|
||||
sizeof state->s_current_item_attrib);
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
static enum ivy_status parse_msgh(
|
||||
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
|
||||
{
|
||||
struct class_parser_state *state
|
||||
= (struct class_parser_state *)asm_parser_get_state(ctx);
|
||||
|
||||
if (state->s_prev_token != IVY_ASM_TOK_NONE) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
state->s_prev_token = IVY_ASM_TOK_KEYWORD;
|
||||
state->s_current_item = ITEM_MSGH;
|
||||
memset(state->s_current_item_attrib, 0x0,
|
||||
sizeof state->s_current_item_attrib);
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
static enum ivy_status parse_left_bracket(
|
||||
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
|
||||
{
|
||||
struct class_parser_state *state
|
||||
= (struct class_parser_state *)asm_parser_get_state(ctx);
|
||||
|
||||
if (state->s_prev_token != IVY_ASM_TOK_KEYWORD) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
if (state->s_in_attrib_list) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
state->s_in_attrib_list = true;
|
||||
state->s_prev_token = IVY_ASM_SYM_LEFT_BRACKET;
|
||||
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
static enum ivy_status parse_right_bracket(
|
||||
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
|
||||
{
|
||||
struct class_parser_state *state
|
||||
= (struct class_parser_state *)asm_parser_get_state(ctx);
|
||||
|
||||
if (!state->s_in_attrib_list) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
state->s_in_attrib_list = false;
|
||||
state->s_prev_token = IVY_ASM_SYM_RIGHT_BRACKET;
|
||||
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
static enum ivy_status parse_label(
|
||||
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
|
||||
{
|
||||
struct class_parser_state *state
|
||||
= (struct class_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) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
if (!state->s_in_attrib_list) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
if (state->s_attrib_name) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
state->s_prev_token = IVY_ASM_TOK_LABEL;
|
||||
state->s_attrib_name = tok;
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
static enum ivy_status parse_int(
|
||||
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
|
||||
{
|
||||
struct class_parser_state *state
|
||||
= (struct class_parser_state *)asm_parser_get_state(ctx);
|
||||
|
||||
if (state->s_prev_token != IVY_ASM_TOK_LABEL) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
if (!state->s_in_attrib_list) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
if (state->s_attrib_value) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
state->s_attrib_value = tok;
|
||||
state->s_prev_token = IVY_ASM_TOK_INT;
|
||||
return push_attrib(state);
|
||||
}
|
||||
|
||||
static enum ivy_status parse_linefeed(
|
||||
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
|
||||
{
|
||||
struct class_parser_state *state
|
||||
= (struct class_parser_state *)asm_parser_get_state(ctx);
|
||||
|
||||
if (state->s_in_attrib_list) {
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
if (state->s_prev_token != IVY_ASM_TOK_KEYWORD
|
||||
&& state->s_prev_token != IVY_ASM_SYM_RIGHT_BRACKET) {
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
if (state->s_current_item == 0) {
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
/* TODO write table entry. */
|
||||
switch (state->s_current_item) {
|
||||
case ITEM_PROPERTY:
|
||||
ivy_assembler_put_xval(
|
||||
ctx->p_assembler, IVY_ASM_XVAL_PROPERTY,
|
||||
state->s_current_item_attrib);
|
||||
break;
|
||||
case ITEM_VAR:
|
||||
ivy_assembler_put_xval(
|
||||
ctx->p_assembler, IVY_ASM_XVAL_MEMBER_VAR,
|
||||
state->s_current_item_attrib);
|
||||
break;
|
||||
case ITEM_MSGH:
|
||||
ivy_assembler_put_xval(
|
||||
ctx->p_assembler, IVY_ASM_XVAL_MESSAGE_HANDLER,
|
||||
state->s_current_item_attrib);
|
||||
break;
|
||||
default:
|
||||
return IVY_ERR_INTERNAL_FAILURE;
|
||||
}
|
||||
|
||||
state->s_current_item = 0;
|
||||
state->s_prev_token = IVY_ASM_TOK_NONE;
|
||||
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
static enum ivy_status parse_end(
|
||||
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
|
||||
{
|
||||
struct class_parser_state *state
|
||||
= (struct class_parser_state *)asm_parser_get_state(ctx);
|
||||
|
||||
if (state->s_in_attrib_list) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
switch (state->s_prev_token) {
|
||||
case IVY_ASM_KW_CLASS:
|
||||
case IVY_ASM_SYM_RIGHT_BRACKET:
|
||||
case IVY_ASM_TOK_NONE:
|
||||
asm_parser_pop_state(ctx, NULL);
|
||||
return IVY_OK;
|
||||
default:
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
}
|
||||
|
||||
static void init_state(struct ivy_asm_parser *ctx, struct parser_state *state)
|
||||
{
|
||||
ivy_assembler_begin_scope(
|
||||
ctx->p_assembler, IVY_ASM_SCOPE_CLASS, state->s_attrib);
|
||||
}
|
||||
|
||||
static void finish_state(struct ivy_asm_parser *ctx, struct parser_state *state)
|
||||
{
|
||||
ivy_assembler_end_scope(ctx->p_assembler);
|
||||
}
|
||||
|
||||
struct parser_state_type class_parser_state_type = {
|
||||
.n_init_state = init_state,
|
||||
.n_finish_state = finish_state,
|
||||
.n_state_size = sizeof(struct class_parser_state),
|
||||
.n_keyword_parsers = {
|
||||
KW_PARSER(PROPERTY, parse_property),
|
||||
KW_PARSER(VAR, parse_var),
|
||||
KW_PARSER(MSGH, parse_msgh),
|
||||
KW_PARSER(END, parse_end),
|
||||
},
|
||||
.n_symbol_parsers = {
|
||||
SYM_PARSER(LEFT_BRACKET, parse_left_bracket),
|
||||
SYM_PARSER(RIGHT_BRACKET, parse_right_bracket),
|
||||
},
|
||||
.n_token_parsers = {
|
||||
TOK_PARSER(LABEL, parse_label),
|
||||
TOK_PARSER(INT, parse_int),
|
||||
TOK_PARSER(LINEFEED, parse_linefeed),
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,6 +12,7 @@ extern struct parser_state_type selector_parser_state_type;
|
||||
extern struct parser_state_type atom_parser_state_type;
|
||||
extern struct parser_state_type import_parser_state_type;
|
||||
extern struct parser_state_type block_parser_state_type;
|
||||
extern struct parser_state_type class_parser_state_type;
|
||||
|
||||
static const struct parser_state_type *parser_state_types[] = {
|
||||
[ASM_PARSER_UNIT] = &unit_parser_state_type,
|
||||
@@ -21,6 +22,7 @@ static const struct parser_state_type *parser_state_types[] = {
|
||||
[ASM_PARSER_ATOM] = &atom_parser_state_type,
|
||||
[ASM_PARSER_IMPORT] = &import_parser_state_type,
|
||||
[ASM_PARSER_BLOCK] = &block_parser_state_type,
|
||||
[ASM_PARSER_CLASS] = &class_parser_state_type,
|
||||
};
|
||||
static const size_t nr_parser_state_types
|
||||
= sizeof parser_state_types / sizeof parser_state_types[0];
|
||||
|
||||
@@ -5,6 +5,15 @@
|
||||
#include <ivy/asm/assembler.h>
|
||||
#include <ivy/asm/lex.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
|
||||
#define HASH_BLOCK 0x14e5faab9ce0e362
|
||||
|
||||
#define __TOK_PARSER_INDEX(x) ((x) - __IVY_ASM_TOK_INDEX_BASE)
|
||||
#define __SYM_PARSER_INDEX(x) ((x) - __IVY_ASM_SYM_INDEX_BASE)
|
||||
#define __KW_PARSER_INDEX(x) ((x) - __IVY_ASM_KW_INDEX_BASE)
|
||||
|
||||
@@ -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