stage1 初步实现

This commit is contained in:
zzy
2026-08-06 19:26:30 +08:00
parent a56b4cbb70
commit 314100afbc
35 changed files with 556 additions and 2236 deletions

View File

@@ -270,7 +270,8 @@ spl_tok_vec_t spl_lex(const char *source, const char *fname) {
/* Hex literal */
offset += 2;
col += 2;
while (offset < len && isxdigit((unsigned char)source[offset])) {
while (offset < len &&
(isxdigit((unsigned char)source[offset]) || source[offset] == '_')) {
offset++;
col++;
}
@@ -280,7 +281,8 @@ spl_tok_vec_t spl_lex(const char *source, const char *fname) {
/* Binary literal */
offset += 2;
col += 2;
while (offset < len && (source[offset] == '0' || source[offset] == '1')) {
while (offset < len && (source[offset] == '0' || source[offset] == '1' ||
source[offset] == '_')) {
offset++;
col++;
}
@@ -290,7 +292,8 @@ spl_tok_vec_t spl_lex(const char *source, const char *fname) {
/* Octal literal */
offset += 2;
col += 2;
while (offset < len && source[offset] >= '0' && source[offset] <= '7') {
while (offset < len && ((source[offset] >= '0' && source[offset] <= '7') ||
source[offset] == '_')) {
offset++;
col++;
}
@@ -299,7 +302,8 @@ spl_tok_vec_t spl_lex(const char *source, const char *fname) {
}
/* Decimal integer or float */
while (offset < len && isdigit((unsigned char)source[offset])) {
while (offset < len &&
(isdigit((unsigned char)source[offset]) || source[offset] == '_')) {
offset++;
col++;
}