66#include " grammars.hpp"
77#include " actions.hpp"
88
9+ #include < limits>
10+
911namespace 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
0 commit comments