Skip to content

Add pluggable regex engine support#7

Merged
rayokota merged 7 commits into
masterfrom
regex-option
Jul 5, 2026
Merged

Add pluggable regex engine support#7
rayokota merged 7 commits into
masterfrom
regex-option

Conversation

@rayokota

@rayokota rayokota commented Jul 4, 2026

Copy link
Copy Markdown
Owner

No description provided.

@rayokota rayokota changed the title Add pluggable regex support Add pluggable regex engine support Jul 4, 2026
@rayokota
rayokota requested a review from Copilot July 4, 2026 04:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a pluggable regex layer to jsonata-cpp by replacing direct std::regex usage in JSONata evaluation with an engine-agnostic IRegex interface, allowing alternative engines (e.g., RE2) to be injected while keeping the default behavior equivalent to the existing std::regex implementation.

Changes:

  • Add IRegex / RegexEngine abstractions plus a default StdRegex implementation and wire regex literal compilation through the injected engine.
  • Update evaluator/runtime regex paths ($match, $contains, $replace, $split, regex-as-function application) to work with std::shared_ptr<IRegex> instead of std::regex.
  • Add an optional RE2-backed test target demonstrating a non-std::regex engine integration.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
test/RE2EngineTest.cpp Adds RE2-based integration tests for regex behavior with an injected engine.
test/RE2Engine.h Declares a test-only RE2-backed IRegex implementation and engine factory.
test/RE2Engine.cpp Implements the RE2-backed IRegex adapter and engine factory.
src/jsonata/utils/Signature.cpp Updates signature/type detection to treat regex values as shared_ptr<IRegex>.
src/jsonata/Tokenizer.cpp Compiles regex literals via RegexEngine and parses flags into RegexFlags.
src/jsonata/StdRegex.cpp Adds the default std::regex-backed IRegex implementation and defaultRegexEngine().
src/jsonata/Parser.cpp Threads RegexEngine into parsing/tokenization.
src/jsonata/Jsonata.cpp Stores and propagates RegexEngine; updates regex application logic to use IRegex.
src/jsonata/Functions.cpp Ports regex-related functions to IRegex and compiles dynamic string patterns via the current engine.
include/jsonata/utils/Signature.h Includes IRegex so regex values can be recognized in signatures.
include/jsonata/Tokenizer.h Updates tokenizer API to accept/store a RegexEngine and return compiled IRegex.
include/jsonata/StdRegex.h Declares the StdRegex IRegex adapter.
include/jsonata/Parser.h Extends parse() signature to accept a RegexEngine.
include/jsonata/Jsonata.h Extends constructors/factory to accept a RegexEngine and exposes getRegexEngine().
include/jsonata/IRegex.h Introduces IRegex, RegexMatch, RegexFlags, RegexEngine, and defaultRegexEngine().
include/jsonata/Functions.h Updates regex function signatures to use shared_ptr<IRegex>.
CMakeLists.txt Adds optional JSONATA_BUILD_RE2_TEST target that links RE2 when available.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/jsonata/Tokenizer.cpp
Comment thread src/jsonata/Functions.cpp
Comment thread src/jsonata/Functions.cpp
Comment thread src/jsonata/Jsonata.cpp
Comment thread src/jsonata/Jsonata.cpp
Comment thread test/RE2EngineTest.cpp

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Comment thread src/jsonata/utils/Signature.cpp Outdated
Comment thread src/jsonata/Functions.cpp Outdated
Comment thread src/jsonata/Functions.cpp Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Comment thread src/jsonata/Tokenizer.cpp

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Comment thread src/jsonata/Tokenizer.cpp
Comment thread src/jsonata/Functions.cpp Outdated
Comment thread test/RE2Engine.cpp

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Comment thread src/jsonata/Jsonata.cpp
Comment thread src/jsonata/Tokenizer.cpp
Comment thread src/jsonata/Functions.cpp

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.

Comment thread src/jsonata/Tokenizer.cpp
Comment thread src/jsonata/Jsonata.cpp
Comment thread src/jsonata/Functions.cpp
Comment thread src/jsonata/Functions.cpp
Comment thread include/jsonata/Functions.h

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Comment thread src/jsonata/Tokenizer.cpp
Comment thread include/jsonata/IRegex.h Outdated
@rayokota
rayokota requested a review from Copilot July 5, 2026 00:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.

Comment thread src/jsonata/JException.cpp
@rayokota
rayokota merged commit c16b9ca into master Jul 5, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants