https://gitlab.synchro.net/main/sbbs/-/commit/735fc016ec74217075aef86d
Modified Files:
src/syncterm/CMakeLists.txt GNUmakefile Wren.adoc src/syncterm/re1/parse.y pike.c regexp.h y.tab.c src/syncterm/wren_bind.c wren_host.c wren_host_internal.h
Log Message:
SyncTERM: add Hook.onMatch streaming-regex input hooks via RE1
`Hook.onMatch(pattern, fn)` registers a regex against the inbound byte
stream. Implemented as a streaming Pike VM on top of the vendored
RE1 (BSD-3-Clause): each byte feeds one VM step returning tri-state
{MATCH, IMPOSSIBLE, PENDING}; the dispatcher trims a byte off the
front on IMPOSSIBLE, fires fn and trims through the match on MATCH,
waits on PENDING. Filtered, unfiltered, byte-equality, and regex
input hooks all share the same per-event array, preserving
registration order across all forms.
RE1 changes are additive: new pikevm_new/free/start/step/match
symbols in pike.c reuse the existing file-local helpers; original
pikevm() stays untouched. fatal() now consults a host-installed
hook so RE1 syntax errors longjmp back to the Wren binding instead
of exit(2)'ing SyncTERM.
Patterns whose leading construct can match without consuming a byte
(*, +, ? at the start) are rejected at registration time Ä without
that constraint the IMPOSSIBLE-shift trick can't trim the buffer and
matches would silently start being dropped past the 4 KB cap.
Build wires re1/{compile,pike,sub,y.tab}.c with -w to confine the pedagogical-code warnings to RE1's TUs. Wren.adoc grows a regex
section documenting the limited grammar (no backslash escapes, no
character classes, no anchors), the leftmost-first-completing match
semantics, and the leading-anchor constraint.
Co-Authored-By: Claude Opus 4.7 (1M context) <
noreply@anthropic.com>
---
þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net