A minimalistic programming language written in C89.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

68 lignes
1.4 KiB

il y a 6 mois
il y a 6 mois
il y a 6 mois
il y a 6 mois
  1. #pragma once
  2. #include "stddef.h"
  3. #define INK_INTEGER 0
  4. #define INK_NATIVE_FUNCTION 1
  5. #define INK_FUNCTION 2
  6. struct elem {
  7. int type;
  8. int value;
  9. };
  10. struct stack_frame {
  11. struct elem executing;
  12. int index;
  13. };
  14. struct fn {
  15. char* name;
  16. struct elem* things;
  17. int size;
  18. };
  19. struct context;
  20. struct native_fn {
  21. char* name;
  22. void(*value)(struct context*);
  23. };
  24. struct context {
  25. int panic;
  26. void*(*malloc)(size_t);
  27. void*(*realloc)(void*, size_t);
  28. void(*free)(void*);
  29. int(*putchar)(int);
  30. struct elem* stack;
  31. int capacity;
  32. int top;
  33. struct stack_frame* function_stack;
  34. int function_stack_capacity;
  35. int function_stack_top;
  36. struct native_fn* native_words;
  37. int native_words_capacity;
  38. int native_words_top;
  39. struct fn* words;
  40. int words_capacity;
  41. int words_top;
  42. char** lex_reserved_words;
  43. int lex_reserved_words_capacity;
  44. int lex_reserved_words_top;
  45. };
  46. int ink_add_native(struct context* ctx, const char* name, void(*value)(struct context*));
  47. int ink_push(struct context* ctx, struct elem value);
  48. int ink_push_fn(struct context* ctx, struct stack_frame value);
  49. struct context* ink_make_context(void*(*malloc)(size_t), void*(*realloc)(void*, size_t), void(*free)(void*), int(*putchar)(int));
  50. #ifndef NOSTDLIB
  51. struct context* ink_make_default_context();
  52. #endif
  53. int ink_step(struct context *pContext);
  54. void ink_run(struct context *pContext, char* buffer);
  55. int ink_std_library(struct context* ctx);