Reuse startsIdentifier and continuesIdentifier functions (#1695)

This commit is contained in:
Rangi
2025-05-19 15:31:26 -04:00
committed by GitHub
parent 4f2400c15b
commit 126b1e5726
6 changed files with 32 additions and 48 deletions

View File

@@ -6,6 +6,15 @@
#include <stdint.h>
#include <stdio.h>
bool startsIdentifier(int c) {
// This returns false for anonymous labels, which internally start with a '!'
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '.' || c == '_';
}
bool continuesIdentifier(int c) {
return startsIdentifier(c) || (c >= '0' && c <= '9') || c == '#' || c == '$' || c == '@';
}
char const *printChar(int c) {
// "'A'" + '\0': 4 bytes
// "'\\n'" + '\0': 5 bytes