Skip to content
This repository has been archived by the owner on Sep 27, 2020. It is now read-only.

Add suport for parsing type name fragments #85

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

cd1m0
Copy link

@cd1m0 cd1m0 commented Sep 3, 2019

In the process of introspecting solc's ast, we have a use case to parse the type strings embedded in some nodes. It seems that this can be perfectly solved using the solidity-parser-antlr. This PR propses a small new entry point to the parser:

function parseType(input, options) {

That is almost identical to parse(), but parses strings representing just typeName fragments, instead of whole contracts.

So for example one could run:

> parser.parseType('uint[]', {strict: true})
{ type: 'ArrayTypeName',
  baseTypeName: { type: 'ElementaryTypeName', name: 'uint' },
  length: null }
> 

The PR also adds several tests for common solidity types in test/index.js and fixes 2 small lint issues.

Thank you for considering this!

Best
~Dimo

@cd1m0
Copy link
Author

cd1m0 commented Sep 3, 2019

Appologies, I did not open an issue first. If you wish I can also open an issue and reference it here?

@obernardovieira
Copy link
Contributor

Hi, I see 2273972 above, I wonder if you are working on any natspec related? I worked on it in the past, and it got merged (#71), but unfortunately, there were a few cases that I haven't tested so my changes got reverted.
Since that time, and because I want to use solidity-parser-antlr for everything in my solidity documentation tool (https://github.com/HQ20/soldoc) I decided to fork and make it work. That was when I realized the limitations. See here https://github.com/obernardovieira/solidity-parser-antlr I'm very proud of it and planning to open a PR. If there's any chance that we merge our work or see wht fits best. I would appreciate a lot 👍 thanks for your time

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

Successfully merging this pull request may close these issues.

None yet

3 participants