Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement string pattern matching #86

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft

Conversation

Aeledfyr
Copy link
Contributor

Adds a safe pure-Rust implementation of Lua's pattern matching, ported from PRLua. The implementation has been modified to be non-recursive and manually manage a stack for backtracking, and yields back to the executor every so often to prevent hanging on pathological patterns.

This does not yet handle consuming fuel, but it would be straightforward to add, as it can already yield back to the executor.

This currently has three different implementations of the pattern matching engines; one recursive, one sequential, and one built using the async sequence API to allow yielding. The recursive impl is the theoretical fastest (though it has issues with fragile optimizations), but it can't handle yielding to the executor, so it can't be used on untrusted input. I'll likely prune the alternate implementations, but leave them available somewhere if they might be useful for running trusted patterns.

I'm still working on cleaning this up, but it's usable in its current state.

This adds a dependency on memchr for string searching.
(right now it also has an optional dep on no-panic, but I plan to remove it.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant