gumtree icon indicating copy to clipboard operation
gumtree copied to clipboard

add support for AST-diffing Solidity

Open monperrus opened this issue 3 years ago • 8 comments

it would be great to add support for diffing Solidity.

For this we can use the existing support from solidity compiler solc

solc --ast-compact-json contract.sol

Flag --ast-compact-json gives the "AST of all source files in a compact JSON format."

monperrus avatar Feb 07 '22 08:02 monperrus

Nice idea!

Apparently there is also a tree sitter grammar : https://github.com/JoranHonig/tree-sitter-solidity

jrfaller avatar Feb 07 '22 08:02 jrfaller

I looked a little bit into the output of solc and it wouldn't be straightforward, the AST is quite far from the CST and lacking a lot of textual position information 😢

I'll try to see if I get more luck with the tree-sitter one ^^

jrfaller avatar Feb 08 '22 09:02 jrfaller

cool, thanks for the update

monperrus avatar Feb 08 '22 11:02 monperrus

ok the tree-sitter version seems a little unstable I got a ValueError: Incompatible Language version 12. Must be between 13 and 13, so I'll have to retry that at some point in the future when it's more stable

jrfaller avatar Feb 08 '22 13:02 jrfaller

Hello there. I found a parser: https://github.com/solidity-parser/parser I wonder if it could be used in this case.

Coppelian avatar Mar 10 '22 22:03 Coppelian

Hi, apparently there is a ANTLR grammar related to the code you point out here : https://github.com/solidityj/solidity-antlr4

And we have support for antlr grammars, so that might worth a try.

jrfaller avatar Mar 11 '22 07:03 jrfaller