erick-alcachofa f9051e1c21
fix: Minor fixes
Fixed some minor mistakes (wrong messages/errors) due to copy/pasting
code.

Fixed that digits weren't allowed in identifiers before.

Also minor improvements in some functions/code parts.
2025-06-30 00:31:10 -06:00

50 lines
1.1 KiB
C++

#pragma once
#include <cstddef>
namespace arti::lang {
constexpr size_t CE_TAB_SIZE = 2;
static inline constexpr bool isLetter(char c) {
return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
}
static inline constexpr char toLower(char c) {
if (isLetter(c)) {
return (c | 0b00100000);
}
return c;
}
static inline constexpr bool isDigit(char c) {
return (c >= '0' && c <= '9');
}
static inline constexpr bool isFirstIdentChar(char c) {
return isLetter(c) || c == '_';
}
static inline constexpr bool isIdentChar(char c) {
return isLetter(c) || c == '_' || isDigit(c);
}
static inline constexpr bool isHexChar(char c) {
return isDigit(c) || ((toLower(c) >= 'a' && toLower(c) <= 'f'));
}
static inline constexpr bool isBinaryChar(char c) {
return c == '0' || c == '1';
}
static inline constexpr bool isOctalChar(char c) {
return (c >= '0' && c <= '7');
}
static inline constexpr bool isWhiteSpace(char c) {
return (c == ' ' || c == '\t' || c == '\n');
}
} // namespace arti::lang