6
6
#include " grammars.hpp"
7
7
#include " actions.hpp"
8
8
9
+ #include < limits>
10
+
9
11
namespace ctll {
10
12
11
13
@@ -59,7 +61,13 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
59
61
60
62
template <size_t Pos> static constexpr auto get_current_term () noexcept {
61
63
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
+
63
71
} else {
64
72
// return epsilon if we are past the input
65
73
return epsilon{};
@@ -70,7 +78,12 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
70
78
// there is no previous character on input if we are on start
71
79
return epsilon{};
72
80
} 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
+ }
74
87
} else {
75
88
return epsilon{};
76
89
}
@@ -96,7 +109,7 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
96
109
}
97
110
// if rule is string => push it to the front of stack
98
111
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 {
100
113
return decide<Pos>(push_front (string, stack), subject);
101
114
}
102
115
// if rule is epsilon (empty string) => continue
@@ -107,7 +120,7 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
107
120
// if rule is string with current character at the beginning (term<V>) => move to next character
108
121
// and push string without the character (quick LL(1))
109
122
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 {
111
124
#ifdef EXPERIMENTAL_GCC_9
112
125
return decide<Pos+1 >(push_front (list<Content...>(), stack), Subject ());
113
126
#else
@@ -117,7 +130,7 @@ template <typename Grammar, ctll::basic_fixed_string input, typename ActionSelec
117
130
// if rule is string with any character at the beginning (compatible with current term<T>) => move to next character
118
131
// and push string without the character (quick LL(1))
119
132
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 {
121
134
#ifdef EXPERIMENTAL_GCC_9
122
135
return decide<Pos+1 >(push_front (list<Content...>(), stack), Subject ());
123
136
#else
0 commit comments