astexplorer icon indicating copy to clipboard operation
astexplorer copied to clipboard

WIP: [parsers] Add tree-sitter POC

Open forivall opened this issue 6 years ago • 2 comments

At the very least, this is waiting on https://github.com/tree-sitter/tree-sitter/pull/481 to be merged and released, so the patch-package hackage can be removed.

Very POC, requesting feedback. As tree-sitter's parsing internals are written in C, this requires some changes to get the WASM binary to load, so feedback on that in particular would be appreciated.

forivall avatar Nov 09 '19 04:11 forivall

So, am I correctly understanding that this is the JavaScript parser generated by tree sitter? I see that it supports various languages. Does that mean we could also add a parser for e.g. Bash?

The incremental stuff sounds interesting! Will have to look into that some more at some point.

fkling avatar Nov 09 '19 18:11 fkling

Exactly, yes, this is the JavaScript parser that tree-sitter generates (from tree-sitter-javascript). I wanted to see what the structure its JavaScript AST looked like and see if it's ESTree or not, and the best way i thought of was to submit it here, then other people can look at how tree-sitter works! And yes, this means we can add parsers for whichever languages tree-sitter can parse.

For the incremental stuff to work fully, it looks like we have to notify the tree-sitter internals about the edits (see the docs and their playground's code, which, like astexplorer, uses codemirror), but getting that to work would take additional changes to astexplorer's redux-saga data model, and i just didn't have time for that then.

forivall avatar Nov 10 '19 21:11 forivall