#include #include #include #include #include #include "init.h" #include "t6963c/t6963c.h" #include "t6963c/terminal.h" #include "fuspel/interpreter/lex.h" #include "fuspel/interpreter/parse.h" #include "fuspel/interpreter/eval.h" #include "fuspel/interpreter/print.h" #include "fuspel/interpreter/mem.h" static Terminal* term; int __attribute__((__weak__, __section__(".libc"))) write( int handle, void *buff, unsigned int len) { terminal.append_n(term, (char*) buff, len); return len; } void init_terminal(void) { term = terminal.construct(t6963c_rows * t6963c_columns); term->update = t6963c_update_terminal; } fuspel *import(fuspel *already_parsed, char *name) { return already_parsed; } static char* program = "mul a b = code mul a b;" "sub a b = code sub a b;" "prod = foldr mul 1;" "faclist 0 = [];" "faclist n = [n:faclist (sub 1 n)];" "foldr op r [] = r;" "foldr op r [a:x] = op a (foldr op r x);" "main = prod (faclist 5);"; int main(void) { init(); init_terminal(); token_list* tokens; fuspel* pgm; expression* result; tokens = lex(NULL, program); pgm = parse(tokens); free_token_list(tokens); free(tokens); print_fuspel(pgm); printf("\n\n"); result = eval_main(pgm); if (result) { print_expression(result); printf("\n"); free_expression(result); free(result); } else { printf("Evaluation failed...\n\n"); } free_fuspel(pgm); free(pgm); while (1) Idle(); return 0; }