58 releases (6 breaking)

0.9.18 Nov 7, 2024
0.9.14 Oct 23, 2024
0.9.1 Jul 3, 2024
0.7.3 Mar 22, 2024

#439 in Programming languages

Download history 1/week @ 2024-08-24 3/week @ 2024-08-31 297/week @ 2024-09-14 96/week @ 2024-09-21 456/week @ 2024-09-28 318/week @ 2024-10-05 857/week @ 2024-10-12 167/week @ 2024-10-19 18/week @ 2024-10-26 389/week @ 2024-11-02 90/week @ 2024-11-09 13/week @ 2024-11-16 2/week @ 2024-11-23

496 downloads per month
Used in mers

MIT/Apache

415KB
11K SLoC

mers-lib

The library behind mers.

With this, you can parse, compile, check and run mers code. You can also add your own functions and types which can then be used from mers, if you really want to.

Running mers

There are four steps to running mers code. The examples show you how to actually implement them, this readme only explains what they do any why.

1. Parsing

This first step converts the source code, a string, to a parsed mers statement.

In this step, syntax errors and unknown variables are caught.

2. Compiling

This converts a parsed mers statement to a compiled one. It almost never produces an error.

3. Checking

This step is optional. If you parse and compile your source code, you can (try to) run it. However, mers assumes that all mers code you run is actually valid, so if you don't check your codes validity, mers will probably panic while running your code.

This step performs all the type-checking and determines the output type of your code, if it is valid.

For example, the following code is valid and has the return type Int/Float:

my_condition := true

if my_condition {
  5
} else {
  1.4
}

4. Running

This step assumes that the code it is running is actually valid, so it never returns an error. As long as check didn't return an error in Step 3, it is safe to assume that this will return the value produced by the code. We can also assume that the return value has a type which is included in that determined by check. If check returned an error, this will likely panic.

Dependencies

~0–9.5MB
~41K SLoC