Thursday, November 10, 2011

My G machine at 120 lines

If it compiled and was more than a few notes to myself.  But these notes do seem to make a complete G machine.

But to make it run, the simplicity engineers have to define sql operation sequences for it, and install them when the G machine starts.  So I made a sample config file to install ops in G, here it is:

Opcode('&',
Sql('Select * from ?v limit 10 offset ?;'),
Result, Stack
)
I wrote the thing in macro, these little macros define a new SQL operation foe the G machine to run.  The opcode assigned to the ampersand..  Later, when running,  G finds the & and does the sql statement, first filling in the parameters marked ?.

Continuing with the configuration, the next line tells the installer which G variables to set into the SQL before running.  It is establishing a map between what's happening in the machine and what the SQL statement wants.  In this case, it is picking a known system variables, one a string point to table id and another a row pointer.  Both variable published ahead of time, an agreed to by name.  The M4 just lays out the record structures and they are load into sql as the local config store for engines.

So, I am down to the M4 macro thing and 120 new lines of c code embedded with sqlite3. (And tons  SQL code!!!)

No comments: