diff options
| author | Li Jin <dragon-fly@qq.com> | 2020-01-30 19:19:45 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2020-01-30 19:19:45 +0800 |
| commit | 3f535edc133d7d6eb45ebf50627f3ee5deae1155 (patch) | |
| tree | 35ea1b1733d01683dfe149b011e8ddb33912f5a8 /src/MoonP/moon_parser.h | |
| parent | f6a9052be67134aeaad59d0e6f4058dfd09ce324 (diff) | |
| download | yuescript-3f535edc133d7d6eb45ebf50627f3ee5deae1155.tar.gz yuescript-3f535edc133d7d6eb45ebf50627f3ee5deae1155.tar.bz2 yuescript-3f535edc133d7d6eb45ebf50627f3ee5deae1155.zip | |
make gcc happy.
Diffstat (limited to 'src/MoonP/moon_parser.h')
| -rw-r--r-- | src/MoonP/moon_parser.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/MoonP/moon_parser.h b/src/MoonP/moon_parser.h index 933aa7a..a0ad2fa 100644 --- a/src/MoonP/moon_parser.h +++ b/src/MoonP/moon_parser.h | |||
| @@ -24,14 +24,17 @@ namespace MoonP { | |||
| 24 | struct ParseInfo { | 24 | struct ParseInfo { |
| 25 | ast_ptr<false,ast_node> node; | 25 | ast_ptr<false,ast_node> node; |
| 26 | std::string error; | 26 | std::string error; |
| 27 | std::unique_ptr<input> input; | 27 | std::unique_ptr<input> codes; |
| 28 | std::string errorMessage(std::string_view msg, const input_range* loc) const; | 28 | std::string errorMessage(std::string_view msg, const input_range* loc) const; |
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| 31 | template<typename T> | ||
| 32 | struct identity { typedef T type; }; | ||
| 33 | |||
| 31 | #define AST_RULE(type) \ | 34 | #define AST_RULE(type) \ |
| 32 | rule type; \ | 35 | rule type; \ |
| 33 | ast<type##_t> type##_impl = type; \ | 36 | ast<type##_t> type##_impl = type; \ |
| 34 | template<> inline rule& getRule<type##_t>() { return type; } | 37 | inline rule& getRule(identity<type##_t>) { return type; } |
| 35 | 38 | ||
| 36 | extern std::unordered_set<std::string> LuaKeywords; | 39 | extern std::unordered_set<std::string> LuaKeywords; |
| 37 | extern std::unordered_set<std::string> Keywords; | 40 | extern std::unordered_set<std::string> Keywords; |
| @@ -76,11 +79,17 @@ protected: | |||
| 76 | std::stack<bool> doStack; | 79 | std::stack<bool> doStack; |
| 77 | }; | 80 | }; |
| 78 | 81 | ||
| 82 | |||
| 83 | template <class T> | ||
| 84 | inline rule& getRule() { | ||
| 85 | return getRule(identity<T>()); | ||
| 86 | } | ||
| 87 | |||
| 79 | private: | 88 | private: |
| 80 | Converter _converter; | 89 | Converter _converter; |
| 81 | 90 | ||
| 82 | template <class T> | 91 | template <class T> |
| 83 | inline rule& getRule() { | 92 | inline rule& getRule(identity<T>) { |
| 84 | assert(false); | 93 | assert(false); |
| 85 | return Cut; | 94 | return Cut; |
| 86 | } | 95 | } |
