github / semantic

Parsing, analyzing, and comparing source code across many languages
8.94k stars 453 forks source link

Add C support #663

Open jtojnar opened 2 years ago

jtojnar commented 2 years ago

Just a basic C parsing support (no tags) based on https://github.com/tree-sitter/haskell-tree-sitter/pull/294.

You can try it by checking out the haskell-tree-sitter branch from https://github.com/tree-sitter/haskell-tree-sitter/pull/294, setting the path in cabal.project.local in the semantic root (e.g. packages: ../haskell-tree-sitter/tree-sitter-c) and then run RUNFILES_DIR=path/to/haskell-tree-sitter cabal run semantic-ast -- --rootdir=. --language=C (I have no idea to make Bazel use local Haskell packages).

patrickt commented 2 years ago

This is very cool. How does the tree-sitter-c package handle #include facilities and the like? The preprocessor is a harsh mistress.

jtojnar commented 2 years ago

Not sure, I never managed to get it working because tree sitter itself was segfaulting for me half the time so I switched to Coccinelle.