aboutsummaryrefslogtreecommitdiff
path: root/src/tree_sitter/parser.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tree_sitter/parser.h')
-rw-r--r--src/tree_sitter/parser.h50
1 files changed, 31 insertions, 19 deletions
diff --git a/src/tree_sitter/parser.h b/src/tree_sitter/parser.h
index 9df91f8c3c..11bf4fc42a 100644
--- a/src/tree_sitter/parser.h
+++ b/src/tree_sitter/parser.h
@@ -62,13 +62,13 @@ typedef struct {
TSStateId state;
bool extra : 1;
bool repetition : 1;
- };
+ } shift;
struct {
TSSymbol symbol;
int16_t dynamic_precedence;
uint8_t child_count;
uint8_t production_id;
- };
+ } reduce;
} params;
TSParseActionType type : 4;
} TSParseAction;
@@ -83,7 +83,7 @@ typedef union {
struct {
uint8_t count;
bool reusable : 1;
- };
+ } entry;
} TSParseActionEntry;
struct TSLanguage {
@@ -167,22 +167,28 @@ struct TSLanguage {
#define ACTIONS(id) id
-#define SHIFT(state_value) \
- { \
- { \
- .type = TSParseActionTypeShift, \
- .params = {.state = state_value}, \
- } \
+#define SHIFT(state_value) \
+ { \
+ { \
+ .params = { \
+ .shift = { \
+ .state = state_value \
+ } \
+ }, \
+ .type = TSParseActionTypeShift \
+ } \
}
#define SHIFT_REPEAT(state_value) \
{ \
{ \
- .type = TSParseActionTypeShift, \
.params = { \
- .state = state_value, \
- .repetition = true \
+ .shift = { \
+ .state = state_value, \
+ .repetition = true \
+ } \
}, \
+ .type = TSParseActionTypeShift \
} \
}
@@ -194,20 +200,26 @@ struct TSLanguage {
#define SHIFT_EXTRA() \
{ \
{ \
- .type = TSParseActionTypeShift, \
- .params = {.extra = true} \
+ .params = { \
+ .shift = { \
+ .extra = true \
+ } \
+ }, \
+ .type = TSParseActionTypeShift \
} \
}
#define REDUCE(symbol_val, child_count_val, ...) \
{ \
{ \
- .type = TSParseActionTypeReduce, \
.params = { \
- .symbol = symbol_val, \
- .child_count = child_count_val, \
- __VA_ARGS__ \
- } \
+ .reduce = { \
+ .symbol = symbol_val, \
+ .child_count = child_count_val, \
+ __VA_ARGS__ \
+ }, \
+ }, \
+ .type = TSParseActionTypeReduce \
} \
}