parser icon indicating copy to clipboard operation
parser copied to clipboard

Multiple prefix ops allowed

Open jozsef-ostor opened this issue 3 years ago • 1 comments

I think the parser should refuse --1 ++1

jozsef-ostor avatar Mar 07 '22 14:03 jozsef-ostor

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.

cosinekitty avatar Mar 07 '22 14:03 cosinekitty