ASTronomer 🔭 ✨👋 Hey there!This repo contains the source code for ASTronomer, a tool which displays TreeSitter Abstract Syntax Trees (ASTs) alongside some tools to make using them easier! This was created out of my frustration with TreeSitter's (harder than it should be) learning curve. Hope it helps! If you would like to contribute please see the "Contributing" section below! How it worksThis extension uses the TreeSitter Javascript WebAssembly (WASM) build, this reason boils down to the extension runtime basically being Electron. ParsingSparing much of the nitty gritty details about how TreeSitter Parsing works (more here), each supported Language requires a Language WASM build. The currently supported are below in the "Supported Languages" subsection. Each of these Languages will be used to parse a document into an AST. The code for this is largely located in RenderingTo render the syntax tree we're using VS Code's built in tree view, although in the future a webview will provide more flexibility. The code for this located in Supported LanguagesCurrently there are 16 supported languages:
Adding New LanguagesThere are two easy ways to do this!
or
Copying sections of the ASTJust right click a node and select "Copy S-Expression" - the S-Expression is how TreeSitter expresses ASTs in text. These also have the nice advantage of being queryable! Querying the ASTSelect the "Run Query" button at the top of the extension. You wil be prompted for a valid S-Expression. The following is an example of a javascript import statement: Note: The syntax is a bit finicky and there are many operators described in the TreeSitter docs here. There is no need to specify an This part of the extension is most susceptible to bugs, if you find any please open an issue! ContributingFeel free to contribute your ideas! This was built in one person's vision, the more ideas the better! |