Re:A Regular Expression Matcher (2007)
by bluetomcat on Thursday August 25, 2022 @02:55AM
(#32590474)
This just illustrates the power of recursion. With it, the call stack becomes your invisible data structure - it keeps all saved program state deep down. The same approach is used to write recursive-descent parsers for languages with an inherently recursive definition.
You could also devise an iterative solution that wouldn't be more complex - then you simply have to maintain explicit stacks for operators and operands.
You could also devise an iterative solution that wouldn't be more complex - then you simply have to maintain explicit stacks for operators and operands.