Closed shahilahmed closed 2 years ago
I can replicate this.
To see the reason clearly we can add parentheses to the _print
to get (1 - ((2 * 3) - (8 - 5)))
Which is incorrect, opposed to the correct (((1 - (2 * 3)) - 8) - 5)
But I'm not sure the stories are subject to any change as it supposed to capture the Guido's series on PEG parser and any bugs are preserved, I guess ;) Although to be sure I need to hear from @MatthieuDartiailh
@pablogsal is better placed than myself to answer. I join only after pegen got integrated into cpython and well after the stories.
Yeah, unfortunately, we only keep the stories to keep the links in the original blog working and for historical reasons so we don't really "maintain" the stories. I'm closing the issue, but thanks for raising it with us.
I am following the code of story1.
For expression like
1 + 2 * 3
is evaluating correctly but expression like1 - 2 * 3 - 8 - 5
is not evaluating properlyThe evaluation of
1 - 2 * 3 - 8 - 5
should be-18
not-2
Here is my code to evaluate expression
Here is the output
I could figure it out whether my
_eval()
is correct or not Or There is a bug inToyParser
class.Please help it out.Thank you.
Attachment: story1.zip