More specific error messages

This commit is contained in:
Igor M 2024-03-17 14:10:36 +02:00
parent 7b098ff98c
commit dc06b1b6d8
2 changed files with 6 additions and 2 deletions

View file

@ -76,7 +76,7 @@ static AsmError push_data(char *input, size_t len, ByteVec *out, Token *tok,
}
out->len += tok->num;
} else {
return ErrUnexpectedToken;
return ErrNeedsDataLiteral;
}
*tok = token(input, len, tok->start + tok->len);
if (tok->kind == TokNewline || tok->kind == TokEOF) {
@ -85,7 +85,7 @@ static AsmError push_data(char *input, size_t len, ByteVec *out, Token *tok,
if (tok->kind == TokComma) {
continue;
}
return ErrInvalidToken;
return ErrNeedCommaOrNewline;
}
}

View file

@ -26,6 +26,8 @@ typedef enum AsmError_e {
ErrStringDataNotByte,
ErrAlignNeedsNumber,
ErrAlignNeedsPow2,
ErrNeedCommaOrNewline,
ErrNeedsDataLiteral,
} AsmError;
char *ERRORS[] = {
"Success",
@ -55,4 +57,6 @@ char *ERRORS[] = {
"String literals can be used only in .db directive",
".align requires a number",
".align requires a power of two as an argument",
"Need comma or newline after data literal",
"Data literal expects a number or a string",
};