slc/main.c

89 lines
1.9 KiB
C

#include <stdio.h>
#include <stddef.h> // NULL
#include "hamt.h"
#include "turbolist/turbolist.h"
#define SLC_DEBUG
#include "engine/slc.h"
void *nopsym(SLC_SYM_OP op, do_not_save_charptr key, void *ptr) {
if(op == SLC_SYM_ERASE) {
printf("SYM_ERASE\n");
} else {
if(op == SLC_SYM_GET) printf("SYM_GET:");
if(op == SLC_SYM_SET) printf("SYM_SET:");
printf(" %s", key.ptr);
}
return NULL;
// TODO: Create a "peasantly" symbol table where we have:
// - 32 previndex
// - 32 nextindex
// - void* value;
// - char name[]; // inline stored
// - padding (divisible by 8)
//
// Then I can do a lookup basically via strstr-like (but 4byte steps!)
// with first few characters zero-padded in the search term parameter
// and if you want check extra validity by jumping back&forth in it.
}
uint32_t nopstack(SLC_STACK_OP op, uint32_t param) {
return 0;
}
uint32_t nopsession(SLC_SESSION_OP op, uint32_t i, uint32_t j) {
return (uint32_t) -1;
}
iores nopioconn(SLC_IO_OP op, const char *param) {
iores ret;
ret.ptr = NULL;
return ret;
}
char testcoderead() {
static int i = 0;
static const char *code =
"// This is a small test program to push(42); print\n"
"/*#21\n"
"#21\n"
"#+*/\n"
" #42\n"
" #printnum\n"
"\n"
"#: word_test\n"
" #21\n"
" #21\n"
" #+\n"
" #printnum\n"
";\n"
"word_test\n";
return code[i++];
}
int main(int argc, const char **argv) {
// TODO: Implement CLI frontend...
puts("TODO: Implement CLI frontend...");
// TODO: test code removal
slc(
testcoderead, // code_src
nopsession, // session_storage
nopsym, // symbol_table
nopstack, // code_stack
nopstack, // nesting_stack
nopstack, // data_stack
nopstack, // insert_stack
nopioconn, // io_connector
"//", // singleline_comment
"/*", // multiline_comment_opener
"*/", // multiline_comment_closer,
"#", // prefix
";", // ender
"@" // varprefix
);
return 0;
}