Skip to content

Commit 448b15d

Browse files
author
Hana Dusíková
committed
post merging
1 parent 958e5a8 commit 448b15d

File tree

9 files changed

+30
-56
lines changed

9 files changed

+30
-56
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
default: all
44

5-
TARGETS := a.cpp result.cpp test.cpp $(wildcard tests/benchmark-exec/*.cpp)
5+
TARGETS := result.cpp test.cpp $(wildcard tests/benchmark-exec/*.cpp)
66
IGNORE := $(wildcard tests/benchmark/*.cpp) $(wildcard tests/benchmark-exec/*.cpp)
77

88
DESATOMAT := /www/root/desatomat/console/desatomat.php

clang-bench.txt

Lines changed: 0 additions & 20 deletions
This file was deleted.

include/ctll/parser.hpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include "grammars.hpp"
77
#include "actions.hpp"
88

9+
#include <limits>
10+
911
namespace ctll {
1012

1113

@@ -59,7 +61,13 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
5961

6062
template <size_t Pos> static constexpr auto get_current_term() noexcept {
6163
if constexpr (Pos < input.size()) {
62-
return term<input[Pos]>{};
64+
constexpr auto value = input[Pos];
65+
if constexpr (value <= std::numeric_limits<char>::max()) {
66+
return term<static_cast<char>(value)>{};
67+
} else {
68+
return term<input[Pos]>{};
69+
}
70+
6371
} else {
6472
// return epsilon if we are past the input
6573
return epsilon{};
@@ -70,7 +78,12 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
7078
// there is no previous character on input if we are on start
7179
return epsilon{};
7280
} else if constexpr ((Pos-1) < input.size()) {
73-
return term<input[Pos-1]>{};
81+
constexpr auto value = input[Pos-1];
82+
if constexpr (value <= std::numeric_limits<char>::max()) {
83+
return term<static_cast<char>(value)>{};
84+
} else {
85+
return term<input[Pos]>{};
86+
}
7487
} else {
7588
return epsilon{};
7689
}
@@ -96,7 +109,7 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
96109
}
97110
// if rule is string => push it to the front of stack
98111
template <size_t Pos, typename... Content, typename Terminal, typename Stack, typename Subject>
99-
static constexpr auto move(ctll::list<Content...> string, Terminal, Stack stack, Subject subject) noexcept {
112+
static constexpr auto move(push<Content...> string, Terminal, Stack stack, Subject subject) noexcept {
100113
return decide<Pos>(push_front(string, stack), subject);
101114
}
102115
// if rule is epsilon (empty string) => continue
@@ -107,7 +120,7 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
107120
// if rule is string with current character at the beginning (term<V>) => move to next character
108121
// and push string without the character (quick LL(1))
109122
template <size_t Pos, auto V, typename... Content, typename Stack, typename Subject>
110-
static constexpr auto move(ctll::list<term<V>, Content...>, term<V>, Stack stack, Subject) noexcept {
123+
static constexpr auto move(push<term<V>, Content...>, term<V>, Stack stack, Subject) noexcept {
111124
#ifdef EXPERIMENTAL_GCC_9
112125
return decide<Pos+1>(push_front(list<Content...>(), stack), Subject());
113126
#else
@@ -117,7 +130,7 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
117130
// if rule is string with any character at the beginning (compatible with current term<T>) => move to next character
118131
// and push string without the character (quick LL(1))
119132
template <size_t Pos, auto V, typename... Content, auto T, typename Stack, typename Subject>
120-
static constexpr auto move(ctll::list<anything, Content...>, term<T>, Stack stack, Subject) noexcept {
133+
static constexpr auto move(ctll::push<anything, Content...>, term<T>, Stack stack, Subject) noexcept {
121134
#ifdef EXPERIMENTAL_GCC_9
122135
return decide<Pos+1>(push_front(list<Content...>(), stack), Subject());
123136
#else

include/ctre/literals.hpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,21 @@ template <typename CharT, CharT... input> static inline constexpr auto _fixed_st
1919

2020
namespace literals {
2121

22+
// clang and GCC <9 supports LITERALS with packs
23+
2224
#ifdef __clang__
2325
#pragma clang diagnostic push
2426
#pragma clang diagnostic ignored "-Wgnu-string-literal-operator-template"
25-
2627
#define CTRE_ENABLE_LITERALS
2728
#endif
2829

2930
#ifdef __INTEL_COMPILER
3031
// not enable literals
3132
#elif defined __GNUC__
33+
#ifndef EXPERIMENTAL_GCC_9
3234
#define CTRE_ENABLE_LITERALS
3335
#endif
36+
#endif
3437

3538
#ifdef CTRE_ENABLE_LITERALS
3639

@@ -101,18 +104,6 @@ template <ctll::basic_fixed_string input> CTRE_FLATTEN constexpr CTRE_FORCE_INLI
101104
}
102105

103106

104-
#if !__cpp_nontype_template_parameter_class
105-
template <typename CharT, CharT... charpack> CTRE_FLATTEN constexpr inline auto operator""_simple_test() noexcept {
106-
constexpr auto & _input = _fixed_string_reference<CharT, charpack...>;
107-
#else
108-
template <ctll::basic_fixed_string input> CTRE_FLATTEN constexpr inline auto operator""_simple_test() noexcept {
109-
constexpr auto _input = input; // workaround for GCC 9 bug 88092
110-
#endif
111-
return ctll::parser<ctre::simple, _input>::correct;
112-
}
113-
114-
#endif
115-
#endif
116107
#endif
117108

118109
#ifdef __clang__
File renamed without changes.

tests/matching2.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include <ctre.hpp>
22
#include <string_view>
33

4+
#ifndef EXPERIMENTAL_GCC_9
5+
46
using namespace ctre::literals;
57
using namespace ctre::test_literals;
68
using namespace std::string_view_literals;
@@ -230,4 +232,4 @@ static_assert(!"(?!.*(.)\\g{1})[a-z]+"_ctre.match("abcdeefgh"sv));
230232

231233

232234

233-
235+
#endif

tests/matching3.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include <ctre.hpp>
22
#include <string_view>
33

4+
#ifndef EXPERIMENTAL_GCC_9
5+
46
using namespace ctre::literals;
57
using namespace ctre::test_literals;
68
using namespace std::string_view_literals;
@@ -195,7 +197,7 @@ TEST_MATCH(112, "\\[\\]", "[]");
195197

196198

197199

198-
200+
#endif
199201

200202

201203

tests/simple.cpp

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/wide-pattern.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <ctre.hpp>
22

3-
static constexpr auto Pattern = ctll::basic_fixed_string{ LR"(^(\S+;\d+)\s+(\d+|\d+/\d+)?\s+((\d{1,2})-([A-Z]{3,3})-(\d{4,4})\s+(\d{1,2}):(\d{2,2})(:(\d{2,2})(\.\d{2,2})?)?(\s+\[(\S+),(\S+)\]\s+\(([A-Z]*),([A-Z]*),([A-Z]*),([A-Z]*)\))?)?)" };
3+
static constexpr auto Pattern = ctll::basic_fixed_string{ L"[a-z]+" };
44

55
int main()
66
{

0 commit comments

Comments
 (0)