erick-alcachofa 85a34bdd65
feat: Added Token, Tokenizer, Generator, and some utilities
Initial version of Tokenizer and Token
Generator template for coroutines (used in tokenizer)
Utilities like string related functions, TrieMap, and error handling

TODO: Add tests for Tokenizer
TODO: Add tests for Generator
2025-03-10 01:20:23 -06:00

50 lines
1.0 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 == '_';
}
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