diff options
| author | Li Jin <dragon-fly@qq.com> | 2020-02-17 15:46:38 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2020-02-17 15:46:38 +0800 |
| commit | 71d9ad9506524fcd3e124c4b4a460afa8fbf35eb (patch) | |
| tree | 8283382f37bc7dd9e827e27c830e867a6cb6c270 /src/MoonP/parser.hpp | |
| parent | 0091db154bc4d40a0c2d79a2311ddc3711321811 (diff) | |
| download | yuescript-71d9ad9506524fcd3e124c4b4a460afa8fbf35eb.tar.gz yuescript-71d9ad9506524fcd3e124c4b4a460afa8fbf35eb.tar.bz2 yuescript-71d9ad9506524fcd3e124c4b4a460afa8fbf35eb.zip | |
refactor some codes to be safer.
Diffstat (limited to '')
| -rw-r--r-- | src/MoonP/parser.hpp | 11 |
1 files changed, 0 insertions, 11 deletions
diff --git a/src/MoonP/parser.hpp b/src/MoonP/parser.hpp index 01d1050..14abe1a 100644 --- a/src/MoonP/parser.hpp +++ b/src/MoonP/parser.hpp | |||
| @@ -28,17 +28,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | |||
| 28 | 28 | ||
| 29 | namespace parserlib { | 29 | namespace parserlib { |
| 30 | 30 | ||
| 31 | // const str hash helper functions | ||
| 32 | inline constexpr size_t hash(char const* input) { | ||
| 33 | return *input ? *input + 33ull * hash(input + 1) : 5381; | ||
| 34 | } | ||
| 35 | inline size_t hash(const char* input, int size, int index) { | ||
| 36 | return index < size ? input[index] + 33ull * hash(input, size, index + 1) : 5381; | ||
| 37 | } | ||
| 38 | inline size_t constexpr operator"" _id(const char* s, size_t) { | ||
| 39 | return hash(s); | ||
| 40 | } | ||
| 41 | |||
| 42 | ///type of the parser's input. | 31 | ///type of the parser's input. |
| 43 | typedef std::basic_string<wchar_t> input; | 32 | typedef std::basic_string<wchar_t> input; |
| 44 | typedef input::iterator input_it; | 33 | typedef input::iterator input_it; |
