binks

Crates.iobinks
lib.rsbinks
version0.1.23
sourcesrc
created_at2020-08-08 18:03:53.532227
updated_at2020-08-14 11:19:00.446625
descriptionThe binks scripting language
homepage
repositoryhttps://github.com/omrihhh/binks
max_upload_size
id274406
size120,389
(omrihhh)

documentation

README

binks is an interpreted dynamically typed enbededd scripting language trying to be as simple as python and as clean looking as possible, written 100% in rust

Project info: Latest Version Rust 1.44+ required Build Status Maintenance GitHub license docs

Features

  • simple and clean syntax
  • embedded
  • easy types extension
  • easy dynamic libraries loading

Syntax

binks's syntax is inspired by Python, Rust and Dart.

variables are declared by the "let" keyword and can change their type throughout the program.

function are declared by the "fn" keyword followed by the name, the arguments in parenthesis and the code in to block that start with { end end with }

if/elif/else and while loop written with the keyword (if,elif...) followed by the boolean value (no need in parenthesis) and the code in a block that start with { end end with }

calling code from dynamic libraries is done by using the "extern" keyword followed by the path the function name and the argument it takes is this pattern: extern "path":"func":arg1,arg2,arg3

type extension is done by using the "extend" keyword followed by the type to extend and then all the functions you want to add in a block, all function need to have at least one argument and can be called with a method call syntax

use "binks:IO.binks" as Io

fn fib(n) {
    if n == 1 || n == 2 {
        return n - 1	
    }
    return fib(n - 1) + fib(n - 2)
}

Io.println(fib(5))

extend str {
    fn str_method(self) {
        self = ": )"
    }

    fn str_method_2(self) {
        if self == ": )" {
            self = "0_o"
        }
    }
}

let s = ": ("
s.str_method()
s.str_method_2()
Io.println(s)

let x = 10

if 1 + 3 > 3.6 {
    Io.println("if statement!")
}

while x > 0 {
    x = x - 1
    if x == 5 {
        continue
    }
    Io.print(x)
    Io.print(" ")
}

Io.print("\n")

class XCounter {
    fn XCounter(self, x) {
        self.x = x
    }
    fn print_x(self) {
        Io.println(self.x)
    }
    fn increment(self) {
        self.x = self.x + 1
    }
    
}

let o = new XCounter("hello")
o.print_x()
o.x.str_method()
o.print_x()

let o2 = new XCounter(1)
o2.increment()
o2.print_x()

if o < o2 {
    Io.println("false")
}

if o != o2 {
    Io.println("true")
}

if o > o2 {
    Io.println("false")
}

Installing

latest version:

requirements: rust, git

$ git clone https://github.com/omrihhh/binks.git
$ cd binks
$ cargo build --release

then add target\release to your path

stable:

requirements: rust

cargo install binks

Running

$ binks <path> <stack size (2 by default)> 

Try it online

The Binks playground

Next steps

important features i want to implement for the language to be and feel more complete

  • while loop
  • for loop
  • classes
  • more complex classes and objects
  • operator overloading
  • default/named function arguments
  • imports
  • syntactic sugar for index and update (array[1], array[0] = 1)
  • lambda functions
  • libstd
  • embedded
Commit count: 0

cargo fmt