8000 GitHub - scott-clare1/fuzz-lang: The fuzz-lang compiler
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

scott-clare1/fuzz-lang

Repository files navigation

fuzz-lang

A basic implementation of a compiler for fuzz-lang.

fuzz-lang is compiled (transpiled) to rust.

Prerequisites

What the fuck is fuzz-lang

fuzz-lang is a toy language used to help me understand how the "front-end" of a compiler works.

I got carried away and thought I'd add some weird things in.

Here's some fuzz-lang comments detailing the main rules of the language.

comment: `fuzzy` is an assignment statement - fuzz-lang is statically typed so all
comment: variables and function must be annotated.

comment: `labs` is a print statement

comment: `suzy` declares a function - functions can only receive a single input

comment: all functions must end with `flabs`

comment: to denote the types you must annotate the function with curly brackets
comment: showing how the input type transitioned to the output type.

comment: to create an array use the `array` type declare the data type the array should
comment: contain and the number of values then declare the identifier for the array.
comment: e.g., fuzzy array[int; 5] collection = [0, 1, 2, 3, 4];

comment: to then loop through an array use the keywords `every` and `from`.
comment: e.g., every item from collection { labs(item); }

Here's an example program to create an array of values and then square each value in the array:

comment: this program creates an array of 5 integers and then iterates through multiplying it by itself.

fuzzy array[int; 5] collection = [0, 1, 2, 3, 4];

every item from collection {
    fuzzy int item_squarred = item * item;
    labs(item_squarred);
}

Here's an example function to multiply a float by itself:

comment: this program creates a function `square` creates a value `result` using the function and then prints it out.

suzy square(a) {float -> float} {
  fuzzy float squarred = a * a;
  flabs squarred;
}

fuzzy float result = square(2.0);

labs(result);

How do I compile fuzz-lang?

Clone this repository and then run the following:

make fuzz-lang

Then start compiling fuzz to executables:

fuzzc examples/hello_world.fuzz hello_world

Execute program:

./hello_world

🏃 How do I get started?

You don't.

About

The fuzz-lang compiler

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0