ReviewOS

zig-utils/zig-regex

ECMAScript: compile and match the empty pattern

#11
Closed chris opened this 9 days ago ·
9 days ago

zig-js issue zig-utils/zig-js#213 needs JavaScriptCore-compatible empty regular expressions.

ECMAScript treats an empty pattern as a valid zero-width regex, but Regex.compileWithFlags currently returns RegexError.EmptyPattern before the parser can build its existing empty AST node.

Acceptance criteria:

  • Empty patterns compile successfully.
  • find and findFrom return a zero-width match at the requested valid position.
  • Iteration/search callers can advance after zero-width matches without an engine loop.
  • Existing non-empty behavior remains covered.
  • README/API documentation no longer claims empty patterns are rejected.
9 days ago

Implemented and pushed to main in fd4927c. Empty ECMAScript patterns now compile and produce zero-width matches at the start, requested findFrom position, and end of input. Focused regression: zig test src/regex.zig --test-filter "compile empty pattern" (1/1 passed). zig-utils/zig-js#213 will consume this directly.

Sign in to comment on this issue.