abstracted out code reader - might need it to support includes better or do they become literally a pass?

This commit is contained in:
Richard Thier 2024-09-14 13:41:00 +02:00
parent 87164e7a65
commit a6f47915d3

View File

@ -31,6 +31,11 @@ enum SLC_IO_OP {
SLC_IO_CMD,
};
typedef enum SLC_IO_OP SLC_IO_OP;
enum SLC_CODE_OP {
SLC_CODE_COUNT,
SLC_CODE_READ,
};
typedef enum SLC_CODE_OP SLC_CODE_OP;
/**
* Function-abstraction for a "symbol-table".
@ -100,10 +105,23 @@ typedef uint32_t (*session)(SLC_SESSION_OP op, uint32_t i);
*/
typedef const char* (*ioconn)(SLC_IO_OP op, const char *param);
/**
* Function-abstraction for reading the source code.
*
* Operations:
*
* SLC_CODE_COUNT To get how much bytes are readable (i is unused). Returns size as uint32_t (full used)
* SLC_CODE_READ To read bytes of the source code at location i. Returns the byte char as uint32_t (low byte)
*
* @param op Defines which operation the caller wants.
* @param i In case of READ, the index of the data.
*/
typedef uint32_t (*coderead)(SLC_CODE_OP op, uint32_t i);
/**
* This function runs the main slc engine over a snippet of code.
*
* @param code The input source code to interpret / run.
* @param code_src The input source code to interpret / run.
* @param symbol_table The symbol table to use
* @param code_stack The code stack (return addresses) to use
* @param data_stack The data stack (forth-like stack) to use
@ -112,7 +130,7 @@ typedef const char* (*ioconn)(SLC_IO_OP op, const char *param);
* @param io_connector The engine uses this to open/close pipes/files and write/read them.
*/
void slc(
const char *code,
coderead code_src,
sym symbol_table,
stack code_stack,
stack data_stack,