federicobond / solidity-parser-antlr

A Solidity parser for JS built on top of a robust ANTLR4 grammar
MIT License
155 stars 55 forks source link

VariableDeclaration ASTNode #60

Closed aoli-al closed 5 years ago

aoli-al commented 5 years ago

Can VariableDeclaration be simplified? Currently, VariableDeclaration contains many redundant information.

For example, isStateVar, visibility, and isDeclaredConst are only used when the variable is a state variable. Can we move the information to StateVariableDeclaration? Besides, StateVariableDeclaration will always have one VariableDeclaration object.

I guess we can refactor VariableDeclaration to: typeName, name, and storageLocation.

Another question is why eventParameter, functionParameter, and variableDeclaration share the same variableDeclaration object? Can we separate them?

federicobond commented 5 years ago

Yes, it could be simplified, but the official AST output from solc uses the same node type for all of them AFAIK and I could not find a strong enough case for doing things differently.

If you have a specific use case in mind that could benefit from this change I would be open to considering it.

aoli-al commented 5 years ago

I see. It is reasonable to have the same output as solc parser.

Thanks!

yxliang01 commented 5 years ago

However, the current AST format is very different from solc's though?

federicobond commented 5 years ago

It is, and that is a little bit problematic. I would like to bring it closer over time.