haskell / haskell/alex

Feature: allow the user to capture groups on regex

Open
#148 4 comments 1 reaction 0 assignees View on GitHub
feature request
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.