tree-sitter / tree-sitter

An incremental parsing system for programming tools
https://tree-sitter.github.io
MIT License
18.62k stars 1.45k forks source link

Lots of errors when trying to build a C++ parser #3521

Closed mrcjkb closed 3 months ago

mrcjkb commented 3 months ago

Problem

Hey :wave:

I'm trying to run tree-sitter build (with the Rust CLI) on tree-sitter-norg, which has a C++ scanner.

With tree-sitter version 0.22.5, it works fine. With version 0.22.6, I get lots of errors like:

/build/source/src/parser.c:634931:1: error: designator order for field 'TSParseAction::<unnamed struct>::child_count
' does not match declaration order in 'TSParseAction::<unnamed struct>'

and

src/parser.c:469936:1: sorry, unimplemented: non-trivial designated initializers not supported

In both cases, I see a warning,

Warning: Using a C++ scanner is now deprecated. Please migrate your scanner code to C, as C++ support will be removed in the near future.

Has support for C++ scanners been removed already?

Steps to reproduce

git clone --depth=1 git@github.com:nvim-neorg/tree-sitter-norg.git cd tree-sitter-norg tree-sitter build

Expected behavior

The parser builds

Tree-sitter version (tree-sitter --version)

tree-sitter 0.22.6

Operating system/version

NixOS 24.11.20240725.5ad6a14 (nixos-unstable)

clason commented 3 months ago

C++ scanners are not supported any longer, because they cannot be compiled to WASM. (Which is why nvim-treesitter has dropped the norg parser in 1.0.)

clason commented 3 months ago

(Support was not explicitly removed, but changes are no longer guaranteed to work with C++ scanners. You can try bisecting, but I strongly suspect that your issues come from https://github.com/tree-sitter/tree-sitter/commit/a2d2da314d7ca9151abb340cf988eccdd694b64a so are actually a config issue.)

mrcjkb commented 3 months ago

Thanks, that's all the info I need :smile:

clason commented 3 months ago

Related (old) issues: https://github.com/tree-sitter/tree-sitter/issues/254 https://github.com/tree-sitter/tree-sitter/issues/543