#ifndef TB_INTERP_H_
#define TB_INTERP_H_

#include <stddef.h>
#include <stdbool.h>
#include "runtime.h"

#define INTERP_ERRMSG_BUF_MAX (2048)

typedef struct {
  char errmsg[INTERP_ERRMSG_BUF_MAX];
} InterpResult;

extern InterpResult RES;

typedef struct Token {
  struct Token *next;
  char *str;

  enum {
    TOK_STRING,
    TOK_CMD,
    TOK_MISC,
  } type;

  bool (*cmd)(struct Token *);
} Token;

typedef struct {
  char *str;
  Token *tokens;
} Tokenizer;

bool interp_runstring(char *string, InterpResult **res, bool interactive);

#endif // TB_INTERP_H_
