<commit_before>#ifndef LILY_H
# define LILY_H

# include <stdarg.h>
# include <stdint.h>
# include <stdio.h>

/* API documentation is processed with NaturalDocs. */

// Title: API Reference - Lily

//////////////////////////
// Section: Basic typedefs
//////////////////////////

// Typedef: lily_bytestring_val
// Holds a ByteString value.
typedef struct lily_bytestring_val_ lily_bytestring_val;

// Typedef: lily_container_val
// Holds a variant, user-defined class, List, or Tuple.
typedef struct lily_container_val_  lily_container_val;

// Typedef: lily_file_val
// Holds a File value.
typedef struct lily_file_val_       lily_file_val;

// Typedef: lily_foreign_val
// Holds a foreign class.
typedef struct lily_foreign_val_    lily_foreign_val;

// Typedef: lily_function_val
// Holds a Function (could be native or foreign).
typedef struct lily_function_val_   lily_function_val;

// Typedef: lily_generic_val
// Holds some kind of pointer value (usually, to be cast to a foreign class).
typedef struct lily_generic_val_    lily_generic_val;

// Typedef: lily_hash_val
// Holds a Hash value.
typedef struct lily_hash_val_       lily_hash_val;

// Typedef: lily_string_val
// Holds a String value.
typedef struct lily_string_val_     lily_string_val;

// Typedef: lily_value
// A complete value with class and flag information.
typedef struct lily_value_          lily_value;

typedef struct lily_vm_state_       lily_state;

typedef void (*lily_destroy_func)(lily_generic_val *);

typedef void (*lily_import_func)(lily_state *s, const char *target);

typedef void (*lily_render_func)(const char *content, void *data);

typedef void (*lily_call_entry_func)(lily_state *);

/////////////////////////
// Section: Configuration
/////////////////////////
// The configuration struct and related functions.

// Struct: lily_config
// All interpreter config info goes here.
//
// Every interpreter requires a configuration struct to initialize it. The
// config struct is a struct with members publically exposed. This allows
// embedders to grab fields they want instead of going through the hoops of
// simple get/set functions for an opaque struct.
//
// Interpreters do not free the config when they are done, nor do they free any
// fields in the config. It is the caller's responsibility to clean up the
// config when the interpreter is done.
//
// Because of that, callers are permitted to use the same configuration to
// initialize multiple interpreters.
//
// Callers must not modify configuration members once an interpreter has been
// created that uses them.
//
// Fields:
//     argc          - (Default: 0)
//                     Number of values in argv.
//
//     argv          - (Default: NULL)
//                     The argument list (later used by Lily's sys.argv).
//
//     data          - (Default: stdin)
//                     This will later be sent as the data part of the
//                     import_func hook.
//
//     gc_multiplier - (Default: 4)
//                     If a gc sweep fails, how much should the count of allowed
//                     values be multiplied by?
//
//     gc_start      - (Default: 100)
//                     How many values should be allowed to exist at once before
//                     a gc pass.
//
//     import_func   - (Default: lily_default_import_func)
//                     What function should be called to handle imports?
//
//     render_func   - (Default: fputs)
//                     What function should be called if there is template
//                     content to be rendered?
//
//     sipkey        - (Default: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
//                     The sipkey is an array of 16 char values that helps to
//                     prevent collisions in Lily's Hash class.
//
//     extra_info    - (Default: 0)
//                     By default, the interpreter does not save parameter names
//                     or docblocks for introspection. If this is 1 when
//                     starting a parse, the information is saved and evailable.
typedef struct lily_config_ {
    int argc;
    char **argv;
    int gc_start;
    int gc_multiplier;
    lily_render_func render_func;
    lily_import_func import_func;
    char sipkey[16];
    void *data;
    int extra_info;
} lily_config;

// Function: lily_config_init
// Initialize a config to default values.
//
// This function assumes that the caller has a config struct on the stack. The
// caller can pass the address of that struct to this function, and the default
// values will be set.
void lily_config_init(lily_config *config);

// Function: lily_config_get
// Fetch an interpreter's config struct.
lily_config *lily_config_get(lily_state *s);
<commit_msg>Fix typo in last commit. Whoops.<commit_after>#ifndef LILY_H
# define LILY_H

# include <stdarg.h>
# include <stdint.h>
# include <stdio.h>

/* API documentation is processed with NaturalDocs. */

// Title: API Reference - Lily

//////////////////////////
// Section: Basic typedefs
//////////////////////////

// Typedef: lily_bytestring_val
// Holds a ByteString value.
typedef struct lily_bytestring_val_ lily_bytestring_val;

// Typedef: lily_container_val
// Holds a variant, user-defined class, List, or Tuple.
typedef struct lily_container_val_  lily_container_val;

// Typedef: lily_file_val
// Holds a File value.
typedef struct lily_file_val_       lily_file_val;

// Typedef: lily_foreign_val
// Holds a foreign class.
typedef struct lily_foreign_val_    lily_foreign_val;

// Typedef: lily_function_val
// Holds a Function (could be native or foreign).
typedef struct lily_function_val_   lily_function_val;

// Typedef: lily_generic_val
// Holds some kind of pointer value (usually, to be cast to a foreign class).
typedef struct lily_generic_val_    lily_generic_val;

// Typedef: lily_hash_val
// Holds a Hash value.
typedef struct lily_hash_val_       lily_hash_val;

// Typedef: lily_string_val
// Holds a String value.
typedef struct lily_string_val_     lily_string_val;

// Typedef: lily_value
// A complete value with class and flag information.
typedef struct lily_value_          lily_value;

typedef struct lily_vm_state_       lily_state;

typedef void (*lily_destroy_func)(lily_generic_val *);

typedef void (*lily_import_func)(lily_state *s, const char *target);

typedef void (*lily_render_func)(const char *content, void *data);

typedef void (*lily_call_entry_func)(lily_state *);

/////////////////////////
// Section: Configuration
/////////////////////////
// The configuration struct and related functions.

// Struct: lily_config
// All interpreter config info goes here.
//
// Every interpreter requires a configuration struct to initialize it. The
// config struct is a struct with members publically exposed. This allows
// embedders to grab fields they want instead of going through the hoops of
// simple get/set functions for an opaque struct.
//
// Interpreters do not free the config when they are done, nor do they free any
// fields in the config. It is the caller's responsibility to clean up the
// config when the interpreter is done.
//
// Because of that, callers are permitted to use the same configuration to
// initialize multiple interpreters.
//
// Callers must not modify configuration members once an interpreter has been
// created that uses them.
//
// Fields:
//     argc          - (Default: 0)
//                     Number of values in argv.
//
//     argv          - (Default: NULL)
//                     The argument list (later used by Lily's sys.argv).
//
//     data          - (Default: stdin)
//                     This will later be sent as the data part of the
//                     import_func hook.
//
//     gc_multiplier - (Default: 4)
//                     If a gc sweep fails, how much should the count of allowed
//                     values be multiplied by?
//
//     gc_start      - (Default: 100)
//                     How many values should be allowed to exist at once before
//                     a gc pass.
//
//     import_func   - (Default: lily_default_import_func)
//                     What function should be called to handle imports?
//
//     render_func   - (Default: fputs)
//                     What function should be called if there is template
//                     content to be rendered?
//
//     sipkey        - (Default: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
//                     The sipkey is an array of 16 char values that helps to
//                     prevent collisions in Lily's Hash class.
//
//     extra_info    - (Default: 0)
//                     By default, the interpreter does not save parameter names
//                     or docblocks for introspection. If this is 1 when
//                     starting a parse, the information is saved and available.
typedef struct lily_config_ {
    int argc;
    char **argv;
    int gc_start;
    int gc_multiplier;
    lily_render_func render_func;
    lily_import_func import_func;
    char sipkey[16];
    void *data;
    int extra_info;
} lily_config;

// Function: lily_config_init
// Initialize a config to default values.
//
// This function assumes that the caller has a config struct on the stack. The
// caller can pass the address of that struct to this function, and the default
// values will be set.
void lily_config_init(lily_config *config);

// Function: lily_config_get
// Fetch an interpreter's config struct.
lily_config *lily_config_get(lily_state *s);

{'fraction_non_alphanumeric': 0.1014019184146727, 'fraction_numerical': 0.007167703172762728, 'mean_word_length': 2.319804058782365, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '7501320', 'n_tokens_mistral': 2858, 'n_tokens_neox': 2667, 'n_words': 1015}