-
Notifications
You must be signed in to change notification settings - Fork 82
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
Feature: allow the user to capture groups on regex #148
Comments
Yes, I would really like to have this functionality. As I recall it was non-trivial to implement it (especially if we want to do it without a performance overhead if you don't use the functionality), but it would be very useful to have it. |
We could try to have separate wrappers for that, something like:
Or adding another directive, like:
I think the last approach is better than the first one. |
@german1608: is the automata-theoretic implementation of groups worked out some where?
against Without drilling up the automata generation of Alex, one could imagine the following light-weight approach:
What Alex would do here, is:
This might not be as comfortable as it could be, but a rather lightweight and generic extension of Alex. In terms of efficiency, there is of course some duplication of work, but just extracting groups in a regexp that is known to match should be cheaper that figuring out which token to extract from the input in the first place. |
There is TDFAs (Tagged Deterministic Finite Automata), e.g. https://github.com/haskell-hvr/regex-tdfa . |
Currently, when alex executes a token action, the whole match is captured. For example:
Would be amazing that alex match syntax allows to capture groups, like other regexes:
Alex could also handle several groups in the same token action, so it could extract the groups as a list of strings or something alike.
The text was updated successfully, but these errors were encountered: