aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-dataloader/detail/LexyLitRange.hpp
blob: a6761a81cc1d23ac851bd198ee315c1b758755a1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#pragma once

#include <lexy/dsl/literal.hpp>

namespace ovdl::detail::lexydsl {
   template<unsigned char LOW, unsigned char HIGH>
   consteval auto make_range() {
      if constexpr (LOW == HIGH) {
         return lexy::dsl::lit_c<LOW>;
      } else if constexpr (LOW == (HIGH - 1)) {
         return lexy::dsl::lit_c<LOW> / lexy::dsl::lit_c<HIGH>;
      } else {
         return lexy::dsl::lit_c<LOW> / make_range<LOW + 1, HIGH>();
      }
   }
}