Post AzMIfGQtrSQfINKYm8 by aaronsgiles@corteximplant.com
(DIR) More posts by aaronsgiles@corteximplant.com
(DIR) Post #AzMIfGQtrSQfINKYm8 by aaronsgiles@corteximplant.com
2025-10-19T05:36:39Z
1 likes, 0 repeats
So it started a bunch of years ago with needing a basic expression evaluator for the MAME debugger. I found an article about infix-to-postfix conversion and wrote a simple expression compiler/executor based on the standard C operators and precedence. It supported a symbol table and allowed you to register functions that could be called to perform actions or get state.Flash forward to the dawn of DREAMM and I needed to evaluate some expressions, so I ported/cleaned up the engine I wrote for MAME, with essentially the same functionality.With DREAMM 4.0 I wanted to do more, and realized that if I could properly short-circuit the && and || operators, and add proper ternary ? : operator support, I could do quite a lot by combining those with the comma operator.After doing that, I realized it was a small step to add actual if/else keyword processing, and support multiple statements via semicolons instead of the comma hack.Then I realized that while loops were a pretty easy next step, and with some additional syntactic processing I could get C-style for loops working as well.Of course, I soon found a need for break/continue support, so added those keywords next.Then my scripts got complicated enough that I wanted to be able to define functions and call them (as opposed to calling external functions implemented by the engine). This need a bit more syntax, but was still a small step.Functions should be able to have parameters, so the next step was parsing the names of the parameters and mapping them to the items being passed. And functions need to be able to return results, so explicit return keyword support was added.And so at this point I've basically implemented a mostly complete C compiler/interpreter. 😜If I knew this is where I'd end up, perhaps it would have made more sense to find existing code and use that, but at this point I'm kind of committed to my own thing. Also lets me control the behaviors to work like I want them to.
(DIR) Post #AzMIfHDSwtHFj03LTU by feld@friedcheese.us
2025-10-19T06:33:10.016416Z
1 likes, 0 repeats
@aaronsgiles you echo the same opinion about having full control as @SlicerDicer when he does his projects and I tell him of existing solutions lol
(DIR) Post #AzMIhxVyeeidUTzTNI by SlicerDicer@friedcheese.us
2025-10-19T06:34:13.600597Z
0 likes, 0 repeats
@feld @aaronsgiles I refuse to use square wheels. 😂