parse_word deals with characters now
Just takes the character literally as a number.
This commit is contained in:
11
asm/parser.c
11
asm/parser.c
@@ -72,7 +72,8 @@ data_type_t parse_data_type(const char *cstr, size_t length)
|
||||
|
||||
perr_t parse_word(token_t token, word *ret)
|
||||
{
|
||||
assert(token.type == TOKEN_LITERAL_NUMBER);
|
||||
if (token.type == TOKEN_LITERAL_NUMBER)
|
||||
{
|
||||
bool is_negative = token.str_size > 1 && token.str[0] == '-';
|
||||
word w = 0;
|
||||
if (is_negative)
|
||||
@@ -105,6 +106,14 @@ perr_t parse_word(token_t token, word *ret)
|
||||
}
|
||||
*ret = w;
|
||||
return PERR_OK;
|
||||
}
|
||||
else if (token.type == TOKEN_LITERAL_CHAR)
|
||||
{
|
||||
*ret = token.str[0];
|
||||
return PERR_OK;
|
||||
}
|
||||
else
|
||||
return PERR_NOT_A_NUMBER;
|
||||
}
|
||||
|
||||
perr_t parse_inst_with_type(token_stream_t *stream, inst_t *ret,
|
||||
|
||||
Reference in New Issue
Block a user