1
C Expressions
HalimHamidov (0)

Expression evaluator

Would you please comment following code for better explanation,
Especially eval_expr.c part of code.
Thanks a lot

You are viewing a single comment. View All
1
mwilki7 (117)

I wonder why they went through the trouble of implementing their own string functions like printing and number conversions.

Like :
write(1, &c, 1);
can be easily rewritten in a more readable format:
printf("%c", c);

Anyhow I added some comments to this code on the repl here:
https://repl.it/@mwilki7/expression-evaluator

Most expression evaluators use some sort of stack data structure (push, pop, first in last out) to keep track of which operations apply to which number. This solution uses the call stack as the stack data structure (also known as recursion).