A minimalistic programming language written in C89.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
706 B

преди 6 месеца
  1. #include "ink.h"
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <malloc.h>
  5. int nop_putchar(int n) {
  6. return n;
  7. }
  8. int main(int _1, char** _2) {
  9. char read_buffer[2048];
  10. struct context* ctx = ink_make_default_context();
  11. ctx->putchar = nop_putchar;
  12. char* argv_d[3];
  13. argv_d[0] = "test/bench01.nk";
  14. argv_d[1] = "test/bench02.nk";
  15. argv_d[2] = "test/bench03.nk";
  16. char** it = argv_d;
  17. char** end_argv = it + 3;
  18. for(; it != end_argv; it++) {
  19. FILE* file = fopen(*it, "r");
  20. size_t cnt = fread(read_buffer, 1, 2047, file);
  21. if(cnt == 0) {
  22. }
  23. read_buffer[cnt] = 0;
  24. ink_compile(ctx, read_buffer);
  25. if(ctx->panic) {
  26. perror("Panicked !!");
  27. }
  28. fclose(file);
  29. }
  30. return ctx->panic;
  31. }