Feature: allow the user to capture groups on regex
- Dominant language
- Haskell
- Stars
- 323
- Forks
- 87
- PR merge metrics
- No merged PRs in 30d
Description
Currently, when alex executes a token action, the _whole_ match is captured. For example:
```haskell
%wrapper "basic" -- the behaviour is similar on the other wrappers
tokens :-
\"a\" { \s -> Token a }
{
data Token = Token String
}
-- After reading, alex would return [Token "\"a\""] for input = "\"a\""
```
Would be amazing that alex match syntax allows to capture groups, like other regexes:
```haskell
%wrapper "basic" -- the behaviour is similar on the other wrappers
tokens :-
\"(a)\" { \s -> Token s }
-- After reading, alex would return [Token "a"] for the same input
```
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.
Contributor guide
Assessment
This issue has not been assessed yet.