fixes for examples - many todo for now and need refactors for separating parse / interpret...
This commit is contained in:
parent
004f916aa3
commit
9ec2dffd1b
@ -142,7 +142,7 @@ static word_body word_processed_body(word *w) {
|
||||
|
||||
enum SLC_SYM_OP { SLC_SYM_SET = 0, SLC_SYM_GET = 1, SLC_SYM_ERASE = 2 };
|
||||
typedef enum SLC_SYM_OP SLC_SYM_OP;
|
||||
enum SLC_STACK_OP { SLC_STACK_PUSH, SLC_STACK_POP, SLC_STACK_AT, SLC_STACK_COUNT, SLC_STACK_ERASE };
|
||||
enum SLC_STACK_OP { SLC_STACK_PUSH, SLC_STACK_POP, SLC_STACK_AT, SLC_STACK_POPAT, SLC_STACK_COUNT, SLC_STACK_ERASE };
|
||||
typedef enum SLC_STACK_OP SLC_STACK_OP;
|
||||
enum SLC_SESSION_OP {
|
||||
SLC_SESSION_ALLOC,
|
||||
@ -152,7 +152,8 @@ enum SLC_SESSION_OP {
|
||||
SLC_SESSION_SET,
|
||||
SLC_SESSION_GET32,
|
||||
SLC_SESSION_SET32,
|
||||
SLC_SESSION_PROCESS
|
||||
SLC_SESSION_PROCESS,
|
||||
SLC_SESSION_MARK
|
||||
};
|
||||
typedef enum SLC_SESSION_OP SLC_SESSION_OP;
|
||||
enum SLC_IO_OP {
|
||||
@ -197,6 +198,7 @@ typedef void* (*sym)(SLC_SYM_OP op, do_not_save_charptr key, void *ptr);
|
||||
* SLC_STACK_PUSH pushes the "elem" to the stack. Returns 1 if succeeded, otherwise 0.
|
||||
* SLC_STACK_POP pops the stack - does not return meaningful value, beware of underflowing!
|
||||
* SLC_STACK_AT returns the "param"th element down from the top of the stack
|
||||
* SLC_STACK_POPAT pops at the paramth element down from the top of the stack
|
||||
* SLC_STACK_COUNT returns the number of elements in the stack
|
||||
* SLC_STACK_ERASE Makes the stack empty. Basically as if you would POP the COUNT times.
|
||||
*
|
||||
@ -211,13 +213,14 @@ typedef uint32_t (*stack)(SLC_STACK_OP op, uint32_t param);
|
||||
*
|
||||
* Operations:
|
||||
* SLC_SESSION_ALLOC allocates parameter amount of memory and returns an accessor index.
|
||||
* SLC_SESSION_ERASE erase the session storage (all of it) - all parameters are unused
|
||||
* SLC_SESSION_ERASE erase the session storage (until last marker!) - all parameters are unused
|
||||
* SLC_SESSION_PUSH adds the given byte (value in i) to the end of the session storage (by growing it) - j unused
|
||||
* SLC_SESSION_GET gets byte at the ith accessor index - j unused
|
||||
* SLC_SESSION_SET gets byte at the ith accessor index to be of (byte)j
|
||||
* SLC_SESSION_GET32 gets uint32_t at the ith accessor index - j unused. XXX: Beware, architectures unaligned access crash!
|
||||
* SLC_SESSION_SET32 gets uint32_t at the ith accessor index to be of j. XXX: Beware, architectures unaligned access crash!
|
||||
* SLC_SESSION_PROCESS gets the last j bytes and moves them overriding bytes at index i, then "shrinks" the storage by j.
|
||||
* SLC_SESSION_MARK sets marker
|
||||
*
|
||||
* @param op Defines which operation the caller wants.
|
||||
* @param i Used on SESSION_GET and is the accessor index, in case of SESSIN_ALLOC it is the amount to allocate.
|
||||
|
22
main.c
22
main.c
@ -46,18 +46,18 @@ char testcoderead() {
|
||||
static int i = 0;
|
||||
static const char *code =
|
||||
"// This is a small test program to push(42); print\n"
|
||||
"/*#push(21)\n"
|
||||
"#push(21)\n"
|
||||
"#add*/\n"
|
||||
" #push(42)\n"
|
||||
" #print\n"
|
||||
"/*#21\n"
|
||||
"#21\n"
|
||||
"#+*/\n"
|
||||
" #42\n"
|
||||
" #printnum\n"
|
||||
"\n"
|
||||
"#: word_test\n"
|
||||
" #push(21)\n"
|
||||
" #push(21)\n"
|
||||
" #add\n"
|
||||
" #print\n"
|
||||
"\n"
|
||||
" #21\n"
|
||||
" #21\n"
|
||||
" #+\n"
|
||||
" #printnum\n"
|
||||
";\n"
|
||||
"word_test\n";
|
||||
return code[i++];
|
||||
}
|
||||
@ -80,7 +80,7 @@ int main(int argc, const char **argv) {
|
||||
"/*", // multiline_comment_opener
|
||||
"*/", // multiline_comment_closer,
|
||||
"#", // prefix
|
||||
"#", // ender
|
||||
";", // ender
|
||||
"@" // varprefix
|
||||
);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user