Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
regex-combinators.hh
Go to the documentation of this file.
1#pragma once
3
5
6#include <string_view>
7
8namespace nix::regex {
9
10// TODO use constexpr string building like
11// https://github.com/akrzemi1/static_string/blob/master/include/ak_toolkit/static_string.hpp
12
13static inline std::string either(std::string_view a, std::string_view b)
14{
15 return std::string { a } + "|" + b;
16}
17
18static inline std::string group(std::string_view a)
19{
20 return std::string { "(" } + a + ")";
21}
22
23static inline std::string many(std::string_view a)
24{
25 return std::string { "(?:" } + a + ")*";
26}
27
28static inline std::string list(std::string_view a)
29{
30 return std::string { a } + many(group("," + a));
31}
32
33}