Wednesday, December 12, 2018

A great args trick

typedef  sruct {
void * arg;
int index} Pstack;
void Shunt{int * argc, void  * args[]) {
Pstack out; 

out.arg= PStack) args[*argc + 1];
Pstack in = out;
shunt(in,out);
}


Here is my new interface for the Tower of Hanoi parser.  The Pstacks hold point to the same stack star, but use different indicies 

I have two stacks, pointing to the same pointer!  But I know the stuff being consumed is a step ahead of the stuff being produced.

So the 'in' stack does a pull from the bottom, the 'out' stack a push to the top. Shunt has know clue that it is rearranges the args list, in place. This makes for repeated execution that starts immediately after compilation. Really good idea, usable by any of the more sophisticated syntax engines. Shunt is a great general purpose parser.

One can keep the shunter and swap the table, creating more complex grammars.  Great for role play, used in conjuction with syntax engine suited.

Swapping outthe operandtable.

The ther trick with shunt is to add operand flags like:
-local
-var
-long

Make them bind properly by setting precedence value.  Then the execution uiunit can look up the real value in  real time. Var means address in symbol table. int mean real binary long. The linux flag '-' is neither alpha nor digit, easily distinguished.

Add the flag 
-extern
It means the next arg is interpreted as a scoping variable used to distinguish Any module that adopts the flag can operate within a contained group over the bus. modules during the console command search.

How does console loop handle scoping?
It doesn't, I go find a package from the pros and write an interface. We need a loadable that gets what scoping is and knows the -extern flag, console is clueless (I am just now figuring on it) . But enterprises can find a sophisticated scoping dictionary, adapt it to the bus, get complex dependencies, and have them managed.  

No comments: