Crates.io | binks |
lib.rs | binks |
version | 0.1.23 |
source | src |
created_at | 2020-08-08 18:03:53.532227 |
updated_at | 2020-08-14 11:19:00.446625 |
description | The binks scripting language |
homepage | |
repository | https://github.com/omrihhh/binks |
max_upload_size | |
id | 274406 |
size | 120,389 |
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
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")
}
requirements: rust, git
$ git clone https://github.com/omrihhh/binks.git
$ cd binks
$ cargo build --release
then add target\release to your path
requirements: rust
cargo install binks
$ binks <path> <stack size (2 by default)>
important features i want to implement for the language to be and feel more complete