aboutsummaryrefslogtreecommitdiff
path: root/src/MoonP/moon_parser.h
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2020-01-30 19:19:45 +0800
committerLi Jin <dragon-fly@qq.com>2020-01-30 19:19:45 +0800
commit3f535edc133d7d6eb45ebf50627f3ee5deae1155 (patch)
tree35ea1b1733d01683dfe149b011e8ddb33912f5a8 /src/MoonP/moon_parser.h
parentf6a9052be67134aeaad59d0e6f4058dfd09ce324 (diff)
downloadyuescript-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.h15
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 {
24struct ParseInfo { 24struct 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
31template<typename T>
32struct 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
36extern std::unordered_set<std::string> LuaKeywords; 39extern std::unordered_set<std::string> LuaKeywords;
37extern std::unordered_set<std::string> Keywords; 40extern 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
79private: 88private:
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 }