Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ts_parser_parse_string seems to hang when the parsing fails #303

Open
balsoft opened this issue Oct 27, 2022 · 2 comments
Open

ts_parser_parse_string seems to hang when the parsing fails #303

balsoft opened this issue Oct 27, 2022 · 2 comments

Comments

@balsoft
Copy link

balsoft commented Oct 27, 2022

With GHC 9.0.2, ts_parser_parse_string seems to hang if the parsing fails. Reproduce:

❯ ghci
GHCi, version 9.0.2: https://www.haskell.org/ghc/  :? for help
ghci> import Foreign
ghci> import TreeSitter.Haskell
ghci> import TreeSitter.Parser
ghci> import TreeSitter.Tree
ghci> import Foreign.C
ghci> parser <- ts_parser_new
ghci> _ <- ts_parser_set_language parser tree_sitter_haskell
ghci> (str, len) <- newCStringLen "this hangs everything"
ghci> tree <- ts_parser_parse_string parser nullPtr str len -- This hangs indefinitely
^C^CInterrupted.

The same works if the string is valid tree-sitter's Haskell grammar (including an empty string).

I have tree-sitter-haskell-0.3.0.2, tree-sitter-0.9.0.3 and ghc-9.0.2. If that matters, this is NixOS Linux, and all packages are provided from nixpkgs. The exact environment can be reproduced with NIX_PATH=nixpkgs=https://github.com/nixos/nixpkgs/archive/c5924154f000e6306030300592f4282949b2db6c.tar.gz nix-shell -p 'haskellPackages.ghcWithPackages (ps: with ps; [ tree-sitter tree-sitter-haskell ])' .

I'm not sure how to debug this further.

@jorpic
Copy link
Contributor

jorpic commented Jan 21, 2023

I don't know what is the root of the problem but tree-sitter-0.9.0.3 is really outdated and depends on a version of tree-sitter that is more than 2 years old.

I updated dependencies here and now it works without looping forever.
Please see example in this gist.
Or you can git clone https://gist.github.com/e60cd0cb3a14acf28b87f7e5838bcd70.git issue303 and try it.

@2482411499
Copy link

docs/section-3-creating-parsers.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants