mini-lang

Crates.iomini-lang
lib.rsmini-lang
version0.1.2
sourcesrc
created_at2021-08-11 06:19:09.759434
updated_at2021-08-11 07:43:38.38513
descriptionA minimal, experimental language for lazy evaluation.
homepage
repositoryhttps://github.com/watcol/mini-lang
max_upload_size
id434606
size42,372
watcol (watcol)

documentation

README

Mini Language

A minimal, experimental language for lazy evaluation.

Syntax

These are the syntax for Mini Language. (Actually, the // comment is not allowed.)

Numerical Literal

print 42      // The integrer number
print -42     // Plus and Minus signs are allowed
print + 42   // and you can insert spaces between them.

Operations

// Arithmetic
print 3 + 2    // 5
print 3 - 2    // 1
print 3 * 2    // 6
print 28 / 5   // 5 (floored)
print 28 % 5   // 3

// Comparison
print 2 > 1    // 1 (true)
print 1 > 1    // 0 (false)
print 2 >= 1   // 1
print 1 >= 1   // 1
print 2 < 1    // 0
print 1 < 1    // 0
print 2 <= 1   // 0
print 1 <= 1   // 1

// Equal, Not equal
print 2 == 1   // 0
print 1 == 1   // 1
print 2 != 1   // 1
print 1 != 1   // 0

// Conditional branch
print if 3 > 2 \   // 5
  then 5 \
  else 0 \

Variables

let x = 5
let y = 3
print x + y   // 8

Functions

// The simple add function
def add(x, y) = x + y

// Recursive function
def fibo(n) = \
  if n <= 2 \
    then n \
    else fibo(n-2) + fibo(n-1)

print add(3, 2)   // 5
print fibo(10)    // 55

API

This language provides the rust library interface, and API documentations are available by docs.rs.

License

Cross Clip is licensed under the MIT license. See LICENSE for details.

Commit count: 24

cargo fmt