Extending the Monkey (programming) Lang from

Overview

๐Ÿˆ Mellang ๐Ÿˆ

Mellang, an interpreted programming language

Mellang VSCode Extension

You can download it on https://marketplace.visualstudio.com/items?itemName=Mello.mellang


Mellang can do almost anything that a basic programming language does:

Types

Mellang has the following data types: null, bool, int, str, array, hash,fn and a "strange" float

Type Syntax
null null
bool true false
int 0 24 1654 -10
str "blablabla string here"
array [] [1, 2] [1, 2, 3]
hash {} {"a": 1} {"a": 1, "b": 2}
float 1.6 1.6324 215.16

Variable Bindings

You can use 'moonvar (var) = (expression)' or just '(var) <- (expression)'

moonvar myVar = 5
anotherVar <- 5 

Arithmetic Expressions

>> myVar <- 10
>> moonvar anotherVar <- myVar * 2
>> (myVar + anotherVar) / 2 - 3
12

OwO Operators

moonvar funcOne = fn(x){x *10}

moonvar TEST = fn(x){x * 2}

moonvar ac = OwO 10 ~> funcOne ~> TEST ~> funcOne ~> funcOne ~> funcOne
(10 * 10 * 2 * 10 * 10 * 10)

>> ac
> 200000

moonvar myList = [1,2,3,4,5]

moonvar sumList = fn(list){map(list, TestTWO)}

OwO myList ~> sumList ~> sumList;
>[5,6,7,8,9]

moonvar elixirLike = OwO "Eae Beleza" ~> String_Upcase ~> String_Split;
>[EAE, BELEZA?]


Conditional Expressions

Mellang supports if and else:

>> a <- 10
>> b <- a * 2
>> c <- if (b > a) { 99 } else { 100 }
>> c
> 99

>> a <- 10
>> b <- 10
>> c <- if (b >= a) { 99 } else { 100 }
>> c
> 99

Installation

TODO

Usage example

Variable Declaration

moonvar myVariable = 5
moonvar myFunction = fn(x){x + 1}
moonvar myHash = {"name": "myName", "otherName : "randomName"}
moonvar myList = [1,3,4,5, fn(x){x + 1}]

myList[4](5)
> 6

myHash["name"]
>myName

map([1,2,3,4],fn(x){x * 2})
>[2,4,6,8]

sum(map([1,2,3,4],fn(x){x * 2}))
>20

While Loops

Mellang supports only one looping construct, the while loop:

x <- 3
myList <- [1,2,3,4,5]

while (x > 0) {
 myList <- map(myList,fn(x){x * 2}) 
 plsShow(myList) 
 x <- x - 1
}

// [2,4,6,8,10]
// [4,8,12,16,20]
// [8,16,24,32,40]

Functions and Closures

You can define named or anonymous functions, including functions inside functions that reference outer variables (closures).

>> moonvar multiply = fn(x, y) { x * y }
>> multiply(50 / 2, 1 * 2)
50
>> fn(x) { x + 10 }(10)
20
>> moonvar newAdder = fn(x) { fn(y) { x + y } }
>> moonvar addTwo = newAdder(2)
>> addTwo(3)
5
>> moonvar sub = fn(a, b) { a - b }
>> moonvar applyFunc = fn(a, b, func) { func(a, b) }
>> applyFunc(10, 2, sub)
8

Recursive Functions

Monkey also supports recursive functions including recursive functions defined in the scope of another function (self-recursion).

>> moonvar wrapper = fn() { moonvar inner = fn(x) { if (x == 0) { return 2 } else { return inner(x - 1) } } return inner(1) }
>> wrapper()
2


>> fib <- fn(n, a, b) { if (n == 0) { return a } if (n == 1) { return b } return fib(n - 1, b, a + b) }
>> fib(35, 0, 1)
9227465

Strings

>> makeGreeter <- fn(greeting) { fn(name) { greeting + " " + name + "!" } }
>> hello <- makeGreeter("Hello")
>> hello("mellum")
Hello mellum!

Arrays

>> myArray := ["Thorsten", "Ball", 28, fn(x) { x * x }]
>> myArray[0]
Thorsten
>> myArray[4 - 2]
28
>> myArray[3](2)
4

Hashes

>> myHash := {"name": "Jimmy", "age": 72, true: "yes, a boolean", 99: "correct, an integer"}
>> myHash["name"]
Jimmy
>> myHash["age"]
72
>> myHash[true]
yes, a boolean
>> myHash[99]
correct, an integer

Builtin functions

  • len(iterable) Returns the length of the iterable (str, array or hash).
  • first(iterable) Returns the first element of the array.
  • last(iterable) Returns the last element of the array.
  • push(iterable) Add an element to the array.
  • replace(string,element_to_replace,element_to_put) Replace something inside a string.
  • plsShow(element) Print something in the screen.
  • Strcomp(string,string) Compare the pointers of two strings.
  • String_Upcase(string) Upcase an entire string.
  • String_Split(string) Split a string into array

Development setup

After dowloading the Mellang VSCode Extension, you have to create a ".mel" file on the root of the project and specify the filename after running the "main.go".

Meta

Antonio Mello Babo โ€“ @MelloTonio

It was inspired by the monkey language of the book "writing an interpreter in go - thorsten ball"

Issues
  • Division by zero isn't handled

    Division by zero isn't handled

    Probably worth catching this, and returning an error:

    wc41 ~/Mellang $ ./Andrei_lang 
    Hello steve! This is the Andrei programming language!
    Feel free to type in commands
    >> plsShow( 3 / 0 );
    panic: runtime error: integer divide by zero
    
    goroutine 1 [running]:
    github.com/Mellotonio/Andrei_lang/Evaluator.evalIntegerInfixExpression(0xc000016300, 0x1, 0x50bfc0, 0xc000016320, 0x50bfc0, 0xc000016328, 0xe, 0x7f0089947108)
    	/home/steve/Mellang/Evaluator/evaluator.go:221 +0x558
    github.com/Mellotonio/Andrei_lang/Evaluator.evalInfixExpression(0xc000016300, 0x1, 0x50bfc0, 0xc000016320, 0x50bfc0, 0xc000016328, 0xc00007e670, 0x1)
    
    opened by skx 3
Owner
Antonio Mello Babo
PUCSP - Computer Science - Studying Javascript, Elixir and Go
Antonio Mello Babo
EGo lets you build, debug und run Go apps on Intel SGX - as simple as conventional Go programming!

EGo lets you build, debug und run Go apps on Intel SGX - as simple as conventional Go programming!

Edgeless Systems GmbH 322 Aug 1, 2022
libraries for various programming languages that make it easy to generate per-process trace files that can be loaded into chrome://tracing

chrometracing: chrome://tracing trace_event files The chrometracing directory contains libraries for various programming languages that make it easy t

Google 22 Jul 8, 2022
This is an open source project for commonly used functions for the Go programming language.

Common Functions This is an open source project for commonly used functions for the Go programming language. This package need >= go 1.3 Code Conventi

แดœษดแด‹ษดแดกแดษด 733 Aug 2, 2022
Rest Api Generator for Golang Programming Language

Rest Api Generator for Golang Programming Language

Eko Kurniadi 3 Nov 29, 2021
Go Library for Competitive Programming with Generics

Go Library for Competitive Programming with Generics Go used to be a difficult language to use for competitive programming. However, with the introduc

Katsuyuki Tateishi 2 Apr 19, 2022
Utilities and immutable collections for functional programming in Golang

Utilities and immutable collections for functional programming in Golang. This is an experimental library to play with the new Generics Feature in Go 1.18.

Peter Zeller 8 May 20, 2022
Tugas Alta Immersive Backend Golang Fundamental Programming (Pointer, Struct, Method, Interface)

Tatacara Melakukan Setup Tugas clone project ini dengan cara git clone https://github.com/Immersive-Backend-Resource/Pointer-Struct-Method-Interface.g

null 0 Jan 9, 2022
Monkey programming language project from 'Writing An Interpreter In Go'and 'Writing A Compiler In Go' Books

Monkey Monkey programming language ?? project from "Writing An Interpreter In Go

Amr Hesham 1 Dec 16, 2021
Trying to build an Ecommerce Microservice in Golang and Will try to make it Cloud Native - Learning Example extending the project of Nic Jackson

Golang Server Project Best Practices Dependency Injection :- In simple words, we want our functions and packages to receive the objects they depend on

Ujjwal Sharma 24 Jul 29, 2022
Support for extending Argo CD

Argo CD Extensions To enable Extensions for your Argo CD cluster will require just a single kubectl apply. Here we provide a way to extend Argo CD suc

argoproj-labs 47 Aug 8, 2022
OpenYurt - Extending your native Kubernetes to edge(project under CNCF)

openyurtio/openyurt English | ็ฎ€ไฝ“ไธญๆ–‡ What is NEW! Latest Release: September 26th, 2021. OpenYurt v0.5.0. Please check the CHANGELOG for details. First R

OpenYurt 1.3k Aug 11, 2022
Console - Commands are defined in struct extending pkg/command/create user.go

Console Creating a Command Commands are defined in struct extending pkg/command/

null 0 Jan 2, 2022
Monkey patching in Go

Go monkeypatching ?? ?? Actual arbitrary monkeypatching for Go. Yes really. Read this blogpost for an explanation on how it works: https://bou.ke/blog

Bouke van der Bijl 2.9k Aug 8, 2022
gomonkey is a library to make monkey patching in unit tests easy

gomonkey is a library to make monkey patching in unit tests easy, and the core idea of monkey patching comes from Bouke, you can read this blogpost for an explanation on how it works.

Zhang Xiaolong 1.2k Aug 12, 2022
Monkey-go - Writing An Interpreter In Golang

monkey-go Learning how to write an Interpreter called Monkey using Go! If you're

Saad Guessous 3 Jun 12, 2022
based on go lang build WEB development framework for go lang beginners .

based on go lang build WEB development framework for go lang beginners .

zhenfan.yu 1 Oct 31, 2021
Pineapple Lang is a simple programming language demo implements by Go

Pineapple Lang is a simple programming language demo implements by Go. It includes a hand-written recursive descent parser and a simple interpreter, although the language is not even Turing-complete. But this repo's main goal is to give beginners of compilation principles a warm up and a simple look at how a programming language is built.

karminski-็‰™ๅŒป 232 Jul 12, 2022
Source code for the Container-lang programming language

Container-lang Container-lang is a lightweight, interpreted, esoteric scripting language based on the idea of "code containers", aiming to make it eas

null 11 Jan 21, 2022
Floppa programming language inspired by the brainf*ck programming language. Created just for fun and you can convert your brainf*ck code to floppa code.

Floppa Programming Language Created just for fun. But if you want to contribute, why not? Floppa p.l. inspired by the brainf*ck programming language.

null 18 Apr 26, 2022
T# Programming Language. Something like Porth, Forth but written in Go. Stack-oriented programming language.

The T# Programming Language WARNING! THIS LANGUAGE IS A WORK IN PROGRESS! ANYTHING CAN CHANGE AT ANY MOMENT WITHOUT ANY NOTICE! Something like Forth a

T# 92 Jun 29, 2022
Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

Advent of Code 2021 Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved

Kemal Ogun Isik 0 Dec 2, 2021
Yayx programming language is begginer friendly programming language.

Yayx Yayx programming language is begginer friendly programming language. What have yayx: Easy syntax Dynamic types Can be compiled to outhers program

null 1 Dec 27, 2021
Yayx programming language is begginer friendly programming language.

Yayx Yayx programming language is begginer friendly programming language. What have yayx: Easy syntax Dynamic types Can be compiled to outhers program

Yayx Programming Language 7 May 20, 2022
Zach Howell 0 Jan 4, 2022
Go (lang) HTTP session authentication

Go Session Authentication See git tags/releases for information about potentially breaking change. This package uses the Gorilla web toolkit's session

Cameron Little 221 Apr 7, 2022
Set is a useful collection but there is no built-in implementation in Go lang.

goset Set is a useful collection but there is no built-in implementation in Go lang. Why? The only one pkg which provides set operations now is golang

zoumo 49 Aug 2, 2022
Neo4j Rest API Client for Go lang

neo4j.go Implementation of client package for communication with Neo4j Rest API. For more information and documentation please read Godoc Neo4j Page s

Cihangir 27 Jan 26, 2022
Small TCP benchmarking tool in Go-lang

Simple TCP benchmark tool in Go =============================== This package provides simple command line tool to benchmark number of concurrent TCP

Kris Kovalik 14 Aug 16, 2021
A Statsd implementation written in GO lang

statsgod Statsgod is a metric aggregation service inspired by the statsd project. Written in Golang, it increases performance and can be deployed with

Acquia 121 Dec 30, 2020