Consensys / python-solidity-parser

An experimental Solidity parser for Python built on top of a robust ANTLR4 grammar 📚
https://pypi.org/project/solidity-parser/
142 stars 37 forks source link

Missing spaces in PragmaDirective #23

Open jff opened 2 years ago

jff commented 2 years ago

Contracts such as the Ballot contract shown in the official documentation use pragma versions that follow the same syntax as npm:

pragma solidity >=0.7.0 <0.9.0;

According to the official documentation, this is allowed and the parser seems to support this. However, when parsing contracts like this, the value associated with the PragmaDirective doesn't have any spaces:

>>> sourceUnit['children'][0]
{'type': 'PragmaDirective', 'name': 'solidity', 'value': '>=0.7.0<0.9.0'}

Is there any reason for omitting the spaces? Unfortunately, this precludes the use of other modules that already parse version strings that follow the npm specification. This suggests that it would be better to keep the original format.

jff commented 2 years ago

@tintinweb I wonder if someone from the team had the chance to look at this? Thanks!