katef / libfsm

DFA regular expression library & friends
BSD 2-Clause "Simplified" License
931 stars 52 forks source link

Endleaf rejiggle, .fsm syntax for endids, refactor endid get/set api, various related bugfixes #479

Closed katef closed 3 months ago

katef commented 3 months ago

I did quite a few things here, all focused around the endleaf callbacks, and by extension the endid mechanism. I fixed a few small bugs, and got distracted trying to tidy up a bit.

Anyway here's what we get:

The .fsm syntax for endids looks like this:

; ./build/bin/re -r pcre -bpl fsm 'ab?c' 'abc*'
0  ->  1 "a"; # e.g. "a"
1  ->  2 "b"; # e.g. "ab"
1  ->  3 "c"; # e.g. "ac"
2  ->  4 "c"; # e.g. "abc"
4  ->  5 "c"; # e.g. "abcc"
5  ->  5 "c"; # e.g. "abcc"

start: 0;
end:   2 = [0], 3 = [0], 4 = [0, 1], 5 = [0];

and renders out like: image