<commit_before>#ifndef PLOT_VALUE_H
#define PLOT_VALUE_H

#include <stdbool.h>

typedef enum plot_value_type{
    plot_type_number,
    plot_type_symbol,
    /* a function written in plot */
    plot_type_lambda,
    /* a function written in c
     * NB: legacy refers to using the old argument interface of
     * struct plot_value * (*func)(struct plot_env *env, struct plot_value **args, int argc);
     */
    plot_type_legacy,
    /* a syntactic form written in c */
    plot_type_form,
    plot_type_error,
    plot_type_string,
    plot_type_boolean,
    plot_type_character,
    plot_type_pair,
    plot_type_promise,
    /* null does NOT have a matching union member */
    plot_type_null,
    /* this type represents expressions that do not yield a value
     * '(if #f "hello")' => unspecified
     * '(define a "world")' => unspecified
     *
     * this type does NOT have a matching
     * union member
     */
    plot_type_unspecified,
    plot_type_reclaimed /* FIXME useful for testing garbage collection */
#if 0
    plot_type_vector
    plot_type_port
#endif
} plot_value_type;

typedef enum plot_error_type{
    /* allocation failed */
    plot_error_alloc_failed,
    /* arguments provided were incorrect */
    plot_error_bad_args,
    /* unknown internal error, in theory an impossible state */
    plot_error_internal,
    /* unbound symbol encountered */
    plot_error_unbound_symbol,
    /* runtime error in source program */
    plot_error_runtime,

    /* function not implemented yet */
    plot_error_unimplemented,
    /* symbol failed to resolved */
    plot_error_undefined
} plot_error_type;

typedef struct plot_error {
    plot_error_type type;
    const char *msg;
    const char *location;
} plot_error;

typedef struct plot_character {
    char val;
} plot_character;

typedef struct plot_number {
    int val;
} plot_number;

typedef struct plot_symbol {
    const char *val;
    /* len is number of characters used
     * including \0 terminator
     */
    int len;
    /* size is number of characters allocated */
    int size;
    /* hash for this symbol's value, 0 means unhashed */
    unsigned long long hash;
} plot_symbol;

typedef struct plot_string {
    char *val;
    /* len is number of characters used
     * including \0 terminator
     */
    int len;
    /* size is number of characters allocated */
    int size;
} plot_string;

typedef struct plot_boolean {
    bool val;
} plot_boolean;

typedef struct plot_pair {
    struct plot_value *car;
    struct plot_value *cdr;
} plot_pair;

/* FIXME may want to move to functions that check types
 */
#define car(v) ((v)->u.pair.car)
#define cdr(v) ((v)->u.pair.cdr)

#if 0

typedef struct plot_vector {
} plot_vector;

typedef struct plot_port {
} plot_port;

#endif

struct plot_expr;
struct plot_sexpr;
struct plot_env;

typedef struct plot_lambda {
    struct plot_env *env;
    struct plot_value *body;
} plot_lambda;

/* a function written in c
 * NB: legacy refers to using the old argument interface of
 * struct plot_value * (*func)(struct plot_env *env, struct plot_value **args, int argc);
 */
typedef struct plot_legacy {
    /* env to evaluate within
     * args is an array of plot_value *(s) to apply function to<commit_msg>Adding cons and null defines to value<commit_after>#ifndef PLOT_VALUE_H
#define PLOT_VALUE_H

#include <stdbool.h>

typedef enum plot_value_type{
    plot_type_number,
    plot_type_symbol,
    /* a function written in plot */
    plot_type_lambda,
    /* a function written in c
     * NB: legacy refers to using the old argument interface of
     * struct plot_value * (*func)(struct plot_env *env, struct plot_value **args, int argc);
     */
    plot_type_legacy,
    /* a syntactic form written in c */
    plot_type_form,
    plot_type_error,
    plot_type_string,
    plot_type_boolean,
    plot_type_character,
    plot_type_pair,
    plot_type_promise,
    /* null does NOT have a matching union member */
    plot_type_null,
    /* this type represents expressions that do not yield a value
     * '(if #f "hello")' => unspecified
     * '(define a "world")' => unspecified
     *
     * this type does NOT have a matching
     * union member
     */
    plot_type_unspecified,
    plot_type_reclaimed /* FIXME useful for testing garbage collection */
#if 0
    plot_type_vector
    plot_type_port
#endif
} plot_value_type;

typedef enum plot_error_type{
    /* allocation failed */
    plot_error_alloc_failed,
    /* arguments provided were incorrect */
    plot_error_bad_args,
    /* unknown internal error, in theory an impossible state */
    plot_error_internal,
    /* unbound symbol encountered */
    plot_error_unbound_symbol,
    /* runtime error in source program */
    plot_error_runtime,

    /* function not implemented yet */
    plot_error_unimplemented,
    /* symbol failed to resolved */
    plot_error_undefined
} plot_error_type;

typedef struct plot_error {
    plot_error_type type;
    const char *msg;
    const char *location;
} plot_error;

typedef struct plot_character {
    char val;
} plot_character;

typedef struct plot_number {
    int val;
} plot_number;

typedef struct plot_symbol {
    const char *val;
    /* len is number of characters used
     * including \0 terminator
     */
    int len;
    /* size is number of characters allocated */
    int size;
    /* hash for this symbol's value, 0 means unhashed */
    unsigned long long hash;
} plot_symbol;

typedef struct plot_string {
    char *val;
    /* len is number of characters used
     * including \0 terminator
     */
    int len;
    /* size is number of characters allocated */
    int size;
} plot_string;

typedef struct plot_boolean {
    bool val;
} plot_boolean;

typedef struct plot_pair {
    struct plot_value *car;
    struct plot_value *cdr;
} plot_pair;

/* FIXME may want to move to functions that check types
 */
#define cons(l,r) (plot_new_pair(l,r))
#define car(v) ((v)->u.pair.car)
#define cdr(v) ((v)->u.pair.cdr)
#define null (plot_new_null())

#if 0

typedef struct plot_vector {
} plot_vector;

typedef struct plot_port {
} plot_port;

#endif

struct plot_expr;
struct plot_sexpr;
struct plot_env;

typedef struct plot_lambda {
    struct plot_env *env;
    struct plot_value *body;
} plot_lambda;

/* a function written in c
 * NB: legacy refers to using the old argument interface of
 * struct plot_value * (*func)(struct plot_env *env, struct plot_value **args, int argc);
 */
typedef struct plot_legacy {
    /* env to evaluate within
     * args is an array of plot_value *(s) to apply function to
{'fraction_non_alphanumeric': 0.0822957789249924, 'fraction_numerical': 0.0015183723048891589, 'mean_word_length': 3.1349654739485247, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5341040', 'n_tokens_mistral': 2071, 'n_tokens_neox': 1995, 'n_words': 683}