qntm / greenery

Regular expression manipulation library
http://qntm.org/greenery
MIT License
331 stars 40 forks source link

Make FSM public #105

Closed MegaIng closed 7 months ago

MegaIng commented 9 months ago

This has come up at least once already. I would like to also use the same FSM class greenery for my semi-fork interegular which primarily has a difference focus in performance tradeoffs, which I don't think should conflict with the base usage, and a significantly different regex frontend that adds syntax that more closely matches python's re module, which is a non-goal for greenery.

It depends on how you want to do that @qntm

I am fine with either.

This is motivated by someone contributing a performance improvement to my version, that I think would also be beneficial for greenery and also depending on my internal `FSM class in a separate package. People are going to want this FSM class and they are going to use it, so making it public seems like a reasonable idea. I think especially with the improvement of treating character ranges as one, which I haven't ported, your version is just better than mine right now.

qntm commented 9 months ago

I will consider this. Making fsm public as part of the greenery package is probably the easiest way to go about this.

I'm a little concerned that the current interface on the fsm module is a little strange. Note that, for example, following #99 the Charclass class is now an internal dependency of Fsm, not vice versa. Also, this would require "freezing" the API of the fsm module. Not that that API is changing all that rapidly...

qntm commented 9 months ago

@MegaIng Give greenery-4.2.0 a whirl.