Support explicit integer base prefixes and reject malformed literals
Build / AerScript (push) Successful in 39s
Build / AerScript (push) Successful in 39s
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user