Wednesday, December 12, 2018

Interface to the shunter

// Expr a + b - (8 * 9 ) ; // For example
int Entry(int*argc,void * args[]) {
int idx = *argc;
(*argc) += 2;
if(strcmp("Expr",(char *) args[idx) return(0);
return(shunt(args[idx+1));  // returns pointer to output stack for consumption
}

Once again, simple, universal.  the shunter returns  a pointer to the output stack, it is the unfolded version of the syntax string in args on request. My original expression parser was on the bus anyway, this is the most optimum for our needs, it works as advertised and is an easy maintain. It is standard, and any other c version of the thing would be splitting hairs.

I could have an interface to change the operator table. The code has the original wiki comments, I am not the first to c, java, cpp, or forth, the algorithm, old reliable, very popular, easy to modify.

I am proof of the pudding.  I am the amateur here, yet any day of the week I can connect any of those utilities to any of three syntax engines and intermis ha with any  library, java library, sglite, or anything else, either shared library or I can pipe it, they are all on linux bus already. They can all be intelligently interconnected via the syntax engines, all of this loadable. All I needed to sorted out was shared libs, and some core linux system calls.  Almost everything else is a cut n paste, from the pros, ready to use. Absolutely no headers, all variable scoping done by great syntax engines from Golang, Forth, Python. All these dictionary handlers having full direct access to thousands of linux utils. All basically free, via prior agreement on a simple interface.

Dangerous? No more dangerous than hanging on a real hardware bus, both extraordinarily dangerous.  That is where the upper layer comes in, syntax or otherwise, and I dunno nor care, but it becomes an issue, not at my level, not in test and development, not the lab.

It is th knowing that, oh yes, I can always take a standard  string of arithmetic and issue an Expr command, as if it were a linux command line. But, in software, you can always do it, almost anywhere under ad hoc conditions, because it is loadable and there is console loop, short pass thru..

No comments: