Rust-based interpreter for the Dreamberd (https://github.com/TodePond/DreamBerd) language

Overview

Dreamberd.rs

Rust-based interpreter for the Dreamberd language.

The full specification for Dreamberd is available at https://github.com/TodePond/DreamBerd. This file only contains the segments of the specification that are implemented in dreamberd-rs.

Statements

Every statement ends with an exclamation mark! If you're feeling extra, you can even use multiple!!!

print("Hello World!")!

print("Hi!!")!!!!

If you're unsure, that's okay too! You can also use question marks? This will print debug information to the console? The more question marks, the more detailed the information?

print("uh... hi??")???

Negation

You might be wondering what DreamBerd uses for its negation operator, since most languages use !. Don't worry! ; and - both negate the value in front of them.

;"hello there"? // "ereht olleh"
-true? // false
;1 // -1
-1 // -1

Declarations

There are four types of declarations. Constant constants can't be changed at all.

const const name = "Ava"!
name += "?"! // does nothing
name = "John"! // does nothing

Constant variables can be edited but not reassigned.

const var age = 1!
age += 1!
age? // 2

Variable constants can be reassigned but not edited.

var const id = "main"!
id = "no thank you"!
id? // "no thank you"

Variable variables can be reassigned and edited.

var var count = 0!
count += 1!
count = 2!

Types

DreamBerd is a weakly-typed language. However, type annotations can be added to declarations and functions.

var const name: String = "Gary"!
const var age: i32 = 22!

const const mul: Fn<i32, i32> = (lhs: i32, rhs: i32)->{
    lhs * rhs
}!
Technical Info

Type annotations don't actually do anything, but they help people feel more comfortable

Naming

Both variables and constants can be named with any Unicode character or string that isn't interpreted as another feature.

const const firstAlphabetLetter = 'A'!
var const 👍 = true!
var var 1️⃣ = 1!

This includes numbers, and other language constructs.

const const 5 = 4!
const const true = false!
2 + 2 ==== 5? // true
true ==== false? // true

Booleans

Booleans can be true, false, or maybe, as current events have shown that reducing complex facts to simple dichotomies can unhelpfully flatten nuance. All values in DreamBerd are thus either truthy, falsey, or maybeyey.

Numbers greater than or equal to one, non-empty strings, non-empty objects, and true are truthey.

Numbers less than or equal to zero, empty strings, empty objects, undefined, and false are falsey.

Numbers between 0 and 1, numbers that are not a number, keywords, functions, and maybe are maybeyey.

Strings

Strings can be declared with backticks, single quotes, double quotes, zero quotes, or even french quotes!

const const name: String = `Jeremy`!
const const name: String = 'Lu'!
const const name: String = "Luke"!
const const name: String = L!
const const name: String = «antoine»!

String Interpolation

Please remember to use your regional currency when interpolating strings.

const const name: String = "world"!
print("Hello ${name}!")!
print("Hello £{name}!")!
print("Hello ¥{name}!")!

Arithmetic

DreamBerd has significant whitespace. Use spacing to specify the order of arithmetic operations.

1 + 2*3? // 7
1+2 * 3? // 9

For operations with the same amount of whitespace, grouping is poorly defined.

1+1*1+1? // 4

You can add strings together and multiply them by numbers. Negating a string reverses it.

"he" + "l"*2 "o" + " " + "world"? // "hello world"
"johnny"*1.5? // "johnnyjoh"
"no lemon " + -"no lemon"? // "no lemon nomel on"

Dividing by Zero

Dividing by zero returns undefined.

3 / 0? // undefined

Equality

JavaScript lets you do different levels of comparison. == for loose comparison, and === for a more precise check. DreamBerd takes this to another level.

You can use === to do a loose check.

3.14 === "3.14"? // true

You can use ==== to do a more precise check.

3.14 ==== "3.14"? // false

You can use ===== to be EVEN MORE precise!

const const pi = 3.14!
pi ===== pi? // true
3.14 ===== 3.14? // false (this differs from the official DreamBerd specification)
3.14 ===== pi? // false

Finally, if you want to be much less precise, you can use ==.

3 == 3.14? // true
🥧 == 22/7? // true

Functions

To declare a function, you can use any letters from the word function (as long as they're in order):

function(add, (a, b),  (a + b))!
func(multiply, (a, b), (a * b))!
fun(subtract, (a, b), (a - b))!
fn(divide, (a, b), (a / b))!
functi(power, (a, b), (a ** b))!
union(inverse, (a), (1/a))!

Alternatively, you can use the arrow syntax

const const does_she_really_like_you = ()->{maybe}!

Delete

To avoid confusion, the delete statement only works with identifiers like variables, numbers, strings, and booleans.

delete(3)!
2+1 === 3? // false

DreamBerd is a multi-paradigm programming language, which means that you can delete the keywords and paradigms you don't like.

delete(maybe)!!!
const const is_raining = maybe!
is_raining? // undefined

When perfection is achieved and there is nothing left to delete, you can do this:

delete(delete)!

Objects

To create an object, start with the empty object and add values to it.

const var my_object = {}!
my_object.name = "Samuel"!

You can also set the call keyword to a function, which can use the self keyword to access attributes of the class.

my_object.call = ()->{"hello, my name is "+self.name?}!

Zero-Abstraction Abstractions

Lots of popular languages use so-called "zero-cost abstractions". DreamBerd instead has zero-abstraction abstractions, which are features that provide runtime costs for little-to-no utility.

Signals

To use a signal, use use.

const var score = use(0)!

In DreamBerd, you can set (and get) signals with just one function:

const var score = use(0)!

score(9)! // Set the value
score()? // Get the value (and print it)

Standard Library

Dreamberd has a fast-growing standard library. Due to the limitations of the file system, it must be copied and pasted into every file that uses it.

const const use: Fn<T> = (v: T) -> {
    var var o = {}!
    o.call = (v: T)->{
        var var r: T = self.value!
        if(;(v====undefined),
            self.value=v!
        )!
        r
    }!
    o.value: T = v!
    o
}!

const const print: Fn<String> = (t: String) -> {t?}!

const const str: Fn<T> = (t: T)->{`${t}`}!
Comments
  • Feature: Types

    Feature: Types

    Types

    Type annotations are optional.

    const var age: Int = 28!
    

    By the way, strings are just arrays of characters.

    String == Char[]!
    

    Similarly, integers are just arrays of digits.

    Int == Digit[]!
    

    If you want to use a binary representation for integers, Int9 and Int99 types are also available.

    const var age: Int9 = 28!
    
    feature 
    opened by PokeJofeJr4th 1
  • Zero-Abstraction Abstractions

    Zero-Abstraction Abstractions

    People love talking about Zero-Cost Abstractions, but what about these? Includes use and type annotations; for an additional runtime cost, get syntactic "sugar" - come up with a funny synonym for "sugar"

    suggestion 
    opened by PokeJofeJr4th 0
  • Assignment is Pretty Broken

    Assignment is Pretty Broken

    variable = "hello there since the variable thing returns a cloned Pointer, reassignment doesn't propagate up to the actual state. I don't know how to do this without either rewriting a bunch of code or breaking stuff

    bug 
    opened by PokeJofeJr4th 0
  • Feature: Signals

    Feature: Signals

    Signals

    To use a signal, use use.

    const var score = use(0)!
    

    When it comes to signals, the most important thing to discuss is syntax.

    In DreamBerd, you can set (and get) signals with just one function:

    const var score = use(0)!
    
    score(9)! // Set the value
    score()?  // Get the value (and print it)
    

    Alternatively, you can be more explicit with your signal syntax, by splitting it into a getter and setter.

    const var [getScore, setScore] = use(0)!
    
    setScore(9)! // Set the value
    getScore()?  // Get the value (and print it)
    

    Technical info: This is pure syntax sugar. The split signal functions are exactly the same as before.

    const var [getScore, setScore] = use(0)!
    
    getScore(9)! // Set the value
    setScore()?  // Get the value (and print it)
    

    This means that you can carry on splitting as much as you like.

    const var [[[getScore, setScore], setScore], setScore] = use(0)!
    
    feature 
    opened by PokeJofeJr4th 0
  • Ternary Operator

    Ternary Operator

    condition ~? is_true ~; isnt_true ~: is_maybe
    
    condition ~? is_true ~; is_false!
    condition ~? is_true ~~ is_maybe!
    condition ~; is_false ~~ is_maybe!
    
    condition ???
        :: if_true
        ::: if_false
        :::: if_maybe
    
    suggestion 
    opened by PokeJofeJr4th 0
  • Feature: Async

    Feature: Async

    Asynchronous Functions

    Asynchronous functions synchronise with each other. They take turns running lines of code.

    async funct count() {
       print(2)!
       print(4)!
    }
    
    count()!
    print(1)!
    print(3)!
    print(5)!
    

    You can use the noop keyword to wait for longer before taking your turn.

    async func count() {
       print(2)!
       noop!
       print(5)!
    }
    
    count()!
    print(1)!
    print(3)!
    print(4)!
    

    Note: In the program above, the computer interprets noop as a string and its sole purpose is to take up an extra line. You can use any string you want.

    feature 
    opened by PokeJofeJr4th 0
  • Feature: DBX

    Feature: DBX

    DBX

    You can embed DBX in DreamBerd. It's just DreamBerd, and it's also just HTML.

    funct App() => {
       return <div>Hello world!</div>
    }
    

    Warning: As you know, class is already a keyword in DreamBerd, so you can't use it within DBX.

    funct App() => {
       // This is not ok
       return <div class="greeting">Hello world!</div>
    }
    

    className is also a DreamBerd keyword, so you can't use that either.

    funct App() => {
       // This is also not ok
       return <div className="greeting">Hello world!</div>
    }
    

    Instead, you can use the htmlClassName attribute.

    funct App() => {
       // This is fine
       return <div htmlClassName="greeting">Hello world!</div>
    }
    

    Please note: Unlike JSX, you are free to freely use the for attribute - because DreamBerd doesn't have loops.

    funct App() => {
       return (
          <label for="name">Name</label>
          <input id="name" />
       )
    }
    
    feature 
    opened by PokeJofeJr4th 0
  • Feature: Classes

    Feature: Classes

    Classes

    You can make classes, but you can only ever make one instance of them. This shouldn't affect how most object-oriented programmers work.

    class Player {
       const var health = 10!
    }
    
    const var player1 = new Player()!
    const var player2 = new Player()! //Error: Can't have more than one 'Player' instance!
    

    This is how you could do this:

    class PlayerMaker {
       function makePlayer() => {
          class Player {
             const var health = 10!
          }
          const const player = new Player()!
          return player!
       }
    }
    
    const const playerMaker = new PlayerMaker()!
    const var player1 = playerMaker.makePlayer()!
    const var player2 = playerMaker.makePlayer()!
    

    Class Names

    For maximum compatibility with other languages, you can alternatively use the className keyword when making classes.

    This makes things less complicated.

    className Player {
       const var health = 10!
    }
    

    In response to some recent criticism about this design decision, we would like to remind you that this is part of the JavaScript specification, and therefore - out of our control.

    feature 
    opened by PokeJofeJr4th 0
  • Feature: Files

    Feature: Files

    File Structure

    Write five or more equals signs to start a new file. This removes the need for multiple files or any build process.

    const const score = 5!
    print(score)! //5
    
    =====================
    
    const const score = 3!
    print(score)! //3
    

    New for 2022!
    Thanks to recent advances in technology, you can now give files names.

    ======= add.db =======
    function add(a, b) => {
       return a + b!
    }
    

    Exporting

    Many languages allow you to import things from specific files. In DreamBerd, importing is simpler. Instead, you export to specific files!

    ===== add.db ==
    function add(a, b) => {
       return a + b!
    }
    
    export add to "main.db"!
    
    ===== main.db ==
    import add!
    add(3, 2)!
    
    feature 
    opened by PokeJofeJr4th 0
Owner
null
Rust port of https://github.com/hunar4321/life_code with some fun features.

Smarticles A Rust port of Brainxyz's Artificial Life simulator with some fun features. A simple program to simulate primitive Artificial Life using si

Chevy Ray Johnston 15 Dec 24, 2022
ARCHIVED -- moved into the main Embassy repo at https://github.com/embassy-rs/embassy

ARCHIVED - moved into the main Embassy repo https://github.com/embassy-rs/embassy cyw43 WIP driver for the CYW43439 wifi chip, used in the Raspberry P

null 245 Jun 27, 2023
A BASIC language interpreter. Does not conform to existing standards. Mostly a toy.

JW-Basic A toy language that is somewhat like QBasic. Features: Graphics: 160x96 (255 colors & transparent) Text: 32x16 (4x5 font) Character set: ASCI

John Wells 8 Feb 15, 2023
An interpreter and compiler for the Brainfuck language.

Brainrust ?? An interpreter and compiler for the Brainfuck language. Prerequisites You need a LLVM 16.0.* installation on your system. On Windows, you

Michael Gerhold 4 Nov 4, 2023
A Typescript interpreter in Rust.

typescript This is a Rust native implementation of a Typescript Parser and a JIT execution engine. This project comes in two crates: [typescript-ast]:

Arne Simon 4 Oct 31, 2022
A fast, powerful, and safe interpreter written in rust!

Kraber A fast, powerful, and safe programming language written in rust! About It packs a punch like the Kraber .50-Cal. Kraber is designed to be minim

Int Fract 3 Mar 24, 2024
☃️ Learning Rust with AoC 2021 🎄https://adventofcode.com/2021/

?? Andrei's 2021 Advent of Code ?? Learning Goals Rust basics (vectors, arrays, math, etc.) Rust basic CLI Rust linear algebra and ndarrays (e.g., htt

Andrei Bârsan 1 Feb 2, 2022
Rust wrapper for gphoto2 (mirror of https://git.maxicarlos.de/maxicarlos08/gphoto2-rs)

GPhoto2-rs Rust bindings to libgphoto2 What about gphoto-rs? I know about the other crate (gphoto and gphoto2-sys which was created by @dcuddeback, bu

Maxicarlos08 14 Dec 29, 2022
Mirror of https://gitlab.redox-os.org/redox-os/termion

Documentation Examples Changelog Tutorial Termion is a pure Rust, bindless library for low-level handling, manipulating and reading information about

Redox OS 1.9k Dec 31, 2022
Code examples for https://www.poor.dev/blog/terminal-anatomy/

This repository contains examples from the Anatomy of a Terminal Emulator blog post. Each folder contains a separate example and can be run separately

Aram Drevekenin 28 Dec 7, 2022
A wrapper around the code action dump from https://mcdiamondfire.com.

DiamondFire Action Dump for Rust A wrapper around the code action dump from https://mcdiamondfire.com. This currently only provides schema types for u

null 3 Sep 17, 2022
https://adventofcode.com/2022/

Advent of Code 2022 This repository contains my solutions for Advent of Code 2022. Goal is readable, simple and mostly clean. Each day is solved in it

Guillaume P. 3 Dec 15, 2022
Simple Secure Static (HTTPS) File Server with embedded certificate

Secure Static File Server Static Files HTTPs server with self signed embedded certificate Installation Install using cargo: cargo install ssfs Or buil

0xor0ne 21 Apr 20, 2023
rust-rustlings-2023-autumn-CAIMEOX created by GitHub Classroom

2023秋冬季操作系统训练营 第一阶段训练安排 rustlings Rust编程训练教室 rustlings ??❤️ Greetings and welcome to rustlings. This project contains small exercises to get you used

The Learning&Training Hub of OS Kernel 2 Oct 31, 2023
Download binary for your OS from Github

github-bin-downloader Download binary for your OS from Github. Installation Install github-bin-downloader using cargo cargo install github-bin-downloa

353fc443 10 Dec 11, 2022
A cli tool to download specific GitHub directories or files

cloneit A cli tool to download specific GitHub directories or files. Installation From git git clone https://github.com/alok8bb/cloneit cd cloneit car

Alok 54 Dec 20, 2022
Github user information on terminal :D

octofetch Use this if youre too lazy to open github lol Installation Local install with cargo Run cargo install --git https://github.com/azur1s/octofe

Natapat Samutpong 65 Nov 2, 2022
❗️ Small script to view GitHub notifications in the terminal

github-notifications Small script to view GitHub notifications in the terminal Shows and color-codes the notification source, eg if you're the owner o

Brian Shaginaw 1 Jan 10, 2022
A command-line tool and Docker image to automatically backup Git repositories from GitHub or anywhere

A command-line tool and Docker image to automatically backup Git repositories from GitHub or anywhere

Jake Wharton 256 Dec 27, 2022