Add _ to the set of characters allowed in tokens

This commit is contained in:
2026-02-19 23:35:38 -05:00
parent 3f2f3416c6
commit d79ecef1fe
5 changed files with 38 additions and 27 deletions

View File

@@ -493,18 +493,19 @@ static int llex (LexState *ls, SemInfo *seminfo) {
while (1) {
char c = (char)ls->current;
size_t digit;
if (c >= '0' && c <= '9') digit = (size_t)(c - '0') + 1;
else if (c >= 'a' && c <= 'z') digit = (size_t)(c - 'a') + 11;
else if (c >= 'A' && c <= 'Z') digit = (size_t)(c - 'A') + 11;
if (c == '_') digit = 1;
else if (c >= '0' && c <= '9') digit = (size_t)(c - '0') + 2;
else if (c >= 'a' && c <= 'z') digit = (size_t)(c - 'a') + 12;
else if (c >= 'A' && c <= 'Z') digit = (size_t)(c - 'A') + 12;
else break;
tokval = tokval * 37 + digit;
tokval = tokval * 38 + digit;
toklen++;
save_and_next(ls);
}
if (toklen == 0 || toklen > 12 || ls->current == '_')
if (toklen == 0 || toklen > 12)
lexerror(ls, "invalid token literal", TK_TOKEN);
/* Pad to fixed width of 12 digits. */
for (int i = toklen; i < 12; i++) tokval *= 37;
for (int i = toklen; i < 12; i++) tokval *= 38;
seminfo->p = (void *)tokval;
return TK_TOKEN;
}