Re:Abstract Syntax Tree for Patching Code and Assessing Code...
by ievans on Monday June 07, 2021 @02:32PM
(#27426260)
Sounds like you know the language-specific AST tooling for your stack well, but if you are looking for AST patching that uses a generic approach across many languages, I'm a maintainer for a project named Semgrep (https://en.wikipedia.org/wiki/Semgrep#History) which was created by one of the original coccinelle authors.
It supports many more languages (~17 at various stages of development) and being able to do AST patching as in the original is one of the capabilities we're experimenting with: https://semgrep.dev/docs/experiments/overview/#autofix
Would love your feedback!
Re:Abstract Syntax Tree for Patching Code and Assessing Code...
by chgibb on Monday June 07, 2021 @12:20PM
(#27424337)
What was your solution to writing out your parsed Lua AST?
Re:Abstract Syntax Tree for Patching Code and Assessing Code...
by Aissen on Monday June 07, 2021 @01:04PM
(#27425002)
Just checked and I did not output lua code, but I used the AST to do custom static checks; only the js part did code output, and used babel-plugin-recast to get identical formatting.
Before the 1.0 promise, Go used "go fix" to automatically update old code, and the standard library even has tools to manipulate an AST.
The linux kernel uses coccinelle for C code, which goes one step further, and lets you write "semantic patches", which is a DSL to do this in a compact way and without having to write code.