Zerionyx Documentation

Getting Started

  • Install Zerionyx: git clone https://github.com/memecoder12345678/Zerionyx
  • Run a file: python zerionyx.py yourfile.zyx
  • Open interactive shell: python zerionyx.py
  • See the github repository for more info

Language Grammar

PROGRAM ::= STATEMENTS

STATEMENTS ::= STATEMENT (NEWLINE+ STATEMENT)* NEWLINE*

STATEMENT ::= SIMPLE_STATEMENT | COMPOUND_STATEMENT

SIMPLE_STATEMENT ::=
    load STRING
  | return [EXPR]
  | continue
  | break
  | using [parent] IDENTIFIER (, IDENTIFIER)*
  | del IDENTIFIER (, IDENTIFIER)*
  | EXPR

COMPOUND_STATEMENT ::=
    IF_EXPR
  | FOR_EXPR
  | WHILE_EXPR
  | NAMESPACE_EXPR
  | (DECORATOR+ DEF_FUNC)
  | DEF_FUNC

BODY ::= STATEMENT | (NEWLINE STATEMENTS done)

EXPR ::= ASSIGNMENT_EXPR

ASSIGNMENT_EXPR ::=
    (IDENTIFIER (, IDENTIFIER)* = EXPR)
  | (IDENTIFIER AUG_ASSIGN_OP EXPR)
  | LOGIC_EXPR

AUG_ASSIGN_OP ::= += | -= | *= | /= | //= | %= | ^=

LOGIC_EXPR ::= COMP_EXPR ((and | or) COMP_EXPR)*

COMP_EXPR ::=
    not COMP_EXPR
  | ARITH_EXPR ((== | != | < | > | <= | >=) ARITH_EXPR)*

ARITH_EXPR ::= TERM ((+ | -) TERM)*

TERM ::= FACTOR ((* | / | // | %) FACTOR)*

FACTOR ::=
    + FACTOR
  | * FACTOR                      (* vargs unpacking *)
  | ** FACTOR                     (* kargs unpacking *)
  | DOLLAR_EXPR

DOLLAR_EXPR ::= POWER ($ POWER)*  (* $ is for indexing instead of [] *)

POWER ::= CALL (^ FACTOR)*        (* power operator *)

CALL ::= ATOM ( (. IDENTIFIER) | (( [ARG_LIST] )) )*

ARG_LIST ::= ARG (, ARG)*

ARG ::= EXPR | (IDENTIFIER = EXPR)

ATOM ::=
    INT | FLOAT | STRING | IDENTIFIER
  | ( EXPR )
  | LIST_EXPR
  | HASHMAP_EXPR
  | IF_EXPR
  | FOR_EXPR
  | WHILE_EXPR
  | DEF_FUNC
  | NAMESPACE_EXPR

LIST_EXPR ::= [ [EXPR (, EXPR)*] ]

HASHMAP_EXPR ::= { [EXPR : EXPR (, EXPR : EXPR)*] }

NAMESPACE_EXPR ::= namespace IDENTIFIER NEWLINE STATEMENTS done

IF_EXPR ::=
    if EXPR do BODY
    (elif EXPR do BODY)*
    [else do BODY]?

FOR_EXPR ::=
    (for FOR_IN_CLAUSE | FOR_RANGE_CLAUSES) do BODY

FOR_IN_CLAUSE ::= IDENTIFIER (, IDENTIFIER)* in EXPR

FOR_RANGE_CLAUSES ::= FOR_RANGE_CLAUSE (, FOR_RANGE_CLAUSE)*

FOR_RANGE_CLAUSE ::= IDENTIFIER [= EXPR] to EXPR [step EXPR]?

WHILE_EXPR ::= while EXPR do BODY

DECORATOR ::= & EXPR NEWLINE*

DEF_FUNC ::=
    defun [IDENTIFIER] ( [PARAM_LIST] ) (-> EXPR | (NEWLINE STATEMENTS done))

PARAM_LIST ::= (PARAMS [, VAR_PARAMS]) | VAR_PARAMS

PARAMS ::= PARAM (, PARAM)*

PARAM ::= IDENTIFIER [= EXPR]

VAR_PARAMS ::= (VARARGS_PARAM [, KWARGS_PARAM]) | KWARGS_PARAM

VARARGS_PARAM ::= * IDENTIFIER

KWARGS_PARAM ::= ** IDENTIFIER

The Zen of Zerionyx

The Zen of Zerionyx, by MemeCoder.

Clarity is better than cleverness.
Consistency is better than chaos.
Freedom in syntax, but not in structure.
Parentheses are for math, backslashes are for flow.
The caret (^) means power — and nothing else.
Blocks should be explicit: done says it all.
if is a command, not a value.
Whitespace is free; newlines are not.
Write like a poet, execute like a machine.
Code is for humans first, machines second.
load means include — not magic.
Indentation is rhythm, not restriction.
When in doubt, don’t guess — define it.
Simplicity comes first.
If it’s hard to explain, it’s probably wrong.
If it’s easy to explain, it might be right.
Weirdness is not a feature.
Zerionyx may be magical, but its syntax must be real.

Language Reference

Data Types

Zerionyx is dynamically typed. Here are the primary data types:

  • Number: Can be an integer (e.g., 10, -5) or a float (e.g., 3.14)
  • String: A sequence of characters, enclosed in double quotes (e.g., "hello")
  • Bool: Represents boolean values, either true or false
  • List: An ordered collection of items, similar to an array (e.g., [1, "two", true])
  • HashMap: A collection of key-value pairs (e.g., {"name": "Zyx", "version": 1}), keys must be strings
  • Bytes: A sequence of raw bytes, useful for binary data and hashing
  • CFloat: A "correct float" type that uses high-precision decimals to avoid common floating-point errors
  • None: A special type representing the absence of a value, written as none

Built-in Constants

Zerionyx provides several global constants for convenience.

Core Values

  • true — The boolean value for truth
  • false — The boolean value for falsehood
  • none — Represents the absence of a value
  • is_main — Check if the current file is the one being executed

Type Representations (Strings)

These constants are string values that correspond to the output of the type() function. They are useful for type checking.


if type([1, 2]) == list do
    println("It's a list!")
done

  • list"<list>"
  • str"<str>"
  • int"<int>"
  • float"<float>"
  • bool"<bool>"
  • func"<func>"
  • hashmap"<hashmap>"
  • thread"<thread>"
  • bytes"<bytes>"
  • cfloat"<cfloat>"
  • py_obj"<py-obj>"
  • namespace"<namespace>"
  • channel_type"<channel>"
  • none_type"<none>"
  • thread_pool_type"<thread-pool>"
  • future_type"<future>"

Special Numeric Values

  • nan — Not a Number
  • inf — Positive infinity
  • neg_inf — Negative infinity

Built-in Functions

  • append(obj, val) → list — Add val to end of obj return val
  • is_panic(func, args=[], kwargs={}) → list — Run func with args return [result, none, none] if ok or [none, err_msg, err_name ("RT": "Runtime Error", "M": "Math Error", "IO": "IO Error" or "T": "Type Error")] if error
  • clear() → none — Clear terminal
  • extend(a, b) → none — Add all in b to a both must be list
  • input(prompt="") → str — Show prompt get user input
  • get_password(prompt="") → str — Show prompt get user password
  • insert(lst, i, val) → none — insert val to lst at index i
  • is_func(x) → bool — Check if x is func
  • is_list(x) → bool — Check if x is list
  • is_py_obj(x) → bool — Check if x is PyObject
  • is_none(x) → bool — Check if x is none
  • is_num(x) → bool — Check if x is number
  • is_str(x) → bool — Check if x is string
  • is_bool(x) → bool — Check if x is boolean
  • is_thread(x) → bool — Check if x is thread
  • is_thread_pool(x) → bool — Check if x is thread pool
  • is_future(x) → bool — Check if x is future
  • is_namespace(x) → bool — Check if x is namespace
  • keys(hm) → list — Return list of all keys in hm (a hashmap)
  • values(hm) → list — Return list of all values in hm
  • items(hm) → list — Return list of [key, value] pairs in hm
  • has(hm, key) → bool — Return true if key exists in hm
  • get(hmol, koi, default=none) → any — Return value for koi or default if not found
  • del_key(hm, key) → none — Delete key and its value from hm
  • len(x) → number — Get length of x
  • panic(msg, type="RT") — Stop with err msg and type ("RT": "Runtime Error", "M": "Math Error", "IO": "IO Error" or "T": "Type Error")
  • pop(lst, i) → any — Remove and return item at i in lst
  • print(value="") → none — Prints text to the standard output with no newline
  • println(value="") → none — Same as print but adds a newline
  • to_float(x, supress_error=false) → number (float)/none — Convert x to float return none if fail and supress_error true else raise
  • to_int(x, supress_error=false) → number (int)/none — Convert x to int return none if fail and supress_error true else raise
  • to_str(x) → str — Convert x to string
  • to_cfloat(x, supress_error=false) → cfloat — Convert x to cfloat (correct float) return none if fail and supress_error true else raise
  • to_bytes(x, from_hex=false, supress_error=false) → bytes — Convert x to bytes return none if fail and supress_error true else raise
  • type(x) → str — Return type of x as string
  • pyexec(code, env={}) → hashmap — Executes embedded Python code and returns its result (use with caution)
  • slice(l, from=none, to=none, step=none) → list/string/hashmap/bytes — Slice list/string/hashmap/bytes l from from to to step step (exclusive)
  • is_nan(n) → bool — Check if n is NaN (Not a Number)
  • is_channel(n) → bool — Check if n is channel
  • is_cfloat(n) → bool — Check if n is cfloat
  • clone(value) → any — Clone and return value
  • get_member(namespace, member, default=none) → any — Gets a member from a namespace, returning default if it does not exist
  • shl(a, b) → number (int) — Bitwise left shift on integer a by b positions
  • shr(a, b) → number (int) — Bitwise right shift on integer a by b positions
  • bitwise_and(a, b) → number (int) — Performs a bitwise AND operation on integers a and b
  • bitwise_or(a, b) → number (int) — Performs a bitwise OR operation on integers a and b
  • bitwise_xor(a, b) → number (int) — Performs a bitwise XOR operation on integers a and b
  • bitwise_not(a) → number (int) — Performs a bitwise NOT (inversion) operation on integer a

Namespaces

Namespaces are objects that serve as containers to group related variables and functions. They help organize code and prevent name conflicts, especially when building libraries.

You can define a namespace using the namespace ... done block. Members inside the namespace are accessed using dot notation (.).

Important note: All variables and functions declared inside a namespace are immutable. This means:

  • The names of variables and functions cannot be changed or reassigned after they are defined.
  • Members of a namespace are read-only — they can be accessed but not modified or overridden.
This ensures that the namespace remains consistent, safe, and protected from unintended changes.


# Define a namespace to group math-related utilities
namespace math_utils
    pi = 3.14159
    
    defun circle_area(radius)
        return pi * radius ^ 2
    done
done

# Access members using dot notation
r = 10
area = math_utils.circle_area(r)

println("The area is " + to_str(area))
println("Pi value: " + to_str(math_utils.pi))

Control Flow

Conditional logic is handled using if, elif, and else statements. Each block of code to be executed is introduced by the do keyword and the entire structure is terminated by done.


score = 85

if score >= 90 do
    println("Grade: A")
elif score >= 80 do
    println("Grade: B")
else do
    println("Grade: C or lower")
done

Loops

Zerionyx provides three types of loops.


While Loop

Executes a code block if a condition is true.


count = 0
while count < 5 do
    println(count)
    count = count + 1
done

For Loop (Numeric Range)

Iterates over a range of numbers.


# Prints numbers from 0 to 10
for i to 11 do
    println(i)
done

# Prints numbers from 01 to 99
for i to 10, j = 1 to 10 do
    println(to_str(i) + to_str(j))
done

# Prints even numbers from 2 to 10
for j = 2 to 11 step 2 do
    println(j)
done


For-In Loop (Iterator)

Iterates over the elements of an iterable like a list or string.


fruits = ["apple", "banana", "cherry"]
for fruit in fruits do
    println("I like " + fruit)
done

The break statement can be used to exit a loop immediately, and continue skips to the next iteration.

Functions

Functions are defined with the defun keyword. They can accept parameters and also support default values.


Function

A function is a reusable block of code that can be called with arguments to perform specific operations.


defun greet(name="World")
    return "Hello, " + to_str(name) + "!"
done

println(greet("Zerionyx")) # Output: Hello, Zerionyx!
println(greet())           # Output: Hello, World!

Anonymous and One-Line Functions

Functions can also be defined on a single line, and can be anonymous (without a name).


# One-line function
defun sqrt(x) -> x ^ 0.5

# Anonymous function assigned to a variable
a = defun (x) -> x ^ 0.5

Decorators

Decorators modify or enhance functions using the & symbol before the function definition. A decorator is a function that takes another function and returns a new, modified function.


load "libs.decorators"

# &decorators.once ensures this function only runs its body the first time it's called
&decorators.once
defun initialize_settings()
    println("Settings initialized")
done

initialize_settings() # Output: Settings initialized
initialize_settings() # Does nothing

The using Statement: Accessing Global Scope

The using statement is used to explicitly bind a variable reference to the global scope rather than creating a new local variable. This allows a function to read from and modify a global variable directly.


using : The global Analogy

When you need a function to modify a variable that exists in the global scope (or a specific top-level namespace), using creates a direct, writable link to that original variable. This brings the name into the local scope for easy access.


is_running = true

defun stop_application()
    using is_running
    is_running = false
done

println("App is running: " + to_str(is_running)) # Output: App is running: true

stop_application()

println("App is running: " + to_str(is_running)) # Output: App is running: false

using parent Statement: The nonlocal Analogy

The using parent statement is used inside nested functions. It binds a variable reference to the immediate parent function’s scope, similar to Python’s nonlocal keyword.


x = 2 # Global variable

defun outer()
    x = 0 # Local variable, shadows the global 'x'

    defun inner()
        using parent x
        x += 1
    done

    println("outer's x before: " + to_str(x)) # Output: outer's x before: 0
    inner()
    println("outer's x after: " + to_str(x)) # Output: outer's x after: 1
done

outer()
println("global x: " + to_str(x)) # Output: global x: 2

Vargs and Kwargs

Zerionyx supports functions that can accept a variable number of arguments using special syntax in the parameter list.


Vargs (*args)

A parameter prefixed with a single asterisk (*) will collect all extra positional arguments into a list. This is often called "vargs" or "star-args".


Kwargs (**kwargs)

A parameter prefixed with a double asterisk (**) will collect all extra keyword arguments into a HashMap. This is commonly known as "kwargs".


defun show_details(name, *scores, **details)
    println("Name: " + name)
    println("Scores (Vargs): " + to_str(scores))
    println("Details (Kwargs): " + to_str(details))
done

# Call the function with multiple positional and keyword arguments
show_details("Alice", 95, 88, 100, age=25, city="New York")

# Output:
# Name: Alice
# Scores (Vargs): [95, 88, 100]
# Details (Kwargs): {"age": 25, "city": "New York"}

Input/Output

Basic console I/O is handled by built-in functions.

  • println(value): Prints the value followed by a newline
  • print(value): Prints the value without a newline
  • input(prompt): Displays a prompt and returns the user's input as a string

name = input("Enter your name: ")
println("Hello, " + name)

Error Handling

Zerionyx uses a "panic" system for errors. Instead of traditional try-catch blocks, you can safely execute a function using the is_panic built-in. It returns a list indicating success or failure.


defun divide(a, b)
    if b == 0 do
        panic("Cannot divide by zero!", "M") # "M" for Math Error
    done
    return a / b
done

result = is_panic(divide, [10, 0])
value = result$0      # The result if successful
error_msg = result$1  # The error message if it failed
error_type = result$2 # The error type (e.g., "M")

if error_msg != none do
    println("Error: " + error_msg)
else do
    println("Result: " + to_str(value))
done
# Output: Error: Cannot divide by zero!

File Handling

File operations are managed through the ffio standard library.


load "libs.ffio"

filename = "greetings.txt"
content = "Hello from Zerionyx!"

# Write to a file
ffio.write(filename, "w", content)

# Read from a file
read_content = ffio.read(filename, "r")
println(read_content) # Output: Hello from Zerionyx!

Strings

Strings are immutable sequences of characters.

  • Concatenation: "a" + "b" results in "ab"
  • Repetition: "a" * 3 results in "aaa"
  • Indexing: Use the $ operator to get a character at a specific index "hello"$1 results in "e"

For more advanced functions like splitting, joining, and replacing, use the string library.

Lists

Lists are mutable, ordered collections of items.

  • Creation: my_list = [1, "a", true]
  • Indexing: my_list$0 returns 1
  • Appending: my_list + "new" returns [1, "a", true, "new"]
  • Concatenation: [1, 2] * [3, 4] returns [1, 2, 3, 4]
  • Removal by index: [1, 2, 3] - 1 returns [1, 3]

The listm library provides functions like map, filter, sort, etc.

HashMaps

HashMaps store key-value pairs. Keys must be strings.

  • Creation: person = {"name": "Alex", "age": 30}
  • Accessing: person$"name" returns "Alex"
  • Adding/Updating: person + {"city": "New York"}, note that this returns a new map

Use built-in functions like keys(hm), values(hm), and has(hm, key) for more operations.

Assignment to Lists and HashMaps

The $ operator is not only used for accessing elements but also for assigning or updating values at a specific index in a list or a key in a HashMap.


List Assignment

You can change the value at a specific index of a list.


nums = [1, 2, 3, 4, 5]
nums$1 = 99 # Update the value at index 1
println(nums) # Output: [1, 99, 3, 4, 5]
println(nums$1) # Output: 99

HashMap Assignment

You can add a new key-value pair or update an existing one. This is particularly useful when building complex structures like a list of hashmaps.


users = []
append(users, {}) # Add an empty hashmap to the list

# Assign values to the hashmap inside the list
users$0$"name" = "user-1"
users$0$"password" = "123456"

println(users)
println(users$0$"name")
println(users$0$"password")

Bytes

The bytes type represents an immutable sequence of bytes. It's essential for working with binary data, file I/O in binary mode, and cryptographic hashing.

  • Creation: Use the to_bytes(value) function
  • From String: to_bytes("hello")
  • From Hex: to_bytes("68656c6c6f", from_hex=true)
  • Operations: Supports concatenation (+) and indexing ($)
load "libs.hash"
data = to_bytes("my secret data")
hashed_data = hash.sha256(data)
println(hashed_data)

CFloat (Correct Float)

Due to the nature of binary floating-point arithmetic, simple operations like 0.1 + 0.2 can result in imprecise values (e.g., 0.30000000000000004). The cfloat type avoids this by using a high-precision decimal representation.

Use to_cfloat(value) to create a CFloat. They support all standard arithmetic operations.


a = to_cfloat("0.1")
b = to_cfloat("0.2")
result = a + b

println(result) # Output: 0.3

Standard Library

To use a library, add load "libs.<name>" at the top of your .zyx file. For example: load "libs.math".

The load statement works similarly to #include in C — it inserts the contents of the file directly into your code, without automatically applying any namespace.

That means if you’re loading your own library and want to keep things organized, you should manually wrap it in a namespace using the namespace keyword.

All official libraries under libs.* are already wrapped in their own namespaces. That’s why you can use them right away, like math.is_prime(314).

To load a library from your current directory instead of the built-in ones, use the local.<name> prefix. For example: load "local.utils" will include utils.zyx from the current folder.

listm.zyx

  • map(f, l) → list — Apply function f to each element of list l
  • filter(f, l) → list — Filter list l by function f (keep elements where f(x) is true)
  • reduce(f, l, i) → any — Reduce list l with function f and initial value i
  • min(l) → number — Minimum value in list l
  • max(l) → number — Maximum value in list l
  • reverse(l) → list — Reverse the list l
  • zip(l1, l2) → list — Pair elements from l1 and l2 (shortest length)
  • zip_longest(l1, l2) → list — Pair elements from l1 and l2 (fill with none if lengths differ)
  • sort(l, reverse=false) → list — Sort list l
  • count(l, v) → number — Count occurrences of v in l
  • index_of(l, v) → number/none — Index of v in l or none if not found
  • rand_int_list(len, min, max) → list — List of random integers
  • rand_float_list(len, min, max) → list — List of random floats

string.zyx

  • split(s, sep="") → list — Split string s by separator sep
  • strip(s, sep=" ") → list — Trims sep from both ends of s
  • join(sep, l) → str — Join list l with separator sep
  • replace(s, old, new, c=-1) → str — Replace old with new in s
  • to_upper(s) → str — Uppercase s
  • to_lower(s) → str — Lowercase s
  • ord(s) → number — Unicode code point of character s
  • chr(n) → str — Character from code n
  • is_digit(s) → bool — Is s a digit
  • is_ascii_lowercase(s) → bool — Is s a lowercase letter
  • is_ascii_uppercase(s) → bool — Is s an uppercase letter
  • is_ascii_letter(s) → bool — Is s a letter
  • is_space(s) → bool — Is s a whitespace character
  • find(s, v) → number/none — Index of substring v in s
  • find_all(s, v) → list — All indices of substring v in s
  • startswith(s, v) → bool — s starts with v
  • endswith(s, v) → bool — s ends with v
  • encode(s, encoding="utf-8", errors="strict")bytes — Encode s using encoding
  • decode(b, encoding="utf-8", errors="strict")string — Decode b using encoding
  • format(s, l) → str — Creates a new formatted string by substituting placeholders like {} within a template with the provided list values

math.zyx

  • sqrt(a) → number — Square root of a
  • abs(a) → number — Absolute value of a
  • fact(n) → number — Factorial of n
  • sin(x) → number — Sine of x
  • cos(x) → number — Cosine of x
  • tan(x) → number — Tangent of x
  • gcd(a, b) → number — GCD of a and b
  • lcm(a, b) → number — LCM of a and b
  • fib(n) → number — n-th Fibonacci number
  • is_prime(n) → bool — Is n prime
  • deg2rad(d) → number — Degrees to radians
  • rad2deg(r) → number — Radians to degrees
  • exp(x) → number — Exponential of x
  • log(x) → number — Natural logarithm of x
  • sinh(x) → number — Hyperbolic sine
  • cosh(x) → number — Hyperbolic cosine
  • tanh(x) → number — Hyperbolic tangent
  • round(x) → number — Round x to nearest integer
  • is_close(a, b, rel_tol=1*10^(-9), abs_tol=0.0) → bool — Compare two floats within a tolerance
  • Constants: PI, E, ln2

ffio.zyx

  • write(file, mode, text) → none — Write text to file with mode mode ("w", "a" or "wb")
  • read(file, mode) → str/bytes — Read contents of file with mode mode ("r" or "rb")
  • exists(file) → bool — Check if file exists
  • get_cdir() → str — Get current directory
  • set_cdir(dir) → none — Change current directory
  • list_dir(dir=".") → list — List files in directory
  • make_dir(dir) → none — Create directory
  • remove_file(file) → none — Remove file
  • rename(old, new) → none — Rename file or directory
  • remove_dir(dir) → none — Remove directory
  • copy(src, dst) → none — Copy file
  • is_file(file) → bool — Is path a file
  • abs_path(path) → str — Get absolute path
  • base_name(file) → str — Get file name
  • dir_name(file) → str — Get parent folder
  • symlink(src, dst) → none — Create symbolic link from src to dst
  • readlink(path) → str — Read destination of a symbolic link
  • stat(path) → list — Get file or directory metadata (follow symlinks)
  • lstat(path) → list — Get file or directory metadata (don’t follow symlinks)
  • walk(top) → list — Recursively walk through directory tree starting at top
  • chmod(path, mode) → none — Change permission bits of a file or directory
  • chown(path, uid, gid) → none — Change owner and group of a file or directory
  • utime(path, times) → none — Set access and modification times
  • link(src, dst) → none — Create a hard link from src to dst
  • unlink(path) → none — Remove a file or symbolic link
  • access(path, mode) → bool — Check user’s access permissions for a path
  • path_join(parts) → str — Join multiple path components into one
  • is_dir(path) → bool — Check if the path is a directory
  • is_link(path) → bool — Check if the path is a symbolic link
  • is_mount(path) → bool — Check if the path is a mount point
  • Constants: os_sep

hash.zyx

  • md5(s) → bytes — MD5 hash of s
  • sha1(s) → bytes — SHA1 hash of s
  • sha256(s) → bytes — SHA256 hash of s
  • sha512(s) → bytes — SHA512 hash of s
  • crc32(s) → bytes — CRC32 hash of s

memory.zyx

  • remember(key, value) → none — Store value with key
  • recall(key) → any/none — Retrieve value by key
  • forget(key) → none — Remove key from memory
  • clear_memory() → none — Clear all memory
  • keys() → list — List all keys
  • is_empty() → bool — Is memory empty
  • size() → number — Number of keys

net.zyx

  • get_ip() → str — Get public IP address
  • get_mac() → str — Get MAC address
  • ping(host) → str — Ping host
  • downl(url, timeout=15) → str — Download file from URL
  • get_local_ip() → str — Get local IP address
  • get_hostname() → str — Get hostname
  • request(url, method="GET", headers={}, data={}, timeout=15) → list/hashmap — Send HTTP request and return response JSON

random.zyx

  • rand() → number (float) — Random float in [0, 1]
  • rand_int(min, max) → number (int) — Random integer in [min, max]
  • rand_float(min, max) → number (float) — Random float in [min, max]
  • rand_choice(list) → any — Random element from list
  • int_seed(i) → number (int) — Integer seed
  • float_seed(f) → number (float) — Float seed

sys.zyx

  • system(cmd) → none — Execute system command
  • osystem(cmd) → list — Same as system but returns its result
  • get_env(name) → str — Get environment variable
  • set_env(name, value) → none — Set environment variable
  • exit(exit_code=0) → none — Exit program
  • argv — List of command-line arguments
  • os_name — OS name

threading.zyx

  • start(func, args=[], kwargs={}) → thread — Starts a new thread to execute func
  • sleep(seconds) → none — Pauses the current thread for a specified duration
  • join(thread, timeout=15) → none — Waits for a specific thread to complete its execution
  • is_alive(thread) → bool — Checks if a thread is still running
  • cancel(thread) → none — Attempts to terminate a running thread

Pool Namespace (threading.pool)

Provides a high-level interface for managing a pool of worker threads to execute tasks asynchronously.

  • new(max_workers=5) → thread-pool — Creates a new thread pool with a specified number of worker threads
  • submit(pool, func, args=[], kwargs={}) → future — Submits a task (func with its arguments) to the thread pool for execution and returns a future object immediately
  • shutdown(pool, wait=true) → none — Shuts down the thread pool, releasing all resources, if wait is true, it will wait for all submitted tasks to complete
  • result(future) → any — Retrieves the result from a future object
  • is_done(future) → bool — Checks if the task associated with the future has completed, either successfully or with an error

time.zyx

  • sleep(seconds) → none — Pauses execution for seconds
  • time() → number (float) — Current time (seconds since epoch)
  • ctime(time) → str — Human-readable time string

datetime Namespace

A namespace for working with date and time objects.

  • now() → str — Returns the current local date and time
  • today() → str — Returns the current local date
  • format(dt, fmt) → str — Formats a datetime object dt into a string using fmt
  • parse(s, fmt) → str — Parses a string s into a datetime object using format fmt
  • add_days(dt, days) → str — Returns a new datetime object with days added
  • diff(dt1, dt2) → number — Returns the difference between two datetime objects

keyboard.zyx

  • write(text) → none — Type text as keyboard input
  • press(key) → none — Press a key
  • release(key) → none — Release a key
  • wait(key) → none — Wait for key press
  • is_pressed(key) → bool — Is key pressed

termcolor.zyx

  • cprint(text, color=none, background=none, style=none) → none — Prints text with color, background, and style with no newline
  • cprintln(text, color=none, background=none, style=none) → none — Same as cprint but adds a newline
  • get_code(color=none, background=none, style=none) → str — Return ANSI escape code string for the given color, background, and style

mouse.zyx

  • move(x, y) → none — Moves the mouse cursor to position (x, y)
  • click() → none — Performs a left-click at the current mouse position
  • right_click() → none — Performs a right-click at the current mouse position
  • scroll(amount) → none — Scrolls vertically by amount units
  • position() → list — Returns the current mouse position as a list of two numbers

screen.zyx

  • capture(path) → none — Takes a screenshot of the entire screen and saves it to path
  • capture_area(x, y, w, h, path) → str — Captures a specific screen region starting at (x, y) with size w × h and saves it to path
  • get_color(x, y) → str — Returns the color at (x, y) as a hex string like #rrggbb

json.zyx

  • parse(o) → str — Convert o to JSON string
  • stringify(s) → any — Parse JSON string s to Zerionyx object

decorators.zyx

  • cache(fn) → func — Store results of function calls and return cached value for the same inputs
  • once(fn) → func — Ensure the function runs only once, subsequent calls return the first result
  • retry(times) → func — Retry a function up to times if it raises an error
  • timeout(ms) → func — Cancel function execution if it exceeds ms milliseconds
  • log_call(fn) → func — Print logs before and after calling the function
  • measure_time(fn) → func — Measure and print execution time (in ms)
  • repeat(n) → func — Execute a function n times and return the last result
  • ignore_error(default=none) → func — Ignore errors and return default if an exception occurs
  • deprecated(msg) → func — Print a warning when calling a deprecated function
  • lazy(fn) → func — Compute the value once and reuse it on subsequent calls

channel.zyx

  • new() → channel — Create a new channel
  • send(ch, value) → none — Send value into channel ch
  • recv(ch) → any — Receive a value from channel ch (blocks if empty)
  • is_empty(ch) → bool — Check if channel ch has no pending values

msgbox.zyx

  • alert(message, title) → none — Displays a simple alert box
  • confirm(message, title, buttons=["OK", "Cancel"]) → str/none — Displays a confirmation dialog and returns the button clicked, or none if the dialog is closed
  • prompt(message, title) → str/none — Prompts for text input and returns the entered string or none if canceled
  • password(message, title) → str/none — Prompts for a masked password and returns the entered string or none if canceled

csv.zyx

  • read(file_path) → list — Read CSV file at file_path and return header-keyed hashmap of column lists
  • write(file_path, data) → none — Write data to CSV file at file_path