Subj : baja.c / unbaja.c To : Angus McLeod From : Digital Man Date : Thu Sep 08 2005 06:09 pm Re: baja.c / unbaja.c By: Angus McLeod to Digital Man on 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 thereo > > > to convert infix with nested sub-expressions to postfix, for simplifie > > > evaluation by the low level processor (in this instance, the BAJA > > > low-level execution code). I've always found it a little strange seei > > > parenthesis actually embedded in the low level code as they are (in > > > tokenized form) in Sync's .BIN files. These are usually removed by th > > > (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 > > 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 does seem vaguely familiar. Do you still have that code around anywhere? > 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. :-) Oh how nice it is to have CVS. :-) > 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! :-) Can you give me an example of a postfix version of the following ARS: ((LEVEL 80 OR FLAG S) AND AGE 18) OR LEVEL 90 or LEVEL 90 OR (TIME 12:00 AND TIME NOT 18:00) > > In hind-site, I could've made a *lot* of different/better design decision > > Of course! And let me quote myself: > > > > It wasn't a criticism, just an observation. I didn't take it that way. > 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. Me too! I wrote some programs that looked and worked great on the surface but under the hood were horrendous examples of programming. digital man Snapple "Real Fact" #190: Thailand means "Land of the Free." .