Subj : baja.c / unbaja.c To : Digital Man From : Angus McLeod Date : Thu Sep 08 2005 09:44 pm Re: baja.c / unbaja.c By: Digital Man to Angus McLeod on Thu Sep 08 2005 12:44:00 > > I meant the use of Dijkstra's *shunting* algorithm or a variant thereof, > > to convert infix with nested sub-expressions to postfix, for simplified > > evaluation by the low level processor (in this instance, the BAJA > > low-level execution code). I've always found it a little strange seeing > > parenthesis actually embedded in the low level code as they are (in > > tokenized form) in Sync's .BIN files. These are usually removed by the > > (semi-)compiler by application of some variation of Dijkstra's > > shunting algorithm. It's a very basic sort of code-optimization. > > Honestly, I wasn't aware of any such algorithm and it didn't occur to me tha > the compiled AR strings needed much opimization. :-) I don't mean to imply that ARS evaluation requires any sort of runtime optimization. But I've studies compilers and compiler design and I had never come across any expression-evaluation code that didn't reduce infix to postfix. Not until I first examined the BAJA compiler and it's output, years ago. You may recall that I wrote a BAJA de-compiler long ago. That was before SBBS source code became publicly available. At the time you sent me a copy of the header file containing all the current op-codes (probably cmdshell.h, unless the name has changed). It worked, but unfortunately, by the time it was finished, it was obsolete. The rate of development of BAJA was high at the time, and new 'verbs' were being introduced faster than I could keep up with, and I decided not to make myself a nuisance by demanding a fresh copy of the header file every two/three days. :-) Anyway, I remember *then*, spelunking my way through .BIN files, how surprised I was to find ARS expressions with parenthesised sub-expressions in the low level code. Since Dijkstra's shunting algorithm eliminates sub-expressions, finding tokenized parenthesis in the low-level code was, somehow, disturbing! :-) > In hind-site, I could've made a *lot* of different/better design decisions. Of course! And let me quote myself: > > It wasn't a criticism, just an observation. I have never looked back on any non-trivial code I ever wrote without experiencing the disturbing thought that I could have done better. Even with code that worked flawlessly over a long lifespan without any problems ever being isolated, I always end up feeling that I could improve on it. --- þ Synchronet þ Great programs on the Synchronet Channel at The ANJO BBS .