Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for AST-diffing Solidity #266

Open
monperrus opened this issue Feb 7, 2022 · 8 comments
Open

add support for AST-diffing Solidity #266

monperrus opened this issue Feb 7, 2022 · 8 comments

Comments

@monperrus
Copy link
Contributor

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."

@jrfaller
Copy link
Member

jrfaller commented Feb 7, 2022

Nice idea!

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

@jrfaller
Copy link
Member

jrfaller commented Feb 8, 2022

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 ^^

@monperrus
Copy link
Contributor Author

monperrus commented Feb 8, 2022 via email

@jrfaller
Copy link
Member

jrfaller commented Feb 8, 2022

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

@Coppelian
Copy link

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

@jrfaller
Copy link
Member

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.

@monperrus
Copy link
Contributor Author

For the record, we have a first prototype at https://github.com/mojtaba-eshghie/solidity-code-diff

@monperrus
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants