{"id":22511681,"url":"https://github.com/zeroxthreef/simpletinyscript","last_synced_at":"2025-08-02T06:06:41.266Z","repository":{"id":55637885,"uuid":"273220417","full_name":"zeroxthreef/SimpleTinyScript","owner":"zeroxthreef","description":"A somewhat small experimental scripting language","archived":false,"fork":false,"pushed_at":"2023-08-19T23:07:46.000Z","size":187,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T00:47:00.123Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zeroxthreef.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-18T11:29:19.000Z","updated_at":"2021-12-31T01:00:09.000Z","dependencies_parsed_at":"2025-02-02T02:41:28.014Z","dependency_job_id":"88ce6d5b-999a-4183-8676-8307070700fa","html_url":"https://github.com/zeroxthreef/SimpleTinyScript","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zeroxthreef/SimpleTinyScript","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroxthreef%2FSimpleTinyScript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroxthreef%2FSimpleTinyScript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroxthreef%2FSimpleTinyScript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroxthreef%2FSimpleTinyScript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zeroxthreef","download_url":"https://codeload.github.com/zeroxthreef/SimpleTinyScript/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroxthreef%2FSimpleTinyScript/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268339663,"owners_count":24234560,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-07T02:13:41.369Z","updated_at":"2025-08-02T06:06:41.206Z","avatar_url":"https://github.com/zeroxthreef.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SimpleTinyScript\nSTS is an experiment in trying to make a really tiny scripting language that is still mostly usable in an environment where it is embedded in another project.\n\nThe code quality for this is not near acceptable. This project is not meant for any serious use.\n\n\n```\nimport stdlib.sts\n\n\nglobal i 0\n\nloop(\u003c $i 10) {\n    print hello world\n    ++ $i\n}\n```\n\n## Usage (when compiling cli.c)\n`./sts` to enter repl. Works like a shell and will fall back on using the native shell if no global or local function is found\n\n`./sts file.sts` to eval a script\n\n## Configuration Definitions\n```\n#define STS_GOTO_JIT //enable the goto jit which requires a gcc extension\n\n#define CLI_ALLOW_SYSTEM //allow the system() shell function to be used in last resort\n\n#define INSTALL_DIR \"/path/to/install\" //change the install directory so imports work in cli.c\n\n#define CLI_NO_SOCKETS //remove the ability to use sockets\n\n#define CLI_NO_TLS //remove the ability to have tls sockets. Will already be in effect if there are no sockets\n```\n\n## Libraries Used\nThe core of sts lives in ``simpletinyscript.h`` which only depends on the C standard library. However, ``cli.c`` depends on system libraries and on the following public domain libraries which exist in ``ext/``:\n* [pdjson](https://github.com/skeeto/pdjson)\n* [zed_net](https://github.com/mackron/zed_net)\n* [Monocypher](https://github.com/eduardsui/tlse)\n* [tlse](https://github.com/LoupVaillant/Monocypher)\n* [base64](https://github.com/badzong/base64)\n\n## Documentation\n\n**print ...**\u003cbr /\u003e\nturns all values into printable strings and adds spaces between them. Also appends a newline and prints it to stdout\n\n**pass var**\u003cbr /\u003e\npasses the value in 'var'. Useful when replacing 'return'\n\n**string ...**\u003cbr /\u003e\nsame as ``print``, but adds no spaces and no newline\n\n**global varname (value_to_set)**\u003cbr /\u003e\nadds a variable of 'varname' to the global scope. Will return 1 or 0 if it exists when no value_to_set is passed\n\n**local varname (value_to_set)**\u003cbr /\u003e\nsame as ``global`` but works in the local scope (global scope if not in any function)\n\n**string-hash var**\u003cbr /\u003e\nreturns a numeric hash of the string using FNV-1a\n\n**const var**\u003cbr /\u003e\nmarks the value as readonly\n\n**typeof var**\u003cbr /\u003e\nreturns a number of STS_* for the type declared in an enum\n\n**sizeof var**\u003cbr /\u003e\nreturns a number set to the size of the value passed\n\n**if cond eval_expr**\u003cbr /\u003e\ntests if the cond is recognized as true and evaluates eval_expr if so. Returns a 1 or 0 if it ran\n\n**elseif cond eval_expr**\u003cbr /\u003e\nsame as ``if`` but will not do anything if the previous value is 1\n\n**else eval_expr**\u003cbr /\u003e\nonly evaluates eval_expr if the previous value is not 1\n\n**function name (parameters) eval_expr**\u003cbr /\u003e\n2 major cases:\n\n1. if 'name' is nil, then it is not automatically added to the current local scope\n2. if 'name' is a string, it is added to the local scope automatically\n\nrequires 0 or more parameters. The last argument is always the eval_expr.\nthis always returns the function value regardless of a nil name\n\n**copy var**\u003cbr /\u003e\nrecursively copies the value passed\n\n**self-name**\u003cbr /\u003e\nretrieves the script filename from the AST\n\n**number var**\u003cbr /\u003e\nturns a string value into a number\n\n**asc number**\u003cbr /\u003e\nreturns a string consisting of the ascii character equal to 'number'\n\n**char string index**\u003cbr /\u003e\nreturns the numeric value of the character in 'string' at position 'index'\n\n**get var index**\u003cbr /\u003e\nreturns the value in 'var' at 'index'. Only works on arrays and strings\n\n**set val_to_set val_to_shallow_copy**\u003cbr /\u003e\nshallow copies 'val_to_shallow_copy' and overwrites 'val_to_set' with the new value\n\n**array ...**\u003cbr /\u003e\nreturns an array of 0 or more values passed\n\n**remove var index**\u003cbr /\u003e\nremoves the value in 'var' at position 'index'. Only works on arrays\n\n**insert var index insert**\u003cbr /\u003e\ninserts 'insert' into 'var' at position 'index'. only works on arrays\n\n**replace var index insert**\u003cbr /\u003e\nreplaces instead of shallow copies the value at an array index\n\n**import file**\u003cbr /\u003e\nlook for file relative to the interpreter PWD, and if it cant find the file and compiled with cli.c, it will search the system install directory\n\n**call function ...**\u003cbr /\u003e\ncalls function value 'function' and supplies arguments from '...'\n\n**\u0026\u0026**, **||**\u003cbr /\u003e\nwork just like in C\n\n**==**, **!=**, **\u003c**, **\u003c=**, **\u003e**, **\u003e=**\u003cbr /\u003e\nwork just like in C, but let you do string comparisons too. Need to be the same type\n\n**+**, **-**, **\\***, **/**, **\\*\\***, **%**, **\u003e\u003e**, **\u003c\u003c**, **\u0026**, **^**, **|**, **~**, **!**, **++**, **--**\u003cbr /\u003e\nwork mostly just like C, but bit operations conver numbers to integers internally then back to doubles. ``**`` is exponential. ``++`` and ``--`` are prefix only\n\n**C's math.h trig functions**\u003cbr /\u003e\nmostly all present\n\nThe following functions are if embedding into cli.c\n---\n\n**pipeout var \\*command\\***\u003cbr /\u003e\nruns popen() and the stdout from the command provided is sent to 'var' as a string. The return value is the return value of the command. This uses the native shell\n\n**file-read file**\u003cbr /\u003e\nreturns nil if not found, and a string of the file's contents\n\n**file-write file string**\u003cbr /\u003e\nreturns nil if file doesnt exist and the number of bytes written from 'string' if it does\n\n**file-append file string**\u003cbr /\u003e\nsame as ``file-write`` but appends to the file instead of overwrites\n\n**stdin-read number_or_char**\u003cbr /\u003e\n2 possible options:\n1. if 'number_or_char' is a number and equal to 0, it will read until EOF in stream and if \u003e0, it will read until the size of the buffer reaches this\n2. if 'number_or_char' is a single width string, the character will be tested and read until encountered in the stream\n\n**stdout-write ...**\u003cbr /\u003e\nsimilar to ``print`` but no spaces between values and no newline and prints to stdout\n\n**stderr-write ...**\u003cbr /\u003e\nsame as ``stdout-write`` but to stderr instead\n\n**getenv name**\u003cbr /\u003e\nreturns nil if not found or a string of the environment variable\n\n**setenv name value**\u003cbr /\u003e\nsets the environment variable to the value if found or makes a new variable of that name\n\n**sleep seconds**\u003cbr /\u003e\nsleeps for the number of seconds provided in 'seconds'\n\n**json string_data|any_value (prettify)**\u003cbr /\u003e\nif supplying a single string argument, it will parse the string. Two arguments with a number is json from value conversion. ``$prettify`` as 1 will make the output look nice. 0 will make the output compact\n\n**socket-tcp port non_blocking listening**\u003cbr /\u003e\ncreates a tcp socket, and if creating a server socket, set listening to 1\n\n**socket-udp port non_blocking**\u003cbr /\u003e\ncreates a udp socket\n\n**socket-set-broadcast socket state_0_or_1**\u003cbr /\u003e\napply SO_BROADCAST\n\n**socket-tcp-connect socket host port**\u003cbr /\u003e\nconnect to a tcp server with the supplied arguments. Returns 1 if the address is unknown, 2 if the host didnt connect, and 0 if successful\n\n**socket-tcp-send socket data**\u003cbr /\u003e\nsends string buffer to host. Returns the amount of sent bytes or -1 on error\n\n**socket-tcp-recv socket**\u003cbr /\u003e\nreturns a string buffer if successful, -1 on error, or 1 if the socket would block on a nonblocking port\n\n**socket-udp-send socket destination_address destination_port data**\u003cbr /\u003e\nsends string buffer to host. Returns the amount of sent bytes or -1 on error\n\n**socket-udp-recv socket**\u003cbr /\u003e\nreturns a string buffer if successful, -1 on error, or 1 if the socket would block on a nonblocking port\n\n**socket-tcp-would-block socket**\u003cbr /\u003e\nreturns 1 if the socket would block\n\n**socket-tcp-accept socket out_client_socket_reference**\u003cbr /\u003e\nthe out_socket_client_reference value will be set to the client socket (similar to pipeout) and returns 0 upon success, 1 upon would block, -1 upon error, and 2 upon the socket not able to listen\n\n**socket-enable-ssl-client socket**\u003cbr /\u003e\nenable ssl on the current socket. Returns nonzero on error\n\n**crypto-argon2i password_str salt_str block_num iteration_num**\u003cbr /\u003e\nreturns a 32 byte string. Monocypher documentation recommends 100000 blocks and 3 iterations\n\n**crypto-hash str**\u003cbr /\u003e\nreturns a 32 byte string hash using blake2b\n\n**crypto-sign-public privkey_str**\u003cbr /\u003e\nreturns a 32 byte public key string. Requires a 32 byte private key string\n\n**crypto-sign message_str privkey_str**\u003cbr /\u003e\nreturns a 64 byte signature string. the private key string must be 32 bytes\n\n**crypto-check message_str signature_str pubkey_str**\u003cbr /\u003e\nreturns 1 if a correct 64 byte signature str is used for the 32 byte public key str on the message\n\n**base64-encode str**\u003cbr /\u003e\nreturn a b64 encoded string\n\n**base64-decode str**\u003cbr /\u003e\nreturn a decoded b64 string\n\n**exit status**\u003cbr /\u003e\nexits the interpreter with an optional status\n\n**directory-list**\u003cbr /\u003e\nreturns an array of strings in the directory or nil if it doesnt exist\n\n**platform**\u003cbr /\u003e\nreturns 'windows' or 'unix'\n\nThe following functions are documentation for ``stdlib.sts``\n---\n\n**STS_EXTERNAL**, **STS_NIL**, **STS_NUMBER**, **STS_STRING**, **STS_ARRAY**, **STS_FUNCTION**\u003cbr /\u003e\nreturns the number of the type returned by ``typeof``\n\n**hashmap ...**\u003cbr /\u003e\nreturns a hashmap of \"key, value\". To make easily readable, append a '\\' at the end of every key and value passed so the function arguments cascade vertically\n\n**hashmap-get map key**\u003cbr /\u003e\nreturns nil if not found and the value in 'map' of 'key'\n\n**hashmap-exists map key**\u003cbr /\u003e\nreturns 1 if the key does and 0 if not\n\n**hashmap-set map key value**\u003cbr /\u003e\nsets the key if it exists, and if it doesnt it will make a new one to set to 'value'\n\n**hashmap-replace map key value**\u003cbr /\u003e\nreplaces the entire row value and key if it exists, and if it doesnt it will make a new one to set to 'value'\n\n**hashmap-remove map key**\u003cbr /\u003e\nremoves 'key' and its value from 'map'\n\n**hashmap-keys map**\u003cbr /\u003e\nreturns an array of the strings used as keys in the hashmap\n\n**hashmap-values map**\u003cbr /\u003e\nsame as ``hashmap-keys`` but for the values instead\n\n**hashmap-update map**\u003cbr /\u003e\nbecause keys are passed by reference and stored in the row rather than copied into the row, the key could change at some point and thats mostly ok, but the string hash needs to be updated as well. Call this if theres a possibility that the keys updated in the hashmap\n\n**string-tokenize string token**\u003cbr /\u003e\nreturns an array of the string separated into smaller strings divided by 'token'\n\n**string-combine array between_string**\u003cbr /\u003e\nundoes ``string-tokenize** if passed the same token string\n\n**string-range string start end**\u003cbr /\u003e\nreturns an inclusive substring from 'start' and 'end'\n\n**string-search string needle**\u003cbr /\u003e\nreturns -1 if not found, and the position in the string where 'needle' is first found\n\n**string-rsearch string needle**\u003cbr /\u003e\nsame as ``string-search`` but searches from the back of the string\n\n**string-insert string position instring**\u003cbr /\u003e\nreturns a new string with the instring between 'string' at 'position'. Works at the end of the string as well\n\n**string-remove string position**\u003cbr /\u003e\nreturns a new string with the character at 'position' removed\n\n**string-replace string replacee replacement**\u003cbr /\u003e\nreturns a new string with 'replacee' replaced with 'replacement' everywhere\n\n**getpwd self**\u003cbr /\u003e\nreturns the pwd when ``self-name`` is passed\n\n**relimport self script**\u003cbr /\u003e\nimports and uses ``getpwd`` internally when passed ``self-name`` in 'self'\n\n**stdlib-get-error**\u003cbr /\u003e\nreturns nil if no error, and the string of the current stdlib error\n\n**stdlib-set-error component_str error_str**\u003cbr /\u003e\nsets the current stdlib error to the format \"component_str: error_str\"\n\n**string-value-print value**\u003cbr /\u003e\nreturns a string of recursively created stringification of 'value'\n\n**typeof-string value**\u003cbr /\u003e\nreturns a string of the type instead of a number. Looks like \"STS_NUMBER\"\n\n**expr ...**\u003cbr /\u003e\n!WIP\n\n**enum ...**\u003cbr /\u003e\n!WIP\n\n**+=**, **-=**, **\\*=**, **/=**, **%=**, **\\*\\*=**, \nwork like C's operators, but ``**=`` is exponential equal\n\n## License\nUnlicense. This project is released into the public domain.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeroxthreef%2Fsimpletinyscript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzeroxthreef%2Fsimpletinyscript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeroxthreef%2Fsimpletinyscript/lists"}