Reset transient parser state in Parser3::reset #10

Merged
andrew merged 1 commits from weaselbot/weaseljson:weaselbot/issue-2 into main 2026-06-18 20:09:33 +00:00
Member

Closes #2

Ensures WeaselJsonParser_reset restores the parser to its newly-created state by clearing inKey and other per-parse transient state (utf8Codepoint, utf16Surrogate, minCodepoint, numDfa, strDfa) in addition to rewinding the symbol stack. Adds a regression test for the reported callback misrouting.

Bench and DFA tests with SIGSYS failures are unrelated to this change; the parser lifecycle tests pass.

Closes #2 Ensures `WeaselJsonParser_reset` restores the parser to its newly-created state by clearing `inKey` and other per-parse transient state (`utf8Codepoint`, `utf16Surrogate`, `minCodepoint`, `numDfa`, `strDfa`) in addition to rewinding the symbol stack. Adds a regression test for the reported callback misrouting. Bench and DFA tests with `SIGSYS` failures are unrelated to this change; the parser lifecycle tests pass.
weaselbot added 1 commit 2026-06-18 14:34:53 +00:00
Parser3::reset: clear inKey and other per-parse transient state
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 52s
CI / pre-commit (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 49s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m30s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m24s
919b89c842
WeaselJsonParser_reset is documented to restore the parser to its
newly-created state, but reset() only rewound the symbol stack.  The
inKey flag and transient DFA/codepoint state from the previous parse
leaked into the next parse, so a top-level string after a mid-key
reset was delivered via on_key_data instead of on_string_data.

Reset inKey to false and clear utf8Codepoint, utf16Surrogate,
minCodepoint, numDfa, and strDfa so the next document starts fresh.

Add a test that reproduces the reported misrouting.
weaselbot marked the pull request as ready for review 2026-06-18 14:35:32 +00:00
andrew merged commit 7c1c18fe6f into main 2026-06-18 20:09:33 +00:00
andrew deleted branch weaselbot/issue-2 2026-06-18 20:09:33 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weaselab/weaseljson#10