Skip to content

Commit

Permalink
Fix python consumer (#118)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Helwer <2n8rn1w1f@mozmail.com>
  • Loading branch information
ahelwer authored May 15, 2024
1 parent 08d9156 commit 22e7897
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
20 changes: 14 additions & 6 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
let pkgs = import <nixpkgs> {};
in pkgs.mkShell {
packages = with pkgs; [
{ pkgs ? import <nixpkgs> {} }:

let
unstable = import (fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/nixpkgs-unstable.tar.gz";
sha256 = "0lisfh5b3dgcjb083nsxmffvzxzs6ir1jfsxfaf29gjpjnv7sm7f";
}) {};
in

pkgs.mkShell {
packages = [
(pkgs.python3.withPackages (python-pkgs: [
python-pkgs.setuptools
python-pkgs.wheel
python-pkgs.build
]))
(tree-sitter.override { webUISupport = true; })
emscripten
gcc
(unstable.tree-sitter.override { webUISupport = true; })
pkgs.emscripten
pkgs.gcc
];
}

9 changes: 4 additions & 5 deletions test/consumers/python/main.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import tree_sitter_tlaplus as tstla
from tree_sitter import Language, Parser

TLAPLUS_LANGUAGE = Language(tstla.language(), 'tlaplus')
parser = Parser()
parser.set_language(TLAPLUS_LANGUAGE)
TLAPLUS_LANGUAGE = Language(tstla.language())
parser = Parser(TLAPLUS_LANGUAGE)
tree = parser.parse(bytes("""
---- MODULE Test ----
op ≜ ∀ n ∈ ℕ : n ≥ 0
====
""", "utf8"))
print(tree.root_node.sexp())
print(tree.root_node)

query = TLAPLUS_LANGUAGE.query('(def_eq) @capture')
query = TLAPLUS_LANGUAGE.query('(def_eq \"\") @capture')
for node, capture_name in query.captures(tree.root_node):
print(node)

0 comments on commit 22e7897

Please sign in to comment.