Merge pull request #3280 from ObserverOfTime/reduce

refactor(parser): make REDUCE macro non-variadic
This commit is contained in:
Max Brunsfeld 2024-04-11 15:39:28 -07:00 committed by GitHub
commit 18ea74ee12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 14 deletions

View file

@ -1299,16 +1299,9 @@ impl Generator {
} => {
add!(
self,
"REDUCE(.symbol = {}, .child_count = {child_count}",
"REDUCE({}, {child_count}, {dynamic_precedence}, {production_id})",
self.symbol_ids[&symbol]
);
if dynamic_precedence != 0 {
add!(self, ", .dynamic_precedence = {dynamic_precedence}");
}
if production_id != 0 {
add!(self, ", .production_id = {production_id}");
}
add!(self, ")");
}
}
add!(self, ",");

View file

@ -203,12 +203,15 @@ struct TSLanguage {
} \
}}
#define REDUCE(...) \
{{ \
.reduce = { \
.type = TSParseActionTypeReduce, \
__VA_ARGS__ \
}, \
#define REDUCE(symbol_name, children, precedence, prod_id) \
{{ \
.reduce = { \
.type = TSParseActionTypeReduce, \
.symbol = symbol_name, \
.child_count = children, \
.dynamic_precedence = precedence, \
.production_id = prod_id \
}, \
}}
#define RECOVER() \