Wednesday, December 12, 2018

But args are always 64 bit, these days

Great, define the 8 char, fixed width immediate string format. This is great for Shunt, the ability to have very large tables with simple long compares.


 typedef union {
long l;
char s[8];
} Text;

Text t;

t can hold an eight character fixed sized string, such as `Open`, `Close`, `Create`, ...
and compared with:

 if(t.l == `Hello`)

The new quote pair denote ordering according to processor byte order scheme, and the syntax implies right shifted chars in the eight byte field.
This makes extremely fast scripting formats, more like my inline indexing model in join.  I can built really complex, context specific dictionaries, then load them into a shunt machine, as operators. Or make very high speed grammar symbol tables.

I can make this a real time mode selector for shunt.  Now it works with three operating mode selects, the code is not changed much. I will also make a LoadShun command, foe access to the table.

Make a two step look up:

Then we get:

TextLookUp(Text t) {
    int k=0;
    long i=t0;
    while(k < 8) {
      i =table1[i][t.s[k]) ;
       k++;
      if(!t.s[k]) // end of symbol
         return(i);
 }
 return(0); // Unidentified
}

Table is an array of size corresponding to the longest symbol you used, of the fixed  sized window.  So if you have a Shun sript with fixed sized five char operators, you have 32 element tables, a five step look up, each step a simple word access in the processor. Faster than a hash table because you 'Huffman encode', like Morse code, the most frequent operators have the shortest path length and complete the look up in fastest time.

Great trick, I will make this a standard look up mode in symbol table from now on.

No comments: