Fix trainers.party parser failing on apostrophes (#6938)

This commit is contained in:
jfb1337 2025-05-21 09:41:18 +01:00 committed by GitHub
parent c485ae4e90
commit ce9bbcc3b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -459,7 +459,7 @@ static bool match_identifier(struct Parser *p, struct Token *t)
if (!peek_char(&p_, &c))
break;
if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') || ('0' <= c && c <= '9') || c == '_')
if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') || ('0' <= c && c <= '9') || c == '_'|| c == '\'')
;
else
break;
@ -493,7 +493,7 @@ static bool match_human_identifier(struct Parser *p, struct Token *t)
if (!peek_char(&p_, &c))
break;
if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') || c == '_' || c == '-' || c == ' ')
if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') || c == '_' || c == '-' || c == ' ' || c == '\'')
;
else if (p_.offset > t->begin && ('0' <= c && c <= '9'))
;
@ -573,7 +573,7 @@ static bool match_move_identifier(struct Parser *p, struct Token *t)
if (!peek_char(&p_, &c))
break;
if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') || ('0' <= c && c <= '9') || c == '_' || c == '-' || c == ' ' || c == ',')
if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') || ('0' <= c && c <= '9') || c == '_' || c == '-' || c == ' ' || c == ',' || c == '\'')
;
else
break;
@ -1581,6 +1581,8 @@ static void fprint_constant(FILE *f, const char *prefix, struct String s)
fputc(c, f);
else if ('a' <= c && c <= 'z')
fputc(c - 'a' + 'A', f);
else if (c == '\'')
;
else
fputc('_', f);
}