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.

28 line
617 B

4 月之前
4 月之前
4 月之前
  1. #include "ink.h"
  2. #include <stdio.h>
  3. int main(int argc, char** argv) {
  4. char read_buffer[2048];
  5. struct context* ctx = ink_make_default_context();
  6. char** end_argv = argv + argc;
  7. for(argv+=1; argv != end_argv; argv++) {
  8. FILE* file = fopen(*argv, "r");
  9. size_t cnt = fread(read_buffer, 1, 2047, file);
  10. if(cnt == 0) {
  11. }
  12. read_buffer[cnt] = 0;
  13. ink_compile(ctx, read_buffer);
  14. if(ctx->panic) {
  15. fprintf(stderr, "Panicked !! -> %d\n", ctx->panic);
  16. }
  17. fclose(file);
  18. }
  19. while(ink_can_run(ctx)) {
  20. ink_step_everyone(ctx);
  21. }
  22. printf("\nExecuted in %u steps\n", ctx->steps);
  23. return ctx->panic;
  24. }