logoalt Hacker News

aapplebylast Sunday at 5:25 AM1 replyview on HN

Yes, but it doesn't need any funny parsing trick to handle them. Just parse the whole statement as a list of expressions joined by operators, and then you can convert the flat list into a precedence-respecting tree with a few lines of code and an operator-to-precedence table.


Replies

childintimelast Sunday at 5:43 AM

Yes, it's as easy as that. Or check out Jonathan Blow on precedence.

The infamous dragon book convinced people to use the wrong tools and have the wrong mindset. It was a work of incompetence. There were no dragons, but the book itself.