diff options
Diffstat (limited to 'src/MoonP/parser.hpp')
| -rw-r--r-- | src/MoonP/parser.hpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/MoonP/parser.hpp b/src/MoonP/parser.hpp index 9739465..b419e8c 100644 --- a/src/MoonP/parser.hpp +++ b/src/MoonP/parser.hpp | |||
| @@ -28,16 +28,13 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | |||
| 28 | namespace parserlib { | 28 | namespace parserlib { |
| 29 | 29 | ||
| 30 | // const str hash helper functions | 30 | // const str hash helper functions |
| 31 | inline constexpr size_t hash(char const* input) | 31 | inline constexpr size_t hash(char const* input) { |
| 32 | { | ||
| 33 | return *input ? *input + 33ull * hash(input + 1) : 5381; | 32 | return *input ? *input + 33ull * hash(input + 1) : 5381; |
| 34 | } | 33 | } |
| 35 | inline size_t hash(const char* input, int size, int index) | 34 | inline size_t hash(const char* input, int size, int index) { |
| 36 | { | ||
| 37 | return index < size ? input[index] + 33ull * hash(input, size, index + 1) : 5381; | 35 | return index < size ? input[index] + 33ull * hash(input, size, index + 1) : 5381; |
| 38 | } | 36 | } |
| 39 | inline size_t constexpr operator"" _id(const char* s, size_t) | 37 | inline size_t constexpr operator"" _id(const char* s, size_t) { |
| 40 | { | ||
| 41 | return hash(s); | 38 | return hash(s); |
| 42 | } | 39 | } |
| 43 | 40 | ||
| @@ -52,8 +49,7 @@ class _context; | |||
| 52 | class rule; | 49 | class rule; |
| 53 | 50 | ||
| 54 | 51 | ||
| 55 | struct item_t | 52 | struct item_t { |
| 56 | { | ||
| 57 | input_it begin; | 53 | input_it begin; |
| 58 | input_it end; | 54 | input_it end; |
| 59 | void* user_data; | 55 | void* user_data; |
| @@ -74,7 +70,7 @@ public: | |||
| 74 | int m_col; | 70 | int m_col; |
| 75 | 71 | ||
| 76 | ///null constructor. | 72 | ///null constructor. |
| 77 | pos():m_line(-1),m_col(0) {} | 73 | pos():m_line(0),m_col(0) {} |
| 78 | 74 | ||
| 79 | /** constructor from input. | 75 | /** constructor from input. |
| 80 | @param i input. | 76 | @param i input. |
| @@ -216,6 +212,7 @@ public: | |||
| 216 | /** character terminal constructor. | 212 | /** character terminal constructor. |
| 217 | @param c character. | 213 | @param c character. |
| 218 | */ | 214 | */ |
| 215 | rule(); | ||
| 219 | rule(char c); | 216 | rule(char c); |
| 220 | 217 | ||
| 221 | /** null-terminated string terminal constructor. | 218 | /** null-terminated string terminal constructor. |
| @@ -278,6 +275,10 @@ public: | |||
| 278 | */ | 275 | */ |
| 279 | rule *this_ptr() { return this; } | 276 | rule *this_ptr() { return this; } |
| 280 | 277 | ||
| 278 | rule &operator = (rule &); | ||
| 279 | |||
| 280 | rule &operator = (const expr &); | ||
| 281 | |||
| 281 | private: | 282 | private: |
| 282 | //mode | 283 | //mode |
| 283 | enum _MODE { | 284 | enum _MODE { |
| @@ -308,9 +309,6 @@ private: | |||
| 308 | //state | 309 | //state |
| 309 | _state m_state; | 310 | _state m_state; |
| 310 | 311 | ||
| 311 | //assignment not allowed | ||
| 312 | rule &operator = (rule &); | ||
| 313 | |||
| 314 | friend class _private; | 312 | friend class _private; |
| 315 | friend class _context; | 313 | friend class _context; |
| 316 | }; | 314 | }; |
