asm: implement parsing of classes, dot-mnemonics
This commit is contained in:
10
asm/lex.c
10
asm/lex.c
@@ -29,6 +29,9 @@ static struct lex_token_def keywords[] = {
|
||||
LEX_TOKEN_DEF(IVY_ASM_KW_CLASS, "@class"),
|
||||
LEX_TOKEN_DEF(IVY_ASM_KW_BLOCK, "@block"),
|
||||
LEX_TOKEN_DEF(IVY_ASM_KW_PACKAGE, "@package"),
|
||||
LEX_TOKEN_DEF(IVY_ASM_KW_PROPERTY, "@property"),
|
||||
LEX_TOKEN_DEF(IVY_ASM_KW_VAR, "@var"),
|
||||
LEX_TOKEN_DEF(IVY_ASM_KW_MSGH, "@msgh"),
|
||||
LEX_TOKEN_DEF(IVY_ASM_KW_END, "@end"),
|
||||
};
|
||||
static const size_t nr_keywords = sizeof keywords / sizeof keywords[0];
|
||||
@@ -515,7 +518,7 @@ static enum ivy_status push_keyword(
|
||||
static enum ivy_status read_line_comment(struct ivy_asm_lexer *lex)
|
||||
{
|
||||
while (true) {
|
||||
int c = advance(lex);
|
||||
int c = peek(lex);
|
||||
|
||||
if (c == IVY_ERR_EOF || c == '\n') {
|
||||
break;
|
||||
@@ -524,6 +527,8 @@ static enum ivy_status read_line_comment(struct ivy_asm_lexer *lex)
|
||||
if (c < 0) {
|
||||
return c;
|
||||
}
|
||||
|
||||
advance(lex);
|
||||
}
|
||||
|
||||
return IVY_OK;
|
||||
@@ -1033,6 +1038,9 @@ const char *ivy_asm_keyword_to_string(enum ivy_asm_keyword keyword)
|
||||
ENUM_STR(IVY_ASM_KW_BLOCK);
|
||||
ENUM_STR(IVY_ASM_KW_IMPORT);
|
||||
ENUM_STR(IVY_ASM_KW_PACKAGE);
|
||||
ENUM_STR(IVY_ASM_KW_PROPERTY);
|
||||
ENUM_STR(IVY_ASM_KW_VAR);
|
||||
ENUM_STR(IVY_ASM_KW_MSGH);
|
||||
ENUM_STR(IVY_ASM_KW_END);
|
||||
default:
|
||||
return "";
|
||||
|
||||
Reference in New Issue
Block a user