In fact I wouldn't blame the original author, in the absence of knowledge that there was a body of theory giving other efficient approaches, for implementing a parser in that basically transformational style. I'd done so myself a few years earlier, when I thought I'd try implementing an expression evaluator with no prior reading just to see whether I could.
It's all the details that were wrong. If he'd only started by lexing the expression into a list of atoms and operators – in fact, preferably a linked list, for ease of changing length – then he wouldn't have had to keep shifting entire strings back and forth all the time...
In fact I wouldn't blame the original author, in the absence of knowledge that there was a body of theory giving other efficient approaches, for implementing a parser in that basically transformational style. I'd done so myself a few years earlier, when I thought I'd try implementing an expression evaluator with no prior reading just to see whether I could.
It's all the details that were wrong. If he'd only started by lexing the expression into a list of atoms and operators – in fact, preferably a linked list, for ease of changing length – then he wouldn't have had to keep shifting entire strings back and forth all the time...