The program handles multiple lines of input when reading from a file. For
example, given sample_input
, the command
python adder.py sample_inputprints
Sum: 6 Sum: 27 Sum: 55
Building and running:
antlr -Dlanguage=Python3 adder.g4
python adder.py
antlr4
library): python3 adder.py
There is a bug in version 4.5.3 of ANTLR that means that values are not
propogated correctly in some recursive productions. This means the
above adder.g4
file will crash on the sample input with a
message about not being able to add to Nonetype. The fix is to introduce a
new production; see rest_of_number_list
in the
file REVISED_adder.g4
. Note you
will need to save this file as adder.g4
to build (or change
some of the other code to match this file).