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.

66 lignes
1.4 KiB

#pragma once
#include "stddef.h"
#define INK_INTEGER 0
#define INK_NATIVE_FUNCTION 1
#define INK_FUNCTION 2
struct elem {
int type;
int value;
};
struct stack_frame {
struct elem executing;
int index;
};
struct fn {
char* name;
struct elem* things;
int size;
};
struct context;
struct native_fn {
char* name;
void(*value)(struct context*);
};
struct context {
int panic;
void*(*malloc)(size_t);
void*(*realloc)(void*, size_t);
void(*free)(void*);
int(*putchar)(int);
struct elem* stack;
int capacity;
int top;
struct stack_frame* function_stack;
int function_stack_capacity;
int function_stack_top;
struct native_fn* native_words;
int native_words_capacity;
int native_words_top;
struct fn* words;
int words_capacity;
int words_top;
char** lex_reserved_words;
int lex_reserved_words_capacity;
int lex_reserved_words_top;
};
void ink_add_native(struct context* ctx, const char* name, void(*value)(struct context*));
void ink_push(struct context* ctx, struct elem value);
void ink_push_fn(struct context* ctx, struct stack_frame value);
struct context* ink_make_context(void*(*malloc)(size_t), void*(*realloc)(void*, size_t), void(*free)(void*), int(*putchar)(int));
struct context* ink_make_default_context();
int ink_step(struct context *pContext);
void ink_run(struct context *pContext, char* buffer);
void ink_std_library(struct context* ctx);