aboutsummaryrefslogtreecommitdiffhomepage
path: root/lexlib/CharacterCategory.h
diff options
context:
space:
mode:
Diffstat (limited to 'lexlib/CharacterCategory.h')
-rw-r--r--lexlib/CharacterCategory.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/lexlib/CharacterCategory.h b/lexlib/CharacterCategory.h
index 767d79670..d1ac39152 100644
--- a/lexlib/CharacterCategory.h
+++ b/lexlib/CharacterCategory.h
@@ -28,6 +28,23 @@ bool IsIdContinue(int character);
bool IsXidStart(int character);
bool IsXidContinue(int character);
+class CharacterCategoryMap {
+private:
+ std::vector<unsigned char> dense;
+public:
+ CharacterCategoryMap() noexcept;
+ CharacterCategory CategoryFor(int character) const {
+ if (static_cast<size_t>(character) < dense.size()) {
+ return static_cast<CharacterCategory>(dense[character]);
+ } else {
+ // binary search through ranges
+ return CategoriseCharacter(character);
+ }
+ }
+ int Size() const noexcept;
+ void Optimize(int countCharacters);
+};
+
}
#endif