News for hackers. Stuff that matters.
Re:TinyCompiler: A compiler in a week-end by andai on Thursday February 20, 2025 @07:26PM (#43122492)
Is that really the hard part? I figured that part out before I knew much programming: made a simple Excel type formula parser. (A horrible, horrible solution based around replacing strings and manually counting parentheses... but it worked!)

I never got much farther than that though, I've looked into making a compiler many times and got overwhelmed every time.

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).