Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
regex-combinators.hh
Go to the documentation of this file.
1#pragma once
3
4#include <string_view>
5#include <string>
6#include <sstream>
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 std::stringstream ss;
16 ss << a << "|" << b;
17 return ss.str();
18}
19
20static inline std::string group(std::string_view a)
21{
22 std::stringstream ss;
23 ss << "(" << a << ")";
24 return ss.str();
25}
26
27static inline std::string list(std::string_view a)
28{
29 std::stringstream ss;
30 ss << a << "(," << a << ")*";
31 return ss.str();
32}
33
34}