Multiple prefix ops allowed
Opened this issue · 1 comments
jozsef-ostor commented
I think the parser should refuse
--1
++1
cosinekitty commented
Those are odd inputs, and they would be rejected by a C/C++ compiler because --
and ++
are operator tokens. However, my goal for this Medium article was to present something simple so people could understand recursive descent parsers. So I chose a math display formatter, not a programming language. Although --1
looks strange, it is really the same thing as -(-1)
, which is valid.
However, it would be a good exercise if you want, to fork this project and see if you can update the parser to reject such input strings.