raineorshine / solgraph

Visualize Solidity control flow for smart contract security analysis. :dollar: ⇆ :dollar:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Throw error when meet abstract contract.

CyberFork opened this issue · comments

`
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}

function _msgData() internal view virtual returns (bytes memory) {
    this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
    return msg.data;
}

}
`
Parse error
{ SyntaxError: Expected "contract", "import", "interface", "library", "pragma", comment, end of input, end of line, or whitespace but "a" found. Line: 20, Column: 1
at peg$buildStructuredError (/usr/local/lib/node_modules/solgraph/node_modules/solidity-parser-sc/build/parser.js:1376:12)
at Object.peg$parse [as parse] (/usr/local/lib/node_modules/solgraph/node_modules/solidity-parser-sc/build/parser.js:15723:11)
at Object.parse (/usr/local/lib/node_modules/solgraph/node_modules/solidity-parser-sc/index.js:34:23)
at _default (/usr/local/lib/node_modules/solgraph/dist/index.js:91:21)
at /usr/local/lib/node_modules/solgraph/dist/bin.js:29:37
message:
'Expected "contract", "import", "interface", "library", "pragma", comment, end of input, end of line, or whitespace but "a" found. Line: 20, Column: 1',
expected:
[ { type: 'other', description: 'whitespace' },
{ type: 'other', description: 'end of line' },
{ type: 'other', description: 'comment' },
{ type: 'literal', text: 'pragma', ignoreCase: false },
{ type: 'literal', text: 'pragma', ignoreCase: false },
{ type: 'literal', text: 'pragma', ignoreCase: false },
{ type: 'literal', text: 'import', ignoreCase: false },
{ type: 'literal', text: 'import', ignoreCase: false },
{ type: 'literal', text: 'import', ignoreCase: false },
{ type: 'literal', text: 'contract', ignoreCase: false },
{ type: 'literal', text: 'interface', ignoreCase: false },
{ type: 'literal', text: 'library', ignoreCase: false },
{ type: 'other', description: 'whitespace' },
{ type: 'other', description: 'end of line' },
{ type: 'other', description: 'comment' },
{ type: 'end' } ],
found: 'a',
location:
{ start: { offset: 290, line: 20, column: 1 },
end: { offset: 291, line: 20, column: 2 } },
name: 'SyntaxError' }

The parser needs to be updated from solidity-parser-sc to solidity-parser-antlr or another parser that supports abstract contract syntax. I'm not actively working on this project any more but I would be happy to accept a PR.

hey I'm facing the same challenge is there any link that i can refer to

Fixed in v1.0.0. Special thanks to @yellowBirdy.