Closed hengying closed 3 years ago
Wow, thought I'd tested all of that stuff. I'll take a look. Thanks for the feedback.
I don't know if this is the most elegant solution, but I uploaded the following fix:
try:
if '.' in right:
self.__symbol_table[left] = float(right)
else:
self.__symbol_table[left] = int(right)
except ValueError:
raise ValueError('Non-numeric input provided to a numeric variable ' +
'in line ' + str(self.__line_number))
The input code may end up being overhauled anyway in response to the other current issue, but this should work for now.
Suggest doing it the way I did the VAL function. The advantage is that 1.0
would be stored as an INT
numeric = float(value)
if numeric.is_integer():
numeric = int(numeric)
self.__symbol_table[left] = numeric
But this can wait for #19
When I try this program:
I input 2.34, and the error is displayed: String input provided to a numeric variable
I'm not sure if my program is correct.
I make a simple modification: basicparser.py line: 451
Is there any better solution?