Skip to content

Commit

Permalink
deps src: Automatic update
Browse files Browse the repository at this point in the history
  • Loading branch information
marvim committed Apr 15, 2024
1 parent d9ed061 commit e5fa9a4
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 57 deletions.
30 changes: 15 additions & 15 deletions src/treesitter-stamp/download-treesitter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ function(check_file_hash has_hash hash_is_good)
set("${has_hash}" TRUE PARENT_SCOPE)

message(STATUS "verifying file...
file='/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.4.tar.gz'")
file='/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.5.tar.gz'")

file("SHA256" "/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.4.tar.gz" actual_value)
file("SHA256" "/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.5.tar.gz" actual_value)

if(NOT "${actual_value}" STREQUAL "919b750da9af1260cd989498bc84c63391b72ee2aa2ec20fc84882544eb7a229")
if(NOT "${actual_value}" STREQUAL "6bc22ca7e0f81d77773462d922cf40b44bfd090d92abac75cb37dbae516c2417")
set("${hash_is_good}" FALSE PARENT_SCOPE)
message(STATUS "SHA256 hash of
/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.4.tar.gz
/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.5.tar.gz
does not match expected value
expected: '919b750da9af1260cd989498bc84c63391b72ee2aa2ec20fc84882544eb7a229'
expected: '6bc22ca7e0f81d77773462d922cf40b44bfd090d92abac75cb37dbae516c2417'
actual: '${actual_value}'")
else()
set("${hash_is_good}" TRUE PARENT_SCOPE)
Expand Down Expand Up @@ -71,32 +71,32 @@ function(sleep_before_download attempt)
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep "${sleep_seconds}")
endfunction()

if(EXISTS "/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.4.tar.gz")
if(EXISTS "/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.5.tar.gz")
check_file_hash(has_hash hash_is_good)
if(has_hash)
if(hash_is_good)
message(STATUS "File already exists and hash match (skip download):
file='/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.4.tar.gz'
SHA256='919b750da9af1260cd989498bc84c63391b72ee2aa2ec20fc84882544eb7a229'"
file='/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.5.tar.gz'
SHA256='6bc22ca7e0f81d77773462d922cf40b44bfd090d92abac75cb37dbae516c2417'"
)
return()
else()
message(STATUS "File already exists but hash mismatch. Removing...")
file(REMOVE "/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.4.tar.gz")
file(REMOVE "/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.5.tar.gz")
endif()
else()
message(STATUS "File already exists but no hash specified (use URL_HASH):
file='/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.4.tar.gz'
file='/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.5.tar.gz'
Old file will be removed and new file downloaded from URL."
)
file(REMOVE "/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.4.tar.gz")
file(REMOVE "/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.5.tar.gz")
endif()
endif()

set(retry_number 5)

message(STATUS "Downloading...
dst='/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.4.tar.gz'
dst='/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.5.tar.gz'
timeout='none'
inactivity timeout='none'"
)
Expand All @@ -107,7 +107,7 @@ foreach(i RANGE ${retry_number})
if(status_code IN_LIST download_retry_codes)
sleep_before_download(${i})
endif()
foreach(url IN ITEMS [====[https://github.com/tree-sitter/tree-sitter/archive/v0.22.4.tar.gz]====])
foreach(url IN ITEMS [====[https://github.com/tree-sitter/tree-sitter/archive/v0.22.5.tar.gz]====])
if(NOT url IN_LIST skip_url_list)
message(STATUS "Using src='${url}'")

Expand All @@ -118,7 +118,7 @@ foreach(i RANGE ${retry_number})

file(
DOWNLOAD
"${url}" "/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.4.tar.gz"
"${url}" "/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.5.tar.gz"

# no TIMEOUT
# no INACTIVITY_TIMEOUT
Expand All @@ -135,7 +135,7 @@ foreach(i RANGE ${retry_number})
check_file_hash(has_hash hash_is_good)
if(has_hash AND NOT hash_is_good)
message(STATUS "Hash mismatch, removing...")
file(REMOVE "/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.4.tar.gz")
file(REMOVE "/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.5.tar.gz")
else()
message(STATUS "Downloading... done")
return()
Expand Down
2 changes: 1 addition & 1 deletion src/treesitter-stamp/extract-treesitter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.5)

# Make file names absolute:
#
get_filename_component(filename "/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.4.tar.gz" ABSOLUTE)
get_filename_component(filename "/home/runner/work/deps/deps/neovim/deps/build/downloads/treesitter/v0.22.5.tar.gz" ABSOLUTE)
get_filename_component(directory "/home/runner/work/deps/deps/neovim/deps/build/src/treesitter" ABSOLUTE)

message(STATUS "extracting...
Expand Down
4 changes: 2 additions & 2 deletions src/treesitter-stamp/treesitter-urlinfo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ method=url
command=/usr/local/bin/cmake;-P;/home/runner/work/deps/deps/neovim/deps/build/src/treesitter-stamp/download-treesitter.cmake;COMMAND;/usr/local/bin/cmake;-P;/home/runner/work/deps/deps/neovim/deps/build/src/treesitter-stamp/verify-treesitter.cmake;COMMAND;/usr/local/bin/cmake;-P;/home/runner/work/deps/deps/neovim/deps/build/src/treesitter-stamp/extract-treesitter.cmake
source_dir=/home/runner/work/deps/deps/neovim/deps/build/src/treesitter
work_dir=/home/runner/work/deps/deps/neovim/deps/build/src
url(s)=https://github.com/tree-sitter/tree-sitter/archive/v0.22.4.tar.gz
hash=SHA256=919b750da9af1260cd989498bc84c63391b72ee2aa2ec20fc84882544eb7a229
url(s)=https://github.com/tree-sitter/tree-sitter/archive/v0.22.5.tar.gz
hash=SHA256=6bc22ca7e0f81d77773462d922cf40b44bfd090d92abac75cb37dbae516c2417
no_extract=

7 changes: 7 additions & 0 deletions src/treesitter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.22.3] - 2024-04-14

### Performance

- **cli**: Reduced the compile time of generated parsers by generating C code with fewer conditionals
(https://github.com/tree-sitter/tree-sitter/pull/3234)

## [0.22.1] — 2024-03-10

### Bug Fixes
Expand Down
12 changes: 6 additions & 6 deletions src/treesitter/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/treesitter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ members = [
resolver = "2"

[workspace.package]
version = "0.22.4"
version = "0.22.5"
authors = ["Max Brunsfeld <maxbrunsfeld@gmail.com>"]
edition = "2021"
rust-version = "1.74.1"
Expand Down
2 changes: 1 addition & 1 deletion src/treesitter/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION := 0.22.4
VERSION := 0.22.5

# install directory layout
PREFIX ?= /usr/local
Expand Down
2 changes: 1 addition & 1 deletion src/treesitter/cli/npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tree-sitter-cli",
"version": "0.22.4",
"version": "0.22.5",
"author": "Max Brunsfeld",
"license": "MIT",
"repository": {
Expand Down
69 changes: 48 additions & 21 deletions src/treesitter/cli/src/generate/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct Generator {
main_lex_table: LexTable,
keyword_lex_table: LexTable,
large_character_sets: Vec<(Option<Symbol>, CharacterSet)>,
large_character_set_constant_names: Vec<String>,
large_character_set_info: Vec<LargeCharacterSetInfo>,
large_state_count: usize,
keyword_capture_token: Option<Symbol>,
syntax_grammar: SyntaxGrammar,
Expand All @@ -81,6 +81,11 @@ struct Generator {
abi_version: usize,
}

struct LargeCharacterSetInfo {
constant_name: String,
is_used: bool,
}

impl Generator {
fn generate(mut self) -> String {
self.init();
Expand Down Expand Up @@ -108,11 +113,7 @@ impl Generator {
self.add_primary_state_id_list();
}

// Generate a helper function for each large character set.
// let mut sorted_large_char_sets = self.large_character_sets.iter().collect::<Vec<_>>();
for ix in 0..self.large_character_sets.len() {
self.add_character_set(ix);
}
let buffer_offset_before_lex_functions = self.buffer.len();

let mut main_lex_table = LexTable::default();
swap(&mut main_lex_table, &mut self.main_lex_table);
Expand All @@ -124,6 +125,16 @@ impl Generator {
self.add_lex_function("ts_lex_keywords", keyword_lex_table);
}

// Once the lex functions are generated, and we've determined which large
// character sets are actually used, we can generate the large character set
// constants. Insert them into the output buffer before the lex functions.
let lex_functions = self.buffer[buffer_offset_before_lex_functions..].to_string();
self.buffer.truncate(buffer_offset_before_lex_functions);
for ix in 0..self.large_character_sets.len() {
self.add_character_set(ix);
}
self.buffer.push_str(&lex_functions);

self.add_lex_modes_list();
self.add_parse_table();

Expand Down Expand Up @@ -238,6 +249,23 @@ impl Generator {
}
}

for (ix, (symbol, _)) in self.large_character_sets.iter().enumerate() {
let count = self.large_character_sets[0..ix]
.iter()
.filter(|(sym, _)| sym == symbol)
.count()
+ 1;
let constant_name = if let Some(symbol) = symbol {
format!("{}_character_set_{}", self.symbol_ids[&symbol], count)
} else {
format!("extras_character_set_{}", count)
};
self.large_character_set_info.push(LargeCharacterSetInfo {
constant_name,
is_used: false,
});
}

// Determine which states should use the "small state" representation, and which should
// use the normal array representation.
let threshold = cmp::min(SMALL_STATE_THRESHOLD, self.parse_table.symbols.len() / 2);
Expand Down Expand Up @@ -829,10 +857,12 @@ impl Generator {
add!(self, "(!eof && ")
}

let char_set_info = &mut self.large_character_set_info[large_char_set_ix];
char_set_info.is_used = true;
add!(
self,
"set_contains({}, {}, lookahead)",
&self.large_character_set_constant_names[large_char_set_ix],
&char_set_info.constant_name,
large_set.range_count(),
);
if check_eof {
Expand Down Expand Up @@ -940,20 +970,17 @@ impl Generator {
}

fn add_character_set(&mut self, ix: usize) {
let (symbol, characters) = self.large_character_sets[ix].clone();
let count = self.large_character_sets[0..ix]
.iter()
.filter(|(sym, _)| *sym == symbol)
.count()
+ 1;
let characters = self.large_character_sets[ix].1.clone();
let info = &self.large_character_set_info[ix];
if !info.is_used {
return;
}

let constant_name = if let Some(symbol) = symbol {
format!("{}_character_set_{}", self.symbol_ids[&symbol], count)
} else {
format!("extras_character_set_{}", count)
};
add_line!(self, "static TSCharacterRange {}[] = {{", constant_name);
self.large_character_set_constant_names.push(constant_name);
add_line!(
self,
"static TSCharacterRange {}[] = {{",
info.constant_name
);

indent!(self);
for (ix, range) in characters.ranges().enumerate() {
Expand Down Expand Up @@ -1694,7 +1721,7 @@ pub fn render_c_code(
keyword_lex_table: tables.keyword_lex_table,
keyword_capture_token: tables.word_token,
large_character_sets: tables.large_character_sets,
large_character_set_constant_names: Vec::new(),
large_character_set_info: Vec::new(),
syntax_grammar,
lexical_grammar,
default_aliases,
Expand Down
6 changes: 3 additions & 3 deletions src/treesitter/cli/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,11 +525,11 @@ fn parse_test_content(name: String, content: &str, file_path: Option<PathBuf>) -
let mut test_name = String::new();
let mut seen_marker = false;

for line in test_name_and_markers
.split(|&c| c == b'\n')
for line in str::from_utf8(test_name_and_markers)
.unwrap()
.lines()
.filter(|s| !s.is_empty())
{
let line = str::from_utf8(line).unwrap();
match line.split('(').next().unwrap() {
":skip" => (seen_marker, skip) = (true, true),
":platform" => {
Expand Down
2 changes: 1 addition & 1 deletion src/treesitter/lib/binding_rust/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
#[cfg(not(feature = "bindgen"))]
include!("./bindings.rs");

#[cfg(unix)]
#[cfg(not(windows))]
extern "C" {
pub(crate) fn _ts_dup(fd: std::os::raw::c_int) -> std::os::raw::c_int;
}
Expand Down
8 changes: 4 additions & 4 deletions src/treesitter/lib/binding_rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
pub mod ffi;
mod util;

#[cfg(unix)]
use std::os::unix::io::AsRawFd;
#[cfg(not(windows))]
use std::os::fd::AsRawFd;
#[cfg(windows)]
use std::os::windows::io::AsRawHandle;
use std::{
Expand Down Expand Up @@ -942,10 +942,10 @@ impl Tree {
#[doc(alias = "ts_tree_print_dot_graph")]
pub fn print_dot_graph(
&self,
#[cfg(unix)] file: &impl AsRawFd,
#[cfg(not(windows))] file: &impl AsRawFd,
#[cfg(windows)] file: &impl AsRawHandle,
) {
#[cfg(unix)]
#[cfg(not(windows))]
{
let fd = file.as_raw_fd();
unsafe { ffi::ts_tree_print_dot_graph(self.0.as_ptr(), fd) }
Expand Down
2 changes: 1 addition & 1 deletion src/treesitter/lib/binding_web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "web-tree-sitter",
"version": "0.22.4",
"version": "0.22.5",
"description": "Tree-sitter bindings for the web",
"main": "tree-sitter.js",
"types": "tree-sitter-web.d.ts",
Expand Down

0 comments on commit e5fa9a4

Please sign in to comment.