Support explicit integer base prefixes and reject malformed literals
Build / AerScript (push) Successful in 39s

This commit is contained in:
2026-10-26 22:25:20 +01:00
parent 3c83579fb6
commit ab323701d0
2 changed files with 131 additions and 4 deletions
+16
View File
@@ -176,8 +176,24 @@ static sxi32 TokenizeAerScript(SyStream *pStream, SyToken *pToken, void *pUserDa
while(pStream->zText < pStream->zEnd && (pStream->zText[0] == '0' || pStream->zText[0] == '1')) {
pStream->zText++;
}
} else if(c == 'o' || c == 'O') {
/* Octal digit stream */
pStream->zText++;
while(pStream->zText < pStream->zEnd && pStream->zText[0] >= '0' && pStream->zText[0] <= '7') {
pStream->zText++;
}
}
}
if((pToken->nType & PH7_TK_INTEGER) && pStream->zText < pStream->zEnd && pStream->zText[0] < 0xc0 &&
(SyisAlphaNum(pStream->zText[0]) || pStream->zText[0] == '_')) {
/* Flag an integer literal followed by identifier characters [i.e: 0b102,
* 0x41G, 0b10foo]. The offending character is left in the stream and its
* code is stored in pUserData, which numeric tokens do not use otherwise,
* so the compiler can reject the literal with a precise diagnostic. A
* following keyword or alphabetic operator [i.e: 65is int] is not part
* of the literal. */
pToken->pUserData = SX_INT_TO_PTR(pStream->zText[0]);
}
/* Record token length */
pStr->nByte = (sxu32)((const char *)pStream->zText - pStr->zString);
return SXRET_OK;