-
Notifications
You must be signed in to change notification settings - Fork 56
[Question] automatically generating typing from concrete output or the test cases? #47
Comments
Hi @yxliang01, thanks for bringing this up! I don't see a simple way of generating that sort of type information automatically, but I am more than willing to bring the type definitions into this repo so that they can be updated with less bureaucracy and kept up-to-date with any implementation changes. Could you open a pull request to begin that effort? |
@federicobond Sure. It sounds good. I will do it tomorrow. But, since you are aware of this typing thing going on, would you think it's a good idea to bring the typescript tool chain to this project and we simply annotate the types incrementally? This way might some make this library even less error-prone and we sometimes might get benefit from the typescript compiler's type inference. What do you think? |
I think it's a good idea but I would like to do it in two phases. First, bring the type definitions as an independent file, then consider moving the codebase to TypeScript. |
@federicobond Please see #48 and the created PR as the begin of this effort. |
I had a deeper look at the ANTLR grammar and feel like it doesn't really define the structural constraint of the Solidity language. So, it indeed doesn't look like we can just "convert" the grammar to TS types. But, now I see a possibility that we might be able to convert from the quite complete test at https://raw.githubusercontent.com/federicobond/solidity-parser-antlr/master/test/ast.js (Thanks for the good testing :) ). Changing the issue title now. |
@LogvinovLeon Would you like to describe how you created these types previously? Was it automatically generated? Were you simply converting from
Expression , SimpleStatement ) and looks like they are the intermediate types returned by the ANTLR parser. Correct me if wrong.
|
I did parse a rather complex contract and iterated over the generated AST to generate those. |
@yxliang01 that's correct. ANTLR outputs a parse tree (which is a version of a concrete syntax tree). Most of the code in this lib is dedicated to transforming that parse tree into an AST. |
@federicobond Are you also confirming that |
I think so, yes. |
This issue is to discuss the possibility of having the typing for the output of the parser automatically generated. Currently, the typing file at https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/solidity-parser-antlr/index.d.ts is more or less manually written and is very incomplete. Since the output is very structured, I feel like this is doable. However, I haven't figured out a way yet. Any thoughts?
The text was updated successfully, but these errors were encountered: