Python: undo tree-sitter update

This commit is contained in:
Paolo Tranquilli
2025-02-17 15:52:45 +01:00
parent df305d6b52
commit 342bff6125
14 changed files with 303 additions and 92 deletions

View File

@@ -2,6 +2,12 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "ahash"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0453232ace82dee0dd0b4c87a59bd90f7b53b314f3e0f61fe2ee7c8a16482289"
[[package]]
name = "aho-corasick"
version = "1.1.3"
@@ -76,6 +82,12 @@ dependencies = [
"shlex",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "4.5.29"
@@ -109,6 +121,15 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
[[package]]
name = "hashbrown"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
dependencies = [
"ahash",
]
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
@@ -237,10 +258,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd"
[[package]]
name = "streaming-iterator"
version = "0.1.9"
name = "string-interner"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b2231b7c3057d5e4ad0156fb3dc807d900806020c5ffa3ee6ff2c8c76fb8520"
checksum = "383196d1876517ee6f9f0864d1fc1070331b803335d3c6daaa04bbcccd823c08"
dependencies = [
"cfg-if",
"hashbrown",
]
[[package]]
name = "strsim"
@@ -281,39 +306,30 @@ dependencies = [
[[package]]
name = "tree-sitter"
version = "0.24.7"
version = "0.20.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5387dffa7ffc7d2dae12b50c6f7aab8ff79d6210147c6613561fc3d474c6f75"
checksum = "e747b1f9b7b931ed39a548c1fae149101497de3c1fc8d9e18c62c1a66c683d3d"
dependencies = [
"cc",
"regex",
"regex-syntax",
"streaming-iterator",
"tree-sitter-language",
]
[[package]]
name = "tree-sitter-graph"
version = "0.12.0"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63f86eb73c7d891c4b9b6fe4d4e63dd94c506e4788af7c2296afdcfbeea626cc"
checksum = "639d21e886f581d293de5f5081f09af003c54607ff3fa85efa159b243ba1f97a"
dependencies = [
"log",
"regex",
"serde",
"serde_json",
"smallvec",
"streaming-iterator",
"string-interner",
"thiserror",
"tree-sitter",
]
[[package]]
name = "tree-sitter-language"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38eee4db33814de3d004de9d8d825627ed3320d0989cce0dea30efaf5be4736c"
[[package]]
name = "tsg-python"
version = "0.1.0"

View File

@@ -10,7 +10,7 @@ edition = "2021"
[dependencies]
anyhow = "1.0"
regex = "1"
tree-sitter = "^0.24"
tree-sitter-graph = "0.12.0"
tree-sitter = "0.20.4"
tree-sitter-graph = "0.7.0"
tsp = {path = "tsp"}
clap = "4.5"

View File

@@ -2,6 +2,6 @@
# extractor. It is set to the lowest version of Rust we want to support.
[toolchain]
channel = "1.82"
channel = "1.74"
profile = "minimal"
components = [ "rustfmt" ]

View File

@@ -10,6 +10,7 @@ use std::path::Path;
use anyhow::anyhow;
use anyhow::Context as _;
use anyhow::Result;
use clap::{Command, Arg, ArgAction};
use tree_sitter::Parser;
use tree_sitter_graph::ast::File;
use tree_sitter_graph::functions::Functions;
@@ -480,14 +481,18 @@ pub mod extra_functions {
}
fn main() -> Result<()> {
let matches = clap::Command::new("tsg-python")
let matches = Command::new("tsg-python")
.version(BUILD_VERSION)
.author("Taus Brock-Nannestad <tausbn@github.com>")
.about("Extracts a Python AST from the parse tree given by tree-sitter-python")
.args(&[
clap::arg!("-t --tsg [TSG]"),
clap::arg!("--source <SOURCE>"),
])
.arg(
Arg::new("tsg")
.short('t')
.long("tsg")
.action(ArgAction::Set)
.required(false)
)
.arg(Arg::new("source").index(1).required(true))
.get_matches();
let tsg_path = matches
@@ -497,7 +502,7 @@ fn main() -> Result<()> {
let source_path = Path::new(matches.get_one::<String>("source").unwrap());
let language = tsp::language();
let mut parser = Parser::new();
parser.set_language(&language)?;
parser.set_language(language)?;
// Statically include `python.tsg`:
let tsg = if matches.contains_id("tsg") {
std::fs::read(&tsg_path).with_context(|| format!("Error reading TSG file {}", tsg_path))?

View File

@@ -26,7 +26,7 @@ path = "bindings/rust/lib.rs"
## When updating these dependencies, run `misc/bazel/3rdparty/update_cargo_deps.sh`
[dependencies]
tree-sitter = "^0.24"
tree-sitter = ">= 0.20, < 0.21"
[build-dependencies]
cc = "1.2"