A minimalistic programming language written in C89.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

49 wiersze
1.0 KiB

  1. #include "ink.h"
  2. int main(int argc, char** argv) {
  3. struct context* ctx;
  4. ctx = ink_make_default_context();
  5. ink_compile(
  6. ctx,
  7. "macro five do 1 1 1 1 1 + + + + end"
  8. );
  9. ink_compile(
  10. ctx,
  11. "macro tens do five five + end"
  12. );
  13. ink_compile(
  14. ctx,
  15. "macro hundreds do tens tens tens tens tens tens tens tens tens tens + + + + + + + + + end"
  16. );
  17. ink_compile(
  18. ctx,
  19. "macro thousand do hundreds hundreds hundreds hundreds hundreds hundreds hundreds hundreds hundreds hundreds + + + + + + + + + end"
  20. );
  21. int coro = ink_compile(
  22. ctx,
  23. "thousand thousand * thousand / thousand thousand * thousand / thousand / * print_int"
  24. );
  25. ctx->routines[coro].panic = 0;
  26. int increment = 1 << 16;
  27. int counter = increment;
  28. int c;
  29. while(ink_can_run(ctx)) {
  30. for(c = 0; c < 16; ++c)
  31. ink_step_everyone(ctx);
  32. if(ctx->steps < counter) {
  33. ink_gc(ctx);
  34. counter += increment;
  35. }
  36. }
  37. return (ctx->routines[coro].panic != INK_ROUTINE_SUCCESS && ctx->routines[coro].panic != INK_ROUTINE_CAN_REUSE) || ctx->steps > 1000;
  38. }