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 easy to create reusable code for one/many line scripts. Container-lang currently only supports numerical data-types, including integers and floats. String support is unlikely to be added in the future.

Usage

Prebuilt interpreter files are available on the GitHub page.

To run an Container-lang file (.cnl extension), open a command prompt and type container-lang -f [PATH_TO_FILE].

To build from source, clone the Git repo using git clone https://github.com/odddollar/Container-lang.git, then run go build Container-lang.

Code containers

Code containers are the same as a line in other languages, however have a numerical ID that allows them to be referenced later, meaning the same container can be used many times. Additionally, containers can be placed sequentially on one line, allowing for whole programs to be written on one line.

A container is created with the syntax {UNIQUE_NUMERICAL_ID|CODE}. All code is required to be placed in a container.

Containers are executed from left to right, then top to bottom.

E.g.

{ 1 |x <- 10}{2|y <- 11}{ 3|z <- 56}
{4 |i<- 20}

is exactly the same as

{1|x <- 10}
{2|y <- 11}
{3|z <- 56}
{4|i <- 20}

Language reference

Comments

Due to the way the interpreter splits the input file into code containers, any text not within a container will be treated as a comment and thus be ignored by the interpreter.

E.g.

{1|x <- 10}
{2|PRINTLN 5}{3| PRINTLN 10}
This is a comment
{4|mult<- x*22}
{1|x <- 10}{2|PRINTLN 5}{3| PRINTLN 10}This is also a valid comment{4|mult<- x*22}

Variables

Much like other languages, variables are "boxes" that store a value for later referencing. These values can be updated at any time. However, unlike other languages that use the = symbol to assign values, Container-lang uses the arrow symbol, <-.

All variables are global (E.g. those in a block can be accessed by those not in a block and vice versa).

E.g.

This will assign the value 1 to the variable "x"
{1|x<-1}

Mathematical operations can also be performed on variables using this same method.

E.g.

{1|x <- 1}
{2|PRINTLN x}
{3|x <- x+1}
{4|PRINTLN x}

Blocks

Blocks allow for the grouping together of other containers to be executed later. They're very similar to functions in other programming languages, however they don't accept parsing in arguments. Blocks can be placed inside other blocks.

Blocks use the syntax BLOCK [NUMBER_OF_CONTAINERS_TO_GROUP], where the number of containers argument states the next x number of containers to put in the block.

Similarly to functions, blocks won't be run until they're called. Blocks can be run/called using the EXECUTE function (continue reading) and the block container's ID, which will run all the containers contained within that block.

Blocks are incredibly useful for creating chunks of code that can be reused many times.

NOTE: Blocks must be defined before they can be called.

TIP: While not necessary, it makes reading a program so much easier if you indent the containers contained within a block. This whitespace is ignored by the interpreter.

E.g.

This will create a block with an ID of 1 that contains the next 2 containers
{1|BLOCK 2}
	{2|PRINTLN 10}
	{3|PRINTLN 11}
To run this block, use the EXECUTE function
{4|EXECUTE 1}
{1|PRINTLN 1}
{2|BLOCK 2}
	{3|PRINTLN 10}
	{4|PRINTLN 11}
{5|PRINTLN 2}
{6|EXECUTE 2}
This will print
"1
2
10
11"

Containers within a block can't be executed by containers outside the block.

E.g.

This will result in a "No container with specified ID" error
{1|BLOCK 2}
	{2|PRINTLN 10}
	{3|PRINTLN 11}
{4|EXECUTE 2}

Blocks can contain other blocks. This can lead to some interesting nested containers scenarios.

E.g.

This will print
"36
70
1
10
11
12"
{1|BLOCK 8}
	{2|BLOCK 2}
		{3|PRINTLN 10}
		{4|PRINTLN 11}
	{5|PRINTLN 1}
	{8|BLOCK 1}
		{9|PRINTLN 12}
	{11|EXECUTE 2}
	{12|EXECUTE 8}
{6|PRINTLN 36}
{7|PRINTLN 70}
{10|EXECUTE 1}

Repeat

The repeat function is similar to a for loop in other languages, it repeats the given code a set number of times.

It uses the syntax REPEAT [CONTAINER_ID_TO_REPEAT], [NUMBER_OF_TIMES_TO_REPEAT].

The repeat function implicitly creates a variable that keeps track of its current iteration status, named i[CONTAINER_ID_OF_REPEAT], E.g. A repeat container with an ID of 3 will implicitly create an iterator variable called i3.

It is not recommended to write to these variables, it can cause some weird situations, however it is possible.

E.g.

This will print 
"10
10
10"
{1|BLOCK 1}
	{2|PRINTLN 10}
{3|REPEAT 1, 3}

In the above example, the print function is encased in a block to prevent it running by default. If the print wasn't in a block, 10 would be printed 4 times.

This will print
"1
1
1
1
1
1"
{1|BLOCK 3}
	{2|BLOCK 1}
		{3|PRINTLN 1}
	{4|REPEAT 2, 3}
{5|REPEAT 1, 2}

Below is an example of the implicitly created iteration variable.

{1|BLOCK 1}
	{2|PRINTLN i3}
{3|REPEAT 1, 5}

If

If statements exist as they would in any other language, with a condition, code that runs if the condition is true and optional code that runs if the condition is false.

If statements use the syntax IF [CONDITION], [CONTAINER_ID_TO_RUN_IF_TRUE], [CONTAINER_ID_TO_RUN_IF_FALSE (Optional)].

E.g.

{1|BLOCK 1}
	{2|PRINTLN 10}
{3|BLOCK 1}
	{4|PRINTLN 20}
{5|x <- 1}
{6|IF x>11, 1, 3}

The print functions are wrapped in blocks to prevent them from running by default, only executing when called by the if statement.

Execute function

The execute function to used to execute another container by its ID. This is one of the most powerful functions in the language as it allows for the reuse of containers as many times as required.

The syntax used is EXECUTE [ID_OF_CONTAINER_TO_EXECUTE] inside of a container.

E.g.

This will execute the code in the container with ID 1
{2|EXECUTE 1}
This will print 
"10
10
10"
{1|PRINTLN 10}
{2|EXECUTE 1}
{3|EXECUTE 1}

Execute functions can also be used to run other execute functions.

E.g.

This will print 
"10
10
10"
{1|PRINTLN 10}
{2|EXECUTE 1}
{3|EXECUTE 2}

Print function

The print function is called using the syntax PRINT [VALUE_TO_PRINT] or PRINTLN [VALUE_TO_PRINT]inside of a container and is used to display text in the console.

PRINT doesn't add a newline character, PRINTLN does.

To print a blank character (E.g. a space), provide BLANK as an argument for PRINT or PRINTLN.

E.g.

This will print "10" to the console
{1|PRINTLN 10}
This will print "999" to the console
{2|PRINTLN 999}

Variables can be printed by placing the variable name as the argument, as well as expressions involving variables.

E.g.

{1|x <- 1}
{2|PRINTLN x}
{3|PRINTLN x+2}

Examples

Basic 4 bit binary counter

{10|BLOCK 10}
	{7|BLOCK 8}
		{1|BLOCK 6}
			{2|BLOCK 4}
				{12|PRINT i11}
				{9|PRINT i8}
				{3|PRINT i6}
				{4|PRINTLN i5}
			{5|REPEAT 2, 2}
		{6|REPEAT 1, 2}
	{8|REPEAT 7, 2}
{11|REPEAT 10, 2}

Find factors of 2000000

{6|num <- 2000000}
{1|BLOCK 3}
    {4|BLOCK 1}
        {5|PRINTLN i2}
    {3|IF num%i2==0, 4}
{2|REPEAT 1, num+1}
Similar Resources

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. This repository holds my submission/answers for these challenges.

Advent of Code - Zach Howell's Answers Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels

Jan 4, 2022

🐶 Automated code review tool integrated with any code analysis tools regardless of programming language

🐶 Automated code review tool integrated with any code analysis tools regardless of programming language

reviewdog - A code review dog who keeps your codebase healthy. reviewdog provides a way to post review comments to code hosting service, such as GitHu

Jan 2, 2023

🐶 Automated code review tool integrated with any code analysis tools regardless of programming language

🐶 Automated code review tool integrated with any code analysis tools regardless of programming language

reviewdog - A code review dog who keeps your codebase healthy. reviewdog provides a way to post review comments to code hosting service, such as GitHu

Jan 7, 2023

🛠 A full-featured dependency injection container for go programming language.

DI Dependency injection for Go programming language. Tutorial | Examples | Advanced features Dependency injection is one form of the broader technique

Dec 31, 2022

Agent-less vulnerability scanner for Linux, FreeBSD, Container, WordPress, Programming language libraries, Network devices

Agent-less vulnerability scanner for Linux, FreeBSD, Container, WordPress, Programming language libraries, Network devices

Vuls: VULnerability Scanner Vulnerability scanner for Linux/FreeBSD, agent-less, written in Go. We have a slack team. Join slack team Twitter: @vuls_e

Jan 9, 2023

:triangular_ruler:gofmtmd formats go source code block in Markdown. detects fenced code & formats code using gofmt.

:triangular_ruler:gofmtmd formats go source code block in Markdown. detects fenced code & formats code using gofmt.

gofmtmd gofmtmd formats go source code block in Markdown. detects fenced code & formats code using gofmt. Installation $ go get github.com/po3rin/gofm

Oct 31, 2022

Extending the Monkey (programming) Lang from

🍈 Mellang 🍈 Mellang, an interpreted programming language Mellang VSCode Extension You can download it on https://marketplace.visualstudio.com/items?

May 20, 2022

Go(lang) client library for Cachet (open source status page system).

cachet Go(lang) client library for Cachet (open source status page system). Features Full API support Components Incidents Metrics Subscribers Various

Sep 27, 2022

beego is an open-source, high-performance web framework for the Go programming language.

beego is an open-source, high-performance web framework for the Go programming language.

Beego Beego is used for rapid development of enterprise application in Go, including RESTful APIs, web apps and backend services. It is inspired by To

Jan 1, 2023

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

Jan 8, 2023

beego is an open-source, high-performance web framework for the Go programming language.

beego is an open-source, high-performance web framework for the Go programming language.

Beego Beego is used for rapid development of enterprise application in Go, including RESTful APIs, web apps and backend services. It is inspired by To

Jan 8, 2023

letgo is an open-source, high-performance web framework for the Go programming language.

high-performance Lightweight web framework for the Go programming language. golang web framework,高可用golang web框架,go语言 web框架 ,go web

Sep 23, 2022

An open source programming language that makes it easy to build simple

An open source programming language that makes it easy to build simple

The Go Programming Language Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. Gopher ima

Oct 15, 2021

A Master list of Go Programming Tutorials, their write-ups, their source code and their current build status!

A Master list of Go Programming Tutorials, their write-ups, their source code and their current build status!

TutorialEdge TutorialEdge.net Go Tutorials 👩‍💻 👨‍💻 Welcome to the TutorialEdge Go Repository! The goal of this repo is to be able to keep track of

Dec 18, 2022

An open source, online coding platform that offers code practice and tutoring in 50 different programming languages

An open source, online coding platform that offers code practice and tutoring in 50 different programming languages

Exercism Golang En este repositorio voy a subir los ejercicios de la plataforma

Jan 7, 2022

Moby Project - a collaborative project for the container ecosystem to assemble container-based systems

Moby Project - a collaborative project for the container ecosystem to assemble container-based systems

The Moby Project Moby is an open-source project created by Docker to enable and accelerate software containerization. It provides a "Lego set" of tool

Jan 8, 2023

A distributed Configuration Center server that manages config in a container. The container is composed of fields (abstract layer includes: KV, LIST, DICT type). The Field contains basic datatypes (int, float, bool, string, list, dict).

A distributed Configuration Center server that manages config in a container. The container is composed of fields (abstract layer includes: KV, LIST, DICT type). The Field contains basic datatypes (int, float, bool, string, list, dict).

cassem config assembler from key-value pairs' container which include basic datatypes, such as int, string, float, bool, list, dict Features HTTP Rest

Nov 1, 2022

Moby Project - a collaborative project for the container ecosystem to assemble container-based systems

Moby Project - a collaborative project for the container ecosystem to assemble container-based systems

The Moby Project Moby is an open-source project created by Docker to enable and accelerate software containerization. It provides a "Lego set" of tool

Jan 2, 2023

top in container - Running the original top command in a container

top in container - Running the original top command in a container

Running the original top command in a container will not get information of the container, many metrics like uptime, users, load average, tasks, cpu, memory, are about the host in fact. topic(top in container) will retrieve those metrics from container instead, and shows the status of the container, not the host.

Dec 2, 2022
PHP bindings for the Go programming language (Golang)

PHP bindings for Go This package implements support for executing PHP scripts, exporting Go variables for use in PHP contexts, attaching Go method rec

Jan 1, 2023
A fast script language for Go
A fast script language for Go

The Tengo Language Tengo is a small, dynamic, fast, secure script language for Go. Tengo is fast and secure because it's compiled/executed as bytecode

Dec 30, 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.

Oct 20, 2022
Boxygen is a container as code framework that allows you to build container images from code

Boxygen is a container as code framework that allows you to build container images from code, allowing integration of container image builds into other tooling such as servers or CLI tooling.

Dec 13, 2021
based on go lang build WEB development framework for go lang beginners .

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

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.

Dec 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

Jun 29, 2022
Yayx programming language is begginer friendly programming language.
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

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

May 20, 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

Dec 2, 2021