Re:TinyCompiler: A compiler in a week-end
by lelanthran on Friday February 21, 2025 @12:54AM
(#43124426)
It's hard if:
1. You dont recognise the recursive nature of the problem,
Or
2. You don't recognise the stack-based nature in the problem (shunting yard algo, etc).
IOW, you did it the hard way :-).
Re:TinyCompiler: A compiler in a week-end
by PhilipRoman on Friday February 21, 2025 @02:11AM
(#43124897)
Good to know I wasn't alone in writing terrible expression parsers. Since I knew absolutely nothing about parsing, my parser/interpreter consisted of splitting on whitespace, followed by linear scanning to find the most high precedence operation, repeated until a single token remains (basically how a human would do it).
I never got much farther than that though, I've looked into making a compiler many times and got overwhelmed every time.