AstuteSource / chasten

:dizzy: Chasten Uses XML and XPATH to Check a Python Program's AST for Specified Patterns!
https://pypi.org/project/chasten/
GNU General Public License v2.0
7 stars 8 forks source link

Use Treesitter S-Expressions to Run Queries Instead of XPath Expressions #25

Open gkapfham opened 1 year ago

gkapfham commented 1 year ago

Right now the chasten tool uses XPath expressions to query an XML-based representation of a Python program. However, this means that chasten can only work correctly for Python programs!

It would be awesome if chasten could parse source code from any Treesitter-supported language (there are many!) and then use Treesitter S-expressions to run queries for source code patterns.

The complete implementation of this feature would likely require a significant amount of re-implementation of core functionality. However, this feature would be a game changer for chasten because the tool would then support static analysis of programs implemented in many different programming languages!

simojo commented 9 months ago

S Expressions: https://en.wikipedia.org/wiki/S-expression Tree-Sitter querying syntax: https://tree-sitter.github.io/tree-sitter/using-parsers#query-syntax Tips for using Tree-Sitter queries: https://www.bearer.com/blog/tips-for-using-tree-sitter-queries

simojo commented 9 months ago

@Jaclynpqc have you started working on this?

Jaclynpqc commented 9 months ago

@simojo Yes, I'm mostly testing and learning how to use Treesitter at the moment. This is not an urgent feature, more like a nice-to-have, plus it involves changing our code, so I don't think we could incorporate and finish it by the end of the semester. Feel free to experiment with this issue if you like! And thanks for the resources

Jaclynpqc commented 9 months ago

update: I've figured out how to run it to parse Python code However, due to time limitation and more urgent issues, this issue is on hold and I'm focusing on other issues needed to get done