diff --git a/README.md b/README.md index 98529e9..ce06901 100644 --- a/README.md +++ b/README.md @@ -89,14 +89,14 @@ See [./lib/](https://git.xw3.org/fun/fun/src/branch/main/lib) for what the stand ### Optional extensions (build-time selectable / only testing this on Linux actually): - [CGI](https://en.wikipedia.org/wiki/Common_Gateway_Interface) support builtin using [kcgi](https://kristaps.bsd.lv/kcgi/) (optional) ☐ -- [cURL (libcurl)](./docs/external/curl.md) (optional) ☑ -- [INI (iniparser)](./docs/external/ini.md) (optional) ☑ -- [JSON (json-c)](./docs/external/json.md) (optional) ☑ -- [PCRE2](./docs/external/pcre2.md) (optional) ☑ -- [PCSC (smart cards)](./docs/external/pcsc.md) (optional) ☑ -- [OpenSSL](./docs/external/openssl.md) (optional) ☑ -- [SQLite](./docs/external/sqlite.md) (optional) ☑ -- [XML (libxml2)](./docs/external/xml2.md) (optional) ☑ +- [cURL (libcurl)](./docs/extensions/curl.md) (optional) ☑ +- [INI (iniparser)](./docs/extensions/ini.md) (optional) ☑ +- [JSON (json-c)](./docs/extensions/json.md) (optional) ☑ +- [PCRE2](./docs/extensions/pcre2.md) (optional) ☑ +- [PCSC (smart cards)](./docs/extensions/pcsc.md) (optional) ☑ +- [OpenSSL](./docs/extensions/openssl.md) (optional) ☑ +- [SQLite](./docs/extensions/sqlite.md) (optional) ☑ +- [XML (libxml2)](./docs/extensions/xml2.md) (optional) ☑ ☑ = Done / ☐ = Planned or in progress. @@ -106,7 +106,7 @@ There are some libs written in Fun available in the [./lib/](https://git.xw3.org ### OpenSSL quickstart (MD5) -See the dedicated page: ./docs/external/openssl.md +See the dedicated page: ./docs/extensions/openssl.md ## Documentation diff --git a/examples/io/word_count.fun b/examples/io/word_count.fun index 3445239..98db03d 100755 --- a/examples/io/word_count.fun +++ b/examples/io/word_count.fun @@ -307,21 +307,21 @@ using: 1 (optional): 11 ☐: 2 [curl: 1 -(libcurl)](./docs/external/curl.md): 1 +(libcurl)](./docs/extensions/curl.md): 1 ☑: 11 [ini: 1 -(iniparser)](./docs/external/ini.md): 1 +(iniparser)](./docs/extensions/ini.md): 1 [json: 1 -(json-c)](./docs/external/json.md): 1 -[libsql](./docs/external/libsql.md): 1 -[pcre2](./docs/external/pcre2.md): 1 +(json-c)](./docs/extensions/json.md): 1 +[libsql](./docs/extensions/libsql.md): 1 +[pcre2](./docs/extensions/pcre2.md): 1 [pcsc: 1 (smart: 1 -cards)](./docs/external/pcsc.md): 1 -[openssl](./docs/external/openssl.md): 1 -[sqlite](./docs/external/sqlite.md): 1 +cards)](./docs/extensions/pcsc.md): 1 +[openssl](./docs/extensions/openssl.md): 1 +[sqlite](./docs/extensions/sqlite.md): 1 [xml: 1 -(libxml2)](./docs/external/xml2.md): 1 +(libxml2)](./docs/extensions/xml2.md): 1 =: 2 done: 1 planned: 1 @@ -351,7 +351,7 @@ quickstart: 1 (md5): 1 dedicated: 1 page:: 1 -./docs/external/openssl.md: 1 +./docs/extensions/openssl.md: 1 documentation: 2 looking: 1 docs?: 1 diff --git a/src/external/curl.c b/src/extensions/curl.c similarity index 100% rename from src/external/curl.c rename to src/extensions/curl.c diff --git a/src/external/ini.c b/src/extensions/ini.c similarity index 100% rename from src/external/ini.c rename to src/extensions/ini.c diff --git a/src/external/json.c b/src/extensions/json.c similarity index 100% rename from src/external/json.c rename to src/extensions/json.c diff --git a/src/external/openssl.c b/src/extensions/openssl.c similarity index 100% rename from src/external/openssl.c rename to src/extensions/openssl.c diff --git a/src/external/pcre2.c b/src/extensions/pcre2.c similarity index 100% rename from src/external/pcre2.c rename to src/extensions/pcre2.c diff --git a/src/external/pcsc.c b/src/extensions/pcsc.c similarity index 100% rename from src/external/pcsc.c rename to src/extensions/pcsc.c diff --git a/src/external/sqlite.c b/src/extensions/sqlite.c similarity index 100% rename from src/external/sqlite.c rename to src/extensions/sqlite.c diff --git a/src/external/xml2.c b/src/extensions/xml2.c similarity index 100% rename from src/external/xml2.c rename to src/extensions/xml2.c diff --git a/src/external/libressl.c b/src/external/libressl.c deleted file mode 100644 index 2764157..0000000 --- a/src/external/libressl.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * This file is part of the Fun programming language. - * https://fun-lang.xyz/ - * - * Copyright 2026 Johannes Findeisen - * Licensed under the terms of the Apache-2.0 license. - * https://opensource.org/license/apache-2-0 - * - * Added: 2026-02-19 - */ - -/* - * LibreSSL integration helpers (MD5, RIPEMD-160, SHA-256, SHA-512) - */ - -#ifdef FUN_WITH_LIBRESSL -/* - * When building with LibreSSL, include the LibreSSL-provided headers explicitly. - * Downstream distros often ship them under /usr/include/libressl/openssl/… - * and expect the include path to point at /usr/include/libressl so that any - * nested `#include ` inside these headers resolves to the - * corresponding LibreSSL headers as well (not the system OpenSSL 3.x ones). - */ -#include -/* Compatibility: Prefer EVP_MD_get_size universally. If LibreSSL headers - * don't declare it, provide a forward declaration so we can link against - * OpenSSL's libcrypto symbol when that is what CMake found. */ -#ifndef EVP_MD_get_size -int EVP_MD_get_size(const EVP_MD *md); -#endif -#endif -#include - -/* Compute MD5 hex of input buffer; returns malloc'ed C string (lowercase hex). */ -static char *fun_libressl_md5_hex(const unsigned char *data, size_t len) { - static const char hexdig[] = "0123456789abcdef"; - if (!data && len != 0) return NULL; -#ifdef FUN_WITH_LIBRESSL - const EVP_MD *md = EVP_md5(); - if (!md) return NULL; - int dlen = EVP_MD_get_size(md); - if (dlen <= 0) return NULL; - unsigned char *digest = (unsigned char *)malloc((size_t)dlen); - if (!digest) return NULL; - unsigned int out_len = 0; - int ok; - if (len == 0) { - ok = EVP_Digest(NULL, 0, digest, &out_len, md, NULL); - } else { - ok = EVP_Digest(data, len, digest, &out_len, md, NULL); - } - if (ok != 1 || (int)out_len != dlen) { - free(digest); - return NULL; - } - char *hex = (char *)malloc((size_t)dlen * 2 + 1); - if (!hex) { - free(digest); - return NULL; - } - for (int i = 0; i < dlen; ++i) { - hex[2 * i] = hexdig[(digest[i] >> 4) & 0xF]; - hex[2 * i + 1] = hexdig[digest[i] & 0xF]; - } - hex[dlen * 2] = '\0'; - free(digest); - return hex; -#else - char *hex = (char *)malloc(1); - if (hex) hex[0] = '\0'; - return hex; -#endif -} - -/* Compute SHA-256 hex of input buffer; returns malloc'ed C string (lowercase hex). */ -static char *fun_libressl_sha256_hex(const unsigned char *data, size_t len) { - static const char hexdig[] = "0123456789abcdef"; - if (!data && len != 0) return NULL; -#ifdef FUN_WITH_LIBRESSL - const EVP_MD *md = EVP_sha256(); - if (!md) return NULL; - int dlen = EVP_MD_get_size(md); - if (dlen <= 0) return NULL; - unsigned char *digest = (unsigned char *)malloc((size_t)dlen); - if (!digest) return NULL; - unsigned int out_len = 0; - int ok; - if (len == 0) { - ok = EVP_Digest(NULL, 0, digest, &out_len, md, NULL); - } else { - ok = EVP_Digest(data, len, digest, &out_len, md, NULL); - } - if (ok != 1 || (int)out_len != dlen) { - free(digest); - return NULL; - } - char *hex = (char *)malloc((size_t)dlen * 2 + 1); - if (!hex) { - free(digest); - return NULL; - } - for (int i = 0; i < dlen; ++i) { - hex[2 * i] = hexdig[(digest[i] >> 4) & 0xF]; - hex[2 * i + 1] = hexdig[digest[i] & 0xF]; - } - hex[dlen * 2] = '\0'; - free(digest); - return hex; -#else - char *hex = (char *)malloc(1); - if (hex) hex[0] = '\0'; - return hex; -#endif -} - -/* Compute SHA-512 hex of input buffer; returns malloc'ed C string (lowercase hex). */ -static char *fun_libressl_sha512_hex(const unsigned char *data, size_t len) { - static const char hexdig[] = "0123456789abcdef"; - if (!data && len != 0) return NULL; -#ifdef FUN_WITH_LIBRESSL - const EVP_MD *md = EVP_sha512(); - if (!md) return NULL; - int dlen = EVP_MD_get_size(md); - if (dlen <= 0) return NULL; - unsigned char *digest = (unsigned char *)malloc((size_t)dlen); - if (!digest) return NULL; - unsigned int out_len = 0; - int ok; - if (len == 0) { - ok = EVP_Digest(NULL, 0, digest, &out_len, md, NULL); - } else { - ok = EVP_Digest(data, len, digest, &out_len, md, NULL); - } - if (ok != 1 || (int)out_len != dlen) { - free(digest); - return NULL; - } - char *hex = (char *)malloc((size_t)dlen * 2 + 1); - if (!hex) { - free(digest); - return NULL; - } - for (int i = 0; i < dlen; ++i) { - hex[2 * i] = hexdig[(digest[i] >> 4) & 0xF]; - hex[2 * i + 1] = hexdig[digest[i] & 0xF]; - } - hex[dlen * 2] = '\0'; - free(digest); - return hex; -#else - char *hex = (char *)malloc(1); - if (hex) hex[0] = '\0'; - return hex; -#endif -} - -/* Compute RIPEMD-160 hex of input buffer; returns malloc'ed C string (lowercase hex). */ -static char *fun_libressl_ripemd160_hex(const unsigned char *data, size_t len) { - static const char hexdig[] = "0123456789abcdef"; - if (!data && len != 0) return NULL; -#ifdef FUN_WITH_LIBRESSL - const EVP_MD *md = EVP_ripemd160(); - if (!md) return NULL; - int dlen = EVP_MD_get_size(md); - if (dlen <= 0) return NULL; - unsigned char *digest = (unsigned char *)malloc((size_t)dlen); - if (!digest) return NULL; - unsigned int out_len = 0; - int ok; - if (len == 0) { - ok = EVP_Digest(NULL, 0, digest, &out_len, md, NULL); - } else { - ok = EVP_Digest(data, len, digest, &out_len, md, NULL); - } - if (ok != 1 || (int)out_len != dlen) { - free(digest); - return NULL; - } - char *hex = (char *)malloc((size_t)dlen * 2 + 1); - if (!hex) { - free(digest); - return NULL; - } - for (int i = 0; i < dlen; ++i) { - hex[2 * i] = hexdig[(digest[i] >> 4) & 0xF]; - hex[2 * i + 1] = hexdig[digest[i] & 0xF]; - } - hex[dlen * 2] = '\0'; - free(digest); - return hex; -#else - char *hex = (char *)malloc(1); - if (hex) hex[0] = '\0'; - return hex; -#endif -} diff --git a/src/external/libsql.c b/src/external/libsql.c deleted file mode 100644 index e133d7d..0000000 --- a/src/external/libsql.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of the Fun programming language. - * https://fun-lang.xyz/ - * - * Copyright 2025 Johannes Findeisen - * Licensed under the terms of the Apache-2.0 license. - * https://opensource.org/license/apache-2-0 - * - * Added: 2025-11-26 (2025-12-11 migrated from src/vm/libsql/common.c) - */ - -#ifdef FUN_WITH_LIBSQL -#include /* libsql provides a sqlite3-compatible C API */ -#include -#include -#include - -typedef struct LibSqlHandle { - int id; - sqlite3 *db; - struct LibSqlHandle *next; -} LibSqlHandle; - -static LibSqlHandle *g_libsql_handles = NULL; -static int g_libsql_next_id = 1; - -static LibSqlHandle *libsql_reg_add(sqlite3 *db) { - LibSqlHandle *h = (LibSqlHandle *)malloc(sizeof(LibSqlHandle)); - if (!h) return NULL; - h->id = g_libsql_next_id++; - h->db = db; - h->next = g_libsql_handles; - g_libsql_handles = h; - return h; -} - -static LibSqlHandle *libsql_reg_get(int id) { - LibSqlHandle *p = g_libsql_handles; - while (p) { - if (p->id == id) return p; - p = p->next; - } - return NULL; -} - -static void libsql_reg_del(int id) { - LibSqlHandle **pp = &g_libsql_handles; - while (*pp) { - if ((*pp)->id == id) { - LibSqlHandle *dead = *pp; - *pp = (*pp)->next; - free(dead); - return; - } - pp = &((*pp)->next); - } -} -#endif diff --git a/src/external/tcltk.c b/src/external/tcltk.c deleted file mode 100644 index 78e48a6..0000000 --- a/src/external/tcltk.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file is part of the Fun programming language. - * https://fun-lang.xyz/ - * - * Copyright 2025 Johannes Findeisen - * Licensed under the terms of the Apache-2.0 license. - * https://opensource.org/license/apache-2-0 - * - * Added: 2025-12-11 (2025-12-11 migrated from src/vm.c) - */ - -#ifdef FUN_WITH_TCLTK -#include -#include -static Tcl_Interp *g_fun_tcl_interp = NULL; - -static void fun_tk_init_once(void) { - if (g_fun_tcl_interp) return; - Tcl_FindExecutable(NULL); - g_fun_tcl_interp = Tcl_CreateInterp(); - if (!g_fun_tcl_interp) return; - if (Tcl_Init(g_fun_tcl_interp) != TCL_OK) { - fprintf(stderr, "Tcl_Init failed: %s\n", Tcl_GetStringResult(g_fun_tcl_interp)); - } - if (Tk_Init(g_fun_tcl_interp) != TCL_OK) { - fprintf(stderr, "Tk_Init failed: %s\n", Tcl_GetStringResult(g_fun_tcl_interp)); - } - /* Ensure the app terminates if the main window is closed via window manager */ - /* Best-effort: set WM_DELETE_WINDOW handler to exit the process. */ - Tcl_Eval(g_fun_tcl_interp, "wm protocol . WM_DELETE_WINDOW {exit 0}"); -} - -static int fun_tk_eval_script(const char *script) { - fun_tk_init_once(); - if (!g_fun_tcl_interp) return -1; - int rc = Tcl_Eval(g_fun_tcl_interp, script ? script : ""); - return rc; /* TCL_OK = 0 */ -} - -static const char *fun_tk_get_result(void) { - fun_tk_init_once(); - if (!g_fun_tcl_interp) return ""; - return Tcl_GetStringResult(g_fun_tcl_interp); -} - -static void fun_tk_loop(void) { - fun_tk_init_once(); - if (!g_fun_tcl_interp) return; - /* Drive Tk event loop until all main windows are closed */ - while (Tk_GetNumMainWindows() > 0) { - while (Tcl_DoOneEvent(0)) { - } - /* tiny sleep to avoid busy spin */ -#ifdef _WIN32 -#include - Sleep(1); -#else -#include - struct timespec ts = {0, 1000000}; /* 1 ms */ - nanosleep(&ts, NULL); -#endif - } -} -#else -/* Stubs when Tcl/Tk is disabled */ -static void fun_tk_init_once(void) { - (void)0; -} -static int fun_tk_eval_script(const char *script) { - (void)script; - return -1; -} -static const char *fun_tk_get_result(void) { - return ""; -} -static void fun_tk_loop(void) { - (void)0; -} -#endif diff --git a/src/vm.c b/src/vm.c index de841e0..bb69443 100644 --- a/src/vm.c +++ b/src/vm.c @@ -56,20 +56,20 @@ /* Notcurses support removed */ // Optional by extensions commonly used code. #ifdef's are in each single file. -#include "external/curl.c" -#include "external/ini.c" +#include "extensions/curl.c" +#include "extensions/ini.c" #ifdef FUN_WITH_INI /* Central INI handle registry and helpers */ #include "vm/ini/handles.c" #endif /* Note: INI opcode handlers are included below; changes in vm/ini/ .c files * require vm.c to rebuild. */ -#include "external/json.c" -#include "external/openssl.c" -#include "external/pcre2.c" -#include "external/pcsc.c" -#include "external/sqlite.c" -#include "external/xml2.c" +#include "extensions/json.c" +#include "extensions/openssl.c" +#include "extensions/pcre2.c" +#include "extensions/pcsc.c" +#include "extensions/sqlite.c" +#include "extensions/xml2.c" /* forward declarations for include mapping used in error reporting */ extern char *preprocess_includes(const char *src); diff --git a/web/documentation/documentation.md b/web/documentation/documentation.md index d7638e7..6bc6246 100644 --- a/web/documentation/documentation.md +++ b/web/documentation/documentation.md @@ -19,8 +19,8 @@ This file serves as an index of the documents in this directory. Links are relat ## Basics -- [./handbook/](./handbook/) - Comprehensive handbook for the Fun language and VM: install/build, configuration flags, usage, and full feature overview. -- [./repl/](./repl/) - REPL user guide: how to build/launch, editing and history, completions, REPL-on-error, and tips. +- [Handbook](./handbook/) - Comprehensive handbook for the Fun language and VM: install/build, configuration flags, usage, and full feature overview. +- [REPL](./repl/) - REPL user guide: how to build/launch, editing and history, completions, REPL-on-error, and tips. - [Specification v0.4](https://git.xw3.org/fun/fun/src/branch/main/spec/v0.4/){:class="git"} - [Specification v0.3](https://git.xw3.org/fun/fun/src/branch/main/spec/v0.3/){:class="git"} - [Specification v0.2](https://git.xw3.org/fun/fun/src/branch/main/spec/v0.2/){:class="git"} @@ -32,50 +32,50 @@ The examples directory contains demonstrations of most Fun features, from basic ## Overview -- [./types/](./types/) - Core types (numbers, strings, arrays, maps, nil/bool), common operations, patterns, and interop notes. -- [./numbers/](./numbers/) - Working with integers and floats: arithmetic, conversions, clamping, bitwise ops, and patterns. -- [./strings/](./strings/) - Working with strings: literals/escaping, concatenation, substr/find, split, and conversions. -- [./arrays/](./arrays/) - Working with arrays: creation, indexing/slicing, iteration patterns, helpers, and idioms. -- [./maps/](./maps/) - Working with maps: construction, lookup/update, merging, iteration, and common patterns. -- [./includes/](./includes/) - Using local vs. system includes, FUN_LIB_DIR, DEFAULT_LIB_DIR, and namespaced includes with `as`. -- [./opcodes/](./opcodes/) - VM opcodes overview grouped by domain with brief behavior/stack notes. -- [./internals/](./internals/) - Implementation details: bytecode format, VM architecture, stacks/frames, parser, and dispatch. -- [./vm/](./vm/) - VM configuration constants: maximum stack depth, local/global variable limits, and output buffer size. -- [./rust/](./rust/) - Writing Rust-backed opcodes and wiring them into the C VM; build/setup notes. -- [./examples/](./examples/) - How to run the examples and the interactive showcase script, with environment tips. -- [./testing/](./testing/) - How to build and run tests/targets with CMake/CTest, and where to add new tests. -- [./troubleshooting/](./troubleshooting/) - Common issues and quick fixes for build, includes, and REPL usage. +- [Types](./types/) - Core types (numbers, strings, arrays, maps, nil/bool), common operations, patterns, and interop notes. +- [Numbers](./numbers/) - Working with integers and floats: arithmetic, conversions, clamping, bitwise ops, and patterns. +- [Strings](./strings/) - Working with strings: literals/escaping, concatenation, substr/find, split, and conversions. +- [Arrays](./arrays/) - Working with arrays: creation, indexing/slicing, iteration patterns, helpers, and idioms. +- [Mmaps](./maps/) - Working with maps: construction, lookup/update, merging, iteration, and common patterns. +- [Includes](./includes/) - Using local vs. system includes, FUN_LIB_DIR, DEFAULT_LIB_DIR, and namespaced includes with `as`. +- [Opcodes](./opcodes/) - VM opcodes overview grouped by domain with brief behavior/stack notes. +- [Internals](./internals/) - Implementation details: bytecode format, VM architecture, stacks/frames, parser, and dispatch. +- [VM](./vm/) - VM configuration constants: maximum stack depth, local/global variable limits, and output buffer size. +- [Rust](./rust/) - Writing Rust-backed opcodes and wiring them into the C VM; build/setup notes. +- [Examples](./examples/) - How to run the examples and the interactive showcase script, with environment tips. +- [Testing](./testing/) - How to build and run tests/targets with CMake/CTest, and where to add new tests. +- [Troubleshooting](./troubleshooting/) - Common issues and quick fixes for build, includes, and REPL usage. ## New and supplemental guides -- [./build/](./build/) - How to build Fun with CMake, available targets, and build options (FUN_DEBUG, FUN_USE_MUSL, FUN_WITH_CPP, FUN_WITH_RUST, FUN_WITH_OPENSSL). -- [./cli/](./cli/) - Command-line usage of the `fun` executable: synopsis, options, exit codes, includes and library paths. -- [./fun/](./fun/) - Full usage guide for the `fun` executable: invocation patterns, REPL, env vars, include paths, examples, and install locations. -- [./asyncio/](./asyncio/) - Async I/O primitives and patterns: non-blocking sockets, fd polling, examples, and best practices. -- [./funstx/](./funstx/) - Syntax checker for .fun files with optional --fix auto-corrections; usage, exit codes, and limitations. -- [./contributing/](./contributing/) - How to contribute: project structure, coding style, running tests, and PR guidelines. -- [./style-guide/](./style-guide/) - Coding conventions for C and Fun (indentation, naming, idioms). -- [./stdlib/](./stdlib/) - Overview of the standard library modules under ./lib with one-line summaries. -- [./embedding/](./embedding/) - Embedding the VM from C/Rust, lifecycle, and host integration tips. -- [./errors-and-diagnostics/](./errors-and-diagnostics/) - Understanding parser/runtime errors and enabling diagnostics. -- [./performance/](./performance/) - Build/runtime tuning tips and patterns for better performance. -- [./security-and-sandboxing/](./security-and-sandboxing/) - Trust boundaries, I/O expectations, and capability restrictions. -- [,/faq/](./faq/) - Frequently asked questions and quick answers. -- [./website/](./website/) - Documentation for the [fun-lang.xyz](https://fun-lang.xyz) website in the `./web/` directory. -- [./writing-tests/](./writing-tests/) - How to author new tests for Fun and opcode components. -- [./bytecode-format/](./bytecode-format/) - Reference for the bytecode format (split out from internals for convenience). -- [./roadmap/](./roadmap/) - High-level direction, planned features, and pointers to issues. +- [Build](./build/) - How to build Fun with CMake, available targets, and build options (FUN_DEBUG, FUN_USE_MUSL, FUN_WITH_CPP, FUN_WITH_RUST, FUN_WITH_OPENSSL). +- [CLI](./cli/) - Command-line usage of the `fun` executable: synopsis, options, exit codes, includes and library paths. +- [fun](./fun/) - Full usage guide for the `fun` executable: invocation patterns, REPL, env vars, include paths, examples, and install locations. +- [Asyncio](./asyncio/) - Async I/O primitives and patterns: non-blocking sockets, fd polling, examples, and best practices. +- [Funstx](./funstx/) - Syntax checker for .fun files with optional --fix auto-corrections; usage, exit codes, and limitations. +- [Contributing](./contributing/) - How to contribute: project structure, coding style, running tests, and PR guidelines. +- [Style-guide](./style-guide/) - Coding conventions for C and Fun (indentation, naming, idioms). +- [stdlib](./stdlib/) - Overview of the standard library modules under ./lib with one-line summaries. +- [Embedding](./embedding/) - Embedding the VM from C/Rust, lifecycle, and host integration tips. +- [Errors-and-diagnostics](./errors-and-diagnostics/) - Understanding parser/runtime errors and enabling diagnostics. +- [Performance](./performance/) - Build/runtime tuning tips and patterns for better performance. +- [Security-and-Sandboxing](./security-and-sandboxing/) - Trust boundaries, I/O expectations, and capability restrictions. +- [FAQ](./faq/) - Frequently asked questions and quick answers. +- [Website](./website/) - Documentation for the [fun-lang.xyz](https://fun-lang.xyz) website in the `./web/` directory. +- [Writing-Tests](./writing-tests/) - How to author new tests for Fun and opcode components. +- [Bytecode-Format](./bytecode-format/) - Reference for the bytecode format (split out from internals for convenience). +- [Roadmap](./roadmap/) - High-level direction, planned features, and pointers to issues. ## Examples - - [./examples/](./examples/) - Catalog of all example scripts under [https://git.xw3.org/fun/fun/src/branch/main/examples](https://git.xw3.org/fun/fun/src/branch/main/examples){:class="git"}: what each area contains, how to run them, required env vars, and extension requirements. + - [Examples](./examples/) - Catalog of all example scripts under [https://git.xw3.org/fun/fun/src/branch/main/examples](https://git.xw3.org/fun/fun/src/branch/main/examples){:class="git"}: what each area contains, how to run them, required env vars, and extension requirements. -## External extensions +## Extensions -Documentation for optional, build-time selectable integrations lives in [external/](./external/): +Documentation for optional, build-time selectable integrations lives in [extensions/](./extensions/): -- [Index of extensions](./external/) - - Highlights: [cURL](./external/curl/), [INI](./external/ini/), [JSON](./external/json/), [XML (libxml2)](./external/xml2/), [SQLite](./external/sqlite/), [PCRE2](./external/pcre2/), [PC/SC](./external/pcsc/), [OpenSSL](./external/openssl/) +- [Index of extensions](./extensions/) + - Highlights: [cURL](./extensions/curl/), [INI](./extensions/ini/), [JSON](./extensions/json/), [XML (libxml2)](./extensions/xml2/), [SQLite](./extensions/sqlite/), [PCRE2](./extensions/pcre2/), [PC/SC](./extensions/pcsc/), [OpenSSL](./extensions/openssl/) ## Tips diff --git a/web/documentation/external/curl/curl.md b/web/documentation/extensions/curl/curl.md similarity index 95% rename from web/documentation/external/curl/curl.md rename to web/documentation/extensions/curl/curl.md index 1bbf96c..be75d48 100644 --- a/web/documentation/external/curl/curl.md +++ b/web/documentation/extensions/curl/curl.md @@ -7,7 +7,7 @@ noDate: false title: Fun - cURL (libcurl) extension (optional) subtitle: Documentation for cURL (libcurl) extension (optional) description: Documentation for cURL (libcurl) extension (optional) -permalink: /documentation/external/curl/ +permalink: /documentation/extensions/curl/ lang: en tags: - curl diff --git a/web/documentation/external/external/external.md b/web/documentation/extensions/extensions.md similarity index 71% rename from web/documentation/external/external/external.md rename to web/documentation/extensions/extensions.md index 523c00a..f08e2d1 100644 --- a/web/documentation/external/external/external.md +++ b/web/documentation/extensions/extensions.md @@ -4,10 +4,10 @@ published: true noToc: false noComments: false noDate: false -title: Fun - External integrations (optional extensions) -subtitle: Catalog of all example scripts under ./examples/, what each area contains, how to run them, required env vars, and extension requirements. -description: Catalog of all example scripts under ./examples/, what each area contains, how to run them, required env vars, and extension requirements. -permalink: /documentation/external/ +title: Fun - Optional extensions +subtitle: Catalog of optional, build-time selectable extensions for the Fun VM (e.g., cURL, SQLite, JSON). +description: Catalog of optional, build-time selectable extensions for the Fun VM (e.g., cURL, SQLite, JSON). +permalink: /documentation/extensions/ lang: en tags: - area @@ -18,7 +18,7 @@ tags: - examples - extension - extensions -- external +- extensions - integrations - optional - required diff --git a/web/documentation/external/ini/ini.md b/web/documentation/extensions/ini/ini.md similarity index 96% rename from web/documentation/external/ini/ini.md rename to web/documentation/extensions/ini/ini.md index 53ad719..d8f89e0 100644 --- a/web/documentation/external/ini/ini.md +++ b/web/documentation/extensions/ini/ini.md @@ -7,7 +7,7 @@ noDate: false title: Fun - INI (iniparser) extension (optional) subtitle: Documentation for INI (iniparser) extension (optional) description: Documentation for INI (iniparser) extension (optional) -permalink: /documentation/external/ini/ +permalink: /documentation/extensions/ini/ lang: en tags: - extension diff --git a/web/documentation/external/json/json.md b/web/documentation/extensions/json/json.md similarity index 95% rename from web/documentation/external/json/json.md rename to web/documentation/extensions/json/json.md index 9237594..a2f0eb0 100644 --- a/web/documentation/external/json/json.md +++ b/web/documentation/extensions/json/json.md @@ -7,7 +7,7 @@ noDate: false title: Fun - JSON (json-c) extension (optional) subtitle: Documentation for JSON (json-c) extension (optional) description: Documentation for JSON (json-c) extension (optional) -permalink: /documentation/external/json/ +permalink: /documentation/extensions/json/ lang: en tags: - extension diff --git a/web/documentation/external/openssl/openssl.md b/web/documentation/extensions/openssl/openssl.md similarity index 98% rename from web/documentation/external/openssl/openssl.md rename to web/documentation/extensions/openssl/openssl.md index 49b95fb..9f19cdc 100644 --- a/web/documentation/external/openssl/openssl.md +++ b/web/documentation/extensions/openssl/openssl.md @@ -7,7 +7,7 @@ noDate: false title: Fun - OpenSSL extension (optional) subtitle: Documentation for OpenSSL extension (optional) description: Documentation for OpenSSL extension (optional) -permalink: /documentation/external/openssl/ +permalink: /documentation/extensions/openssl/ lang: en tags: - extension diff --git a/web/documentation/external/pcre2/pcre2.md b/web/documentation/extensions/pcre2/pcre2.md similarity index 95% rename from web/documentation/external/pcre2/pcre2.md rename to web/documentation/extensions/pcre2/pcre2.md index a40ba74..5660d5e 100644 --- a/web/documentation/external/pcre2/pcre2.md +++ b/web/documentation/extensions/pcre2/pcre2.md @@ -7,7 +7,7 @@ noDate: false title: Fun - PCRE2 (Perl-Compatible Regex) extension (optional) subtitle: Documentation for PCRE2 (Perl-Compatible Regex) extension (optional) description: Documentation for PCRE2 (Perl-Compatible Regex) extension (optional) -permalink: /documentation/external/pcre2/ +permalink: /documentation/extensions/pcre2/ lang: en tags: - compatible diff --git a/web/documentation/external/pcsc/pcsc.md b/web/documentation/extensions/pcsc/pcsc.md similarity index 95% rename from web/documentation/external/pcsc/pcsc.md rename to web/documentation/extensions/pcsc/pcsc.md index aeb0e87..2929157 100644 --- a/web/documentation/external/pcsc/pcsc.md +++ b/web/documentation/extensions/pcsc/pcsc.md @@ -7,7 +7,7 @@ noDate: false title: Fun - PC/SC (smart cards) extension (optional) subtitle: Documentation for PC/SC (smart cards) extension (optional) description: Documentation for PC/SC (smart cards) extension (optional) -permalink: /documentation/external/pcsc/ +permalink: /documentation/extensions/pcsc/ lang: en tags: - cards diff --git a/web/documentation/external/sqlite/sqlite.md b/web/documentation/extensions/sqlite/sqlite.md similarity index 94% rename from web/documentation/external/sqlite/sqlite.md rename to web/documentation/extensions/sqlite/sqlite.md index 79c64da..b17d36a 100644 --- a/web/documentation/external/sqlite/sqlite.md +++ b/web/documentation/extensions/sqlite/sqlite.md @@ -7,7 +7,7 @@ noDate: false title: Fun - SQLite extension (optional) subtitle: Documentation for SQLite extension (optional) description: Documentation for SQLite extension (optional) -permalink: /documentation/external/sqlite/ +permalink: /documentation/extensions/sqlite/ lang: en tags: - extension diff --git a/web/documentation/external/xml2/xml2.md b/web/documentation/extensions/xml2/xml2.md similarity index 95% rename from web/documentation/external/xml2/xml2.md rename to web/documentation/extensions/xml2/xml2.md index 0d3c695..75ae946 100644 --- a/web/documentation/external/xml2/xml2.md +++ b/web/documentation/extensions/xml2/xml2.md @@ -7,7 +7,7 @@ noDate: false title: Fun - XML (libxml2) extension (optional) subtitle: Documentation for XML (libxml2) extension (optional) description: Documentation for XML (libxml2) extension (optional) -permalink: /documentation/external/xml2/ +permalink: /documentation/extensions/xml2/ lang: en tags: - extension diff --git a/web/documentation/internals/internals.md b/web/documentation/internals/internals.md index 215184d..75c8590 100644 --- a/web/documentation/internals/internals.md +++ b/web/documentation/internals/internals.md @@ -111,7 +111,7 @@ Opcode handlers organization: - To keep vm.c readable, most opcode implementations are factored into small .c files included directly into vm.c (e.g., vm/core/load_const.c, vm/logic/and.c, vm/arrays/push.c, vm/math/abs.c, vm/os/thread_spawn.c, etc.). - This is a deliberate “amalgamation” style: small single-purpose C units compiled as part of vm.c. -- Optional subsystems (JSON, PCRE2, CURL, SQLite, libSQL, PC/SC, XML2, Tcl/Tk, Notcurses, INI, OpenSSL/LibreSSL crypto helpers, sockets, serial, OS helpers) are grouped under src/external and src/vm//. +- Optional subsystems (JSON, PCRE2, CURL, SQLite, libSQL, PC/SC, XML2, Tcl/Tk, Notcurses, INI, OpenSSL/LibreSSL crypto helpers, sockets, serial, OS helpers) are grouped under src/extensions and src/vm//. Dispatch naming and visibility: @@ -152,7 +152,7 @@ The VM is dynamically typed. Values carry a tag; operations check types at runti - Maps: OP_MAKE_MAP/KEYS/VALUES/HAS_KEY. - Conversions/reflection: OP_TO_NUMBER/TO_STRING/CAST/TYPEOF, OP_UCLAMP/SCLAMP. - I/O and OS: OP_READ_FILE/WRITE_FILE/INPUT_LINE/ENV/PROC_RUN/PROC_SYSTEM/TIME_NOW_MS/CLOCK_MONO_MS/DATE_FORMAT/OS_LIST_DIR/RANDOM_NUMBER, sockets, serial. -- External integrations (optional): JSON, CURL, SQLite, libSQL, PC/SC, XML2, Tcl/Tk, Notcurses, INI, OpenSSL/LibreSSL. +- Extensions (optional): JSON, CURL, SQLite, libSQL, PC/SC, XML2, Tcl/Tk, Notcurses, INI, OpenSSL/LibreSSL. Each handler enforces argument types and returns clear error messages via vm_raise_error on misuse. @@ -257,7 +257,7 @@ The VM includes small, standalone C files for each feature group under src/vm/ - Collections and strings: src/vm/arrays/*.c, src/vm/maps/*.c, src/vm/strings/*.c - Conversions/reflection: src/vm/*.c (to_number, to_string, cast, typeof, uclamp, sclamp) - OS and I/O: src/vm/io/*.c, src/vm/os/*.c, sockets and serial -- External integrations: src/external/*.c glue with opcode handlers in src/vm/ when enabled by CMake options +- Extensions: src/extensions/*.c glue with opcode handlers in src/vm/ when enabled by CMake options Feature flags (CMake): @@ -297,7 +297,7 @@ From vm.h defaults (tuned for simplicity; adjust if needed): - src/bytecode.h — instruction set and bytecode container - src/parser.c — compiler, expression/statement/block parsing, emission, indentation handling - src/vm/* — small focused opcode handlers by domain -- src/external/* — integration shims for optional dependencies +- src/extensions/* — integration shims for optional dependencies ## Concurrency, isolates, and garbage collection