Use compile-time matchers for RegEx expressions - #1500
Open
alex-thiessen-for-siemens wants to merge 1 commit into
Open
alex-thiessen-for-siemens wants to merge 1 commit into
alex-thiessen-for-siemens wants to merge 1 commit into
Conversation
alex-thiessen-for-siemens
force-pushed
the
fix/regex-constexpr
branch
from
September 20, 2026 21:58
6a37f27 to
87573c2
Compare
Replace scanner and emitter expressions with private C++11 compile-time matchers. Eliminate runtime AST construction, dynamic vector storage, and static destruction in YAML::RegEx. Keep stream matcher instantiation inside yaml-cpp so Windows DLL consumers do not require unexported Stream internals. Add compile-time and boundary tests and a reproducible benchmark for matching and parser/emitter throughput. Reference verification: not applicable This changes only an internal matcher representation and lifetime behavior; it does not change YAML syntax, schema resolution, or native conversion semantics.
alex-thiessen-for-siemens
force-pushed
the
fix/regex-constexpr
branch
from
September 20, 2026 22:09
87573c2 to
2e28734
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR modernizes the internal regular expression engine used by the
scanner and emitter, converting expressions to compile-time matchers
implemented in C++11.
(
std::vector<RegEx>), and static destruction of global regularexpression objects (
YAML::Exp::*).deinitialization bugs reported in YAML Emitter using YAML::DoubleQuoted when emitted in a destructor of a staticly created struct/class #1281 and Avoid static destructors during program exit #1471.
CharBitSet) backed bystd::array<std::uint64_t, 4>with compile-time membership tests.templates (
Or<Pattern...>,And<Pattern...>,Seq<Pattern...>).emitter call sites.
Performance & Allocation Benchmarks
A dedicated microbenchmark (
regex_benchmarkinutil/regex_benchmark.cpp) was executed on Linux x86_64 to compareagainst the baseline engine:
allocations during initialization and recursive evaluation.
construction, pattern matching, and destruction.
Exp::Word: ~288 ns / iteration (0 allocations)Exp::Chomp: ~22 ns / iteration (0 allocations)Exp::DocStart: ~15 ns / iteration (0 allocations)improved due to elimination of pointer indirection and heap lookups
in hot scanning loops.
Verification
multi-character negation tests in
test/regex_test.cpp.