solidity-parser / parser

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

Natspec parsing? #82

Open lnist opened 1 year ago

lnist commented 1 year ago

In the old repo there was some work on parsing natspec, see https://github.com/federicobond/solidity-parser-antlr/issues/82 . Is it supposed to be merged here?

I tried

const parser = require('@solidity-parser/parser');

const input = `
    contract test {
        uint256 a;
        ///@notice foo
        ///@param a bar
        function f(uint a) {}
    }
`
try {
    const ast = parser.parse(input)
    console.log(ast.children[0].subNodes[1])
} catch (e) {
    if (e instanceof parser.ParserError) {
        console.error(e.errors)
    }
}

But I don't see anything related to natspec. It would be nifty since solhint could then use it to warn on missing natspec for params/returns.

fvictorio commented 1 year ago

Not planned, to be honest. This would mean changing a lot how comments are handled by the grammar, and I don't think I'll have the bandwidth to do it. Of course, if someone wants to give it a shot, PRs are welcome.