Open ldorigo opened 1 year ago
SolidityParser.py.txt Forgot the attachement
For reference, the exact commands I used are:
antlr4 -Dlanguage=Python3 SolidityLexer.g4
antlr4 -Dlanguage=Python3 SolidityParser.g4
That grammar, and in particular SolidityParser.g4, contains locals
and actions, both of which are in a target specific language. While it is not declared with a language option, it is most likely Java. Python3 does not have type declarations, and True
and False
are the literals in the language, not true
and false
. You will need to make a port of the grammar for Python3. There is a target-independent grammar in grammars-v4, but it may be quite old.
I tried generating parsers/lexers using the files at https://github.com/ethereum/solidity/blob/develop/docs/grammar/SolidityLexer.g4 and https://github.com/ethereum/solidity/blob/develop/docs/grammar/SolidityParser.g4 using target=Python3.
The generated Python parser contains syntax errors (exclamation marks before variables and "true" instead of "True"?), e.g.:
I attach the generated file for reference. This is with antlr 4.13.1.