frut_std

Crates.iofrut_std
lib.rsfrut_std
version0.0.4
created_at2025-10-29 15:00:54.051948+00
updated_at2025-11-06 10:56:09.509461+00
descriptionStandard library for the Frut language
homepage
repositoryhttps://github.com/BenimFurka/frut_std
max_upload_size
id1906758
size31,524
furka (BenimFurka)

documentation

README

Frut Standard Library

Crates.io License

Standard library for the Frut programming language. Provides built-in functions, native modules, and primitive-method helpers for use with the frut_lib analyzer and runtime.

Installation

Add this to your Cargo.toml:

[dependencies]
frut_std = "0.0.4"

Or use this comand:

cargo add frut_std

Features

  • Built-ins: print(string): void, println(string): void, input(string): string.
  • Native modules:
    • std/io: re-exports print, println, input.
    • std/math: abs_i(int): int, abs_d(double): double, min_i(int,int): int, min_d(double,double): double, max_i(int,int): int, max_d(double,double): double.
  • Primitive methods (runtime-dispatched):
    • string.len(): int, string.contains(string): bool
    • int.abs(): int, double.abs(): double
    • bool.to_int(): int

Umm

Hey, crate is not finished yet, but its working.

Quick start

Use with frut_lib by predeclaring built-ins for semantic analysis and registering native implementations in the runtime:

use frut_lib::{semantic::SemanticAnalyzer, value::RuntimeEnvironment};
use frut_std::{predeclare_std_builtins, register_std_builtins, register_native_modules};

fn setup() {
    // Semantic predeclare
    let mut analyzer = SemanticAnalyzer::default();
    predeclare_std_builtins(&mut analyzer).unwrap();

    // Runtime registration
    let mut env = RuntimeEnvironment::default();
    register_std_builtins(&mut env);

    // Optionally register specific native modules (or None to import all symbols)
    register_native_modules(
        &mut env,
        &[
            ("std/io".to_string(), None),
            ("std/math".to_string(), None),
        ],
    );
}

In Frut code you can import and use modules:

import std.io;
import std.math;

println("Hello, Frut!");
println("min: " + min_i(3, 5));

Try also frut_interp crate to run this code, that crate uses frut_std crate.

Documentation

See the Frut wiki for the standard library overview and usage:

License

Licensed under the Apache License, Version 2.0 LICENSE.

Commit count: 0

cargo fmt