parse_word deals with characters now

Just takes the character literally as a number.
This commit is contained in:
2023-10-31 20:38:03 +00:00
parent 228f548bd9
commit fa640f13e8

View File

@@ -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)
@@ -106,6 +107,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,
size_t oplength)