mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Improve RGBASM test coverage
This commit is contained in:
@@ -624,7 +624,7 @@ static uint32_t readBracketedMacroArgNum() {
|
||||
}
|
||||
|
||||
if (c >= '0' && c <= '9') {
|
||||
uint32_t n = readDecimalNumber(0);
|
||||
uint32_t n = readDecimalNumber(bumpChar());
|
||||
if (n > INT32_MAX) {
|
||||
error("Number in bracketed macro argument is too large");
|
||||
return 0;
|
||||
@@ -1165,11 +1165,11 @@ static uint32_t readOctalNumber() {
|
||||
}
|
||||
|
||||
static uint32_t readDecimalNumber(int initial) {
|
||||
uint32_t value = initial ? initial - '0' : 0;
|
||||
bool empty = !initial;
|
||||
assume(initial >= '0' && initial <= '9');
|
||||
uint32_t value = initial - '0';
|
||||
|
||||
for (int c = peek();; c = nextChar()) {
|
||||
if (c == '_' && !empty) {
|
||||
if (c == '_') {
|
||||
continue;
|
||||
} else if (c >= '0' && c <= '9') {
|
||||
c = c - '0';
|
||||
@@ -1181,12 +1181,6 @@ static uint32_t readDecimalNumber(int initial) {
|
||||
warning(WARNING_LARGE_CONSTANT, "Integer constant is too large");
|
||||
}
|
||||
value = value * 10 + c;
|
||||
|
||||
empty = false;
|
||||
}
|
||||
|
||||
if (empty) {
|
||||
error("Invalid integer constant, no digits");
|
||||
}
|
||||
|
||||
return value;
|
||||
@@ -1393,9 +1387,9 @@ static void appendExpandedString(std::string &str, std::string const &expanded)
|
||||
case '\n':
|
||||
str += "\\n";
|
||||
break;
|
||||
// LCOV_EXCL_START
|
||||
case '\r':
|
||||
// A literal CR in a string may get treated as a LF, so '\r' is not tested.
|
||||
// LCOV_EXCL_START
|
||||
str += "\\r";
|
||||
break;
|
||||
// LCOV_EXCL_STOP
|
||||
@@ -1637,16 +1631,9 @@ static bool isGarbageCharacter(int c) {
|
||||
&& (c == '\0' || !strchr("; \t~[](),+-*/|^=!<>:&%`\"\r\n\\", c));
|
||||
}
|
||||
|
||||
static void skipGarbageCharacters(int c) {
|
||||
static void reportGarbageCharacters(int c) {
|
||||
// '#' can be garbage if it doesn't start a raw string or identifier
|
||||
assume(isGarbageCharacter(c) || c == '#');
|
||||
|
||||
// Do not report weird characters when capturing, it'll be done later
|
||||
if (lexerState->capturing) {
|
||||
skipChars(isGarbageCharacter);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isGarbageCharacter(peek())) {
|
||||
// At least two characters are garbage; group them into one error report
|
||||
std::string garbage = printChar(c);
|
||||
@@ -1966,7 +1953,7 @@ static Token yylex_NORMAL() {
|
||||
if (raw && startsIdentifier(peek())) {
|
||||
c = bumpChar();
|
||||
} else if (!startsIdentifier(c)) {
|
||||
skipGarbageCharacters(c);
|
||||
reportGarbageCharacters(c);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "helpers.hpp" // assume
|
||||
|
||||
#include "asm/fixpoint.hpp"
|
||||
#include "asm/fstack.hpp"
|
||||
#include "asm/lexer.hpp"
|
||||
@@ -77,9 +79,9 @@ void opt_Parse(char const *s) {
|
||||
result = sscanf(&s[1], "%x", &padByte);
|
||||
if (result != 1) {
|
||||
error("Invalid argument for option 'p'");
|
||||
} else if (padByte > 0xFF) {
|
||||
error("Argument for option 'p' must be between 0 and 0xFF");
|
||||
} else {
|
||||
// Two characters cannot be scanned as a hex number greater than 0xFF
|
||||
assume(padByte <= 0xFF);
|
||||
opt_P(padByte);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -325,9 +325,9 @@ void Expression::makeUnaryOp(RPNCommand op, Expression &&src) {
|
||||
case RPN_TZCOUNT:
|
||||
data = val != 0 ? ctz(uval) : 32;
|
||||
break;
|
||||
// LCOV_EXCL_START
|
||||
default:
|
||||
// `makeUnaryOp` should never be called with a non-unary operator!
|
||||
// LCOV_EXCL_START
|
||||
unreachable_();
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
@@ -467,9 +467,9 @@ void Expression::makeBinaryOp(RPNCommand op, Expression &&src1, Expression const
|
||||
|
||||
data = op_exponent(lval, rval);
|
||||
break;
|
||||
// LCOV_EXCL_START
|
||||
default:
|
||||
// `makeBinaryOp` should never be called with a non-binary operator!
|
||||
// LCOV_EXCL_START
|
||||
unreachable_();
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
Reference in New Issue
Block a user