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

Question: how to add line number to the parser AST? #15

Closed eldadp100 closed 2 years ago

eldadp100 commented 2 years ago

Hi, I think this should be a common question. How can I add the line number to the parser output? Thanks!

tintinweb commented 2 years ago

Hi @eldadp100 👋

call parse_file(..., loc=True,...) which should produce output like:

 'isConstructor': False,
                             'isFallback': False,
                             'isReceive': False,
                             'loc': {'end': {'column': 0, 'line': 18},
                                     'start': {'column': 0, 'line': 13}},
                             'modifiers': [],
                             'name': 'withdrawBad2',