varyk-syntax 0.0.2

Lexer, parser, and AST for the Varyk programming language
Documentation
  • Coverage
  • 23.9%
    65 out of 272 items documented0 out of 1 items with examples
  • Size
  • Source code size: 223.2 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.7 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Varyk-Lang/varyk
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • vlamic

Varyk

Varyk is an experimental programming language with Rust-like safety and Go-like simplicity, created by Vlad Mickevic.

Varyk exists to make Rust available to everyone.

Rust is one of the safest and fastest languages there is, and one of the hardest to learn. Its guarantees belong in every program, but its complexity keeps most people out. Varyk keeps what makes Rust strong: memory safety without a garbage collector, native speed, and the Rust ecosystem. It removes the complexity that stands between people and those benefits, whether they come from another language, are writing their first program, or are an AI agent writing code.

Varyk compiles to Rust and runs on the Rust ecosystem, the way TypeScript compiles to JavaScript. The Rust compiler checks everything Varyk generates, so the guarantees are Rust's own. Varyk code lives in .vr files, Rust code can live in .rs files next to them, and the two build together.

An example

examples/borrowing.vr:

struct User {
    name: string,
}

fn rename(mut user: User) {
    user.name = "Bob";
}

fn print_user(user: User) {
    println!("{}", user.name);
}

fn main() {
    let mut user = User {
        name: "Alice",
    };

    print_user(user);
    rename(user);
    print_user(user);
}

It prints Alice, then Bob. This is the Rust that Varyk generates for it (src/main.rs from varyk build --emit-rust examples/borrowing.vr):

#![allow(
    dead_code,
    unused_variables,
    unused_mut,
    arithmetic_overflow,
    unconditional_panic
)]

struct User {
    name: String,
}

fn rename(user: &mut User) {
    user.name = "Bob".to_string();
}

fn print_user(user: &User) {
    println!("{}", user.name);
}

fn main() {
    let mut user = User {
        name: "Alice".to_string(),
    };
    print_user(&user);
    rename(&mut user);
    print_user(&user);
}

The generated Rust is checked by the Rust compiler like any other Rust code. Varyk keeps Rust's safety model and adds no garbage collector.

Try it

You need a stable Rust toolchain installed through rustup. Varyk calls cargo to build your program.

Install the compiler from crates.io:

cargo install varyk
varyk run examples/hello.vr

Or build it from this repository and run the first example:

cargo build -p varyk
cargo run -p varyk -- run examples/hello.vr

The compiler has three commands:

varyk check <file.vr>    check the program for errors; never runs cargo
varyk build <file.vr>    generate Rust, build it, and print the path of the executable
varyk run <file.vr>      build, then run the program

build and run accept --release. build also accepts --emit-rust, which prints the generated Rust. Every command accepts --message-format=json, which prints errors as JSON, one object per line. When running from this repository, put cargo run -p varyk -- in front, as in the example above.

Status

Varyk is experimental and pre-0.1. Any syntax, error code, or command-line flag may change before a 0.1 release, which is not scheduled. This is milestone 2: the language core. Structs, enums, and match, for loops, methods, Option, Result, Vec, ?, and format! work; the compiler builds and runs the twelve programs in examples/, and it reports every error it knows about with a code, a plain-word message, and, where it can, a suggested fix. Packages, closures, iterators, and much more are not there yet; see docs/language.md for exactly what works.

Documents

License

Licensed under either of MIT or Apache-2.0, at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Trademark

The code is open source; the name is not. "Varyk" is a trademark of Vladislav Mickevic, and the licenses above do not grant rights to it. You may use the name to refer to the project, but a modified version or a fork needs a different name. See TRADEMARKS.md.