feat(generate): add a comment with the tree-sitter version

This commit is contained in:
ObserverOfTime 2024-10-24 18:23:55 +03:00 committed by Amaan Qureshi
parent d3a127a48f
commit 7f0c5f928a

View file

@ -20,6 +20,7 @@ const SMALL_STATE_THRESHOLD: usize = 64;
const ABI_VERSION_MIN: usize = 13;
const ABI_VERSION_MAX: usize = tree_sitter::LANGUAGE_VERSION;
const ABI_VERSION_WITH_PRIMARY_STATES: usize = 14;
const BUILD_VERSION: &str = env!("CARGO_PKG_VERSION");
macro_rules! add {
($this: tt, $($arg: tt)*) => {{
@ -89,6 +90,7 @@ struct LargeCharacterSetInfo {
impl Generator {
fn generate(mut self) -> String {
self.init();
self.add_header();
self.add_includes();
self.add_pragmas();
self.add_stats();
@ -280,6 +282,14 @@ impl Generator {
.count();
}
fn add_header(&mut self) {
add_line!(
self,
"// Automatically generated by tree-sitter v{BUILD_VERSION}"
);
add_line!(self, "");
}
fn add_includes(&mut self) {
add_line!(self, "#include \"tree_sitter/parser.h\"");
add_line!(self, "");