slc/main.c

89 lines
1.9 KiB
C
Raw Permalink Normal View History

2024-09-14 12:54:22 +02:00
#include <stdio.h>
2024-09-26 12:32:58 +02:00
#include <stddef.h> // NULL
2024-09-14 12:54:22 +02:00
#include "hamt.h"
#include "turbolist/turbolist.h"
2024-09-26 12:32:58 +02:00
#define SLC_DEBUG
2024-09-14 12:54:22 +02:00
#include "engine/slc.h"
2024-09-29 16:09:05 +02:00
void *nopsym(SLC_SYM_OP op, do_not_save_charptr key, void *ptr) {
2024-09-29 15:50:53 +02:00
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);
}
2024-09-29 16:09:05 +02:00
return NULL;
// TODO: Create a "peasantly" symbol table where we have:
2024-09-29 02:08:52 +02:00
// - 32 previndex
// - 32 nextindex
2024-09-29 15:50:53 +02:00
// - void* value;
// - char name[]; // inline stored
// - padding (divisible by 8)
//
2024-09-29 02:08:52 +02:00
// 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.
2024-09-26 12:32:58 +02:00
}
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 =
2024-09-28 12:57:01 +02:00
"// This is a small test program to push(42); print\n"
"/*#21\n"
"#21\n"
"#+*/\n"
" #42\n"
" #printnum\n"
2024-09-28 12:57:01 +02:00
"\n"
"#: word_test\n"
" #21\n"
" #21\n"
" #+\n"
" #printnum\n"
";\n"
2024-09-28 12:57:01 +02:00
"word_test\n";
2024-09-26 12:32:58 +02:00
return code[i++];
}
2024-09-14 12:54:22 +02:00
int main(int argc, const char **argv) {
// TODO: Implement CLI frontend...
puts("TODO: Implement CLI frontend...");
2024-09-26 12:32:58 +02:00
// 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
2024-09-26 12:32:58 +02:00
"@" // varprefix
);
2024-09-14 12:54:22 +02:00
return 0;
}