Skip to content

Commit

Permalink
Merge pull request #1601 from alex-pinkus/fix-abi-14-struct-ordering
Browse files Browse the repository at this point in the history
Fix ABI 14 back compat by moving primary_field_ids to the end
  • Loading branch information
maxbrunsfeld committed Jan 18, 2022
2 parents 691469c + 858ea57 commit 2346570
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions cli/src/generate/render.rs
Expand Up @@ -1390,10 +1390,6 @@ impl Generator {
add_line!(self, ".alias_sequences = &ts_alias_sequences[0][0],");
}

if self.abi_version >= ABI_VERSION_WITH_PRIMARY_STATES {
add_line!(self, ".primary_state_ids = ts_primary_state_ids,");
}

// Lexing
add_line!(self, ".lex_modes = ts_lex_modes,");
add_line!(self, ".lex_fn = ts_lex,");
Expand All @@ -1420,6 +1416,10 @@ impl Generator {
add_line!(self, "}},");
}

if self.abi_version >= ABI_VERSION_WITH_PRIMARY_STATES {
add_line!(self, ".primary_state_ids = ts_primary_state_ids,");
}

dedent!(self);
add_line!(self, "}};");
add_line!(self, "return &language;");
Expand Down
2 changes: 1 addition & 1 deletion lib/include/tree_sitter/parser.h
Expand Up @@ -110,7 +110,6 @@ struct TSLanguage {
const TSSymbol *public_symbol_map;
const uint16_t *alias_map;
const TSSymbol *alias_sequences;
const TSStateId *primary_state_ids;
const TSLexMode *lex_modes;
bool (*lex_fn)(TSLexer *, TSStateId);
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
Expand All @@ -124,6 +123,7 @@ struct TSLanguage {
unsigned (*serialize)(void *, char *);
void (*deserialize)(void *, const char *, unsigned);
} external_scanner;
const TSStateId *primary_state_ids;
};

/*
Expand Down

0 comments on commit 2346570

Please sign in to comment.