Table-Driven Character Classification (Lookup Table/LUT) and Bitmask Accumulation
One of the ways that I'm designing my parsers is using Bitmask Accumulation in combination with a table lookup.
Essentially, I create a table of 256 length and lookup each character in it and use bitwise operator
This is a form of classification or categorization.
Then we simply can ask our 8 bit integer if the input for example for the code in the picture:
- Is it possible for it to have IPv4
- Possibility of IPv6
- Contains any specific characters that need special handling like % # ? / \
- Any invalid code points
- Possibility of existence of punycodes
- Existence of Unicode
Of course depending on the table, we can find out other information as well.
This helps the algorithm to completely disable a whole lot of checks.
One of the ways that I'm designing my parsers is using Bitmask Accumulation in combination with a table lookup.
Essentially, I create a table of 256 length and lookup each character in it and use bitwise operator
or (|) to accumulate them all into one single uint8_t integer which each bit of that integer can convey information about the types of characters that gave it.This is a form of classification or categorization.
Then we simply can ask our 8 bit integer if the input for example for the code in the picture:
- Is it possible for it to have IPv4
- Possibility of IPv6
- Contains any specific characters that need special handling like % # ? / \
- Any invalid code points
- Possibility of existence of punycodes
- Existence of Unicode
Of course depending on the table, we can find out other information as well.
This helps the algorithm to completely disable a whole lot of checks.
👍1
Instantiating a generator as a template for certain reasons prevents compilers such as GCC and Clang from identifying it as a coroutine, resulting in errors indicating that
std::coroutine_traits was not found. Implementing a non-templated override resolves this issue. It is uncertain whether this constitutes a compiler bug or standard behavior.
Web++: A C++ Web Framework
I wanted to use std::indirect, but I needed something pimpl idiom that: - consteval constructible-only - consteval copyable-only Ended up writing custom nullable_indirect; at least for now.
Called it
consteval_copyable and removed a whole bunch of repetitive constructors.👍1
Let's hope introducing "dynamic scopes" to a highly templated and complex pipeline-builder "context" type is not gonna backfire.
The user-facing pipeline API will look cute though.
The user-facing pipeline API will look cute though.
👍1😭1