Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/regex/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME regex
SOURCES regex.cc preprocess.h)
SOURCES regex.cc iregexp.h permissive.h)

if(SOURCEMETA_CORE_INSTALL)
sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME regex)
Expand Down
9 changes: 8 additions & 1 deletion src/core/regex/include/sourcemeta/core/regex.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ enum class RegexIndex : std::uint8_t {
/// The dialects that a regular expression pattern can be interpreted with.
enum class RegexDialect : std::uint8_t {
/// A permissive superset of ECMA 262 with PCRE2 extensions
Permissive
Permissive,
/// Strict RFC 9485 I-Regexp, where any pattern outside the grammar is
Comment thread
jviotti marked this conversation as resolved.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The docstring describes this dialect as "Strict RFC 9485 I-Regexp" but the implementation intentionally deviates from the RFC for ^ and $ (they retain PCRE2 assertion semantics rather than being treated as literals per the grammar). Consider adjusting the wording to clarify that this follows the RFC 9485 Section 5.4 engine mapping rather than a pure literal interpretation of the grammar, so callers understand the contract around these characters.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/core/regex/include/sourcemeta/core/regex.h, line 77:

<comment>The docstring describes this dialect as "Strict RFC 9485 I-Regexp" but the implementation intentionally deviates from the RFC for `^` and `$` (they retain PCRE2 assertion semantics rather than being treated as literals per the grammar). Consider adjusting the wording to clarify that this follows the RFC 9485 Section 5.4 engine mapping rather than a pure literal interpretation of the grammar, so callers understand the contract around these characters.</comment>

<file context>
@@ -73,7 +73,10 @@ enum class RegexIndex : std::uint8_t {
   /// A permissive superset of ECMA 262 with PCRE2 extensions
-  Permissive
+  Permissive,
+  /// Strict RFC 9485 I-Regexp, where any pattern outside the grammar is
+  /// rejected and matching considers the whole input
+  IRegexp
</file context>
Suggested change
/// Strict RFC 9485 I-Regexp, where any pattern outside the grammar is
/// RFC 9485 I-Regexp (Section 5.4 engine mapping), where any pattern outside the grammar is

/// rejected and matching considers the whole input. Patterns are
/// interpreted through the RFC 9485 Section 5.4 engine mapping, so an
/// unescaped caret or dollar acts as an assertion instead of a literal
/// and rejects quantification
IRegexp
};

/// @ingroup regex
Expand All @@ -83,6 +89,7 @@ enum class RegexDialect : std::uint8_t {
///
/// - Permissive regexes are NOT automatically anchored
/// - Permissive regexes assume `DOTALL`
/// - RFC 9485 regexes match the whole input
/// - Regexes assume Unicode
/// - Regexes are case sensitive
/// - No matching happens (only boolean validation)
Expand Down
Loading
Loading