A programming language somewhat resembling cellular processes.

Overview

cytosol

An embeddable programming language somewhat resembling cellular processes.

State of the implementation

  • tokenising
  • parsing
  • semantic analysis and translation
  • runtime system and host API

Overview of the language

Records in the environment can activate gene functions or trigger rules. Gene functions can express new records into the environment. Rules can modify the records in the environment.

records

Records are like "structs". They have a name and can have fields.

record PersonInfo(name: string, age: int)

In expressions, fields of records can be accessed with their name, such as p.name or p.age.

The name of a record can be used as a type.

record Student(final_grade: int, info: PersonInfo)

Environment

The environment is a large unsorted set of records. Records can be added or removed from the environment.

To check or bind to a record in the environment they need to be in the "execution factor" list of gene functions or in the "reactant list" of rules.

A cytosol program can only add new things into the environment by using the express statement in gene functions.

The "host application" that manages the execution of cytosol program can also inject or remove records freely.

gene functions

gene functions are nameless functions with an "execution factor" list and a "body".

gene [2 A, 4 B, 0 C]
{
    express 10 D
}

The execution factor list is enclosed by [ and ]. An execution factor is a record that is required to be in the "environment". Only when all execution factors are met/available will the body of the gene function run.

A number in front of the name of a record signifies the quantity that needs to be available in the environment. The quantity 0 means that the record must not be present in order to run the body of the gene function.

An execution factor can be bound to a variable by using name: TypeName. This will bind 1 record to the variable name.

The body can contain a list of a statement, which at the moment can only be

  • the express statement to add new records into the environment. For example express 3 A will place 3 new "A" records into the environment.
  • the call statement used to communicate with the host application

rules

rules can modify the environment by transforming a set of records into a new set of records.

A rule has a "reactant list", which states the part of the environment needing to be present for the rule to perform its function.

With all the reactants available the "product list" will be inserted into the environment and all the reactants will be removed.

rule [4 Hydrogen, 2 Oxygen] -> 2 Water

Just like with the "execution factor list" of gene functions, reactants can have a quantity or be bound to a variable name.

Similarly to the express statement, the product list can also contain quantities.

extern functions

With the extern keyword a function can be declared that can be called from within gene function with the call statement.

extern print_line(s: string)

// Similar to a "main" function.
//
// This expects the `Start` record to be inserted by the host
// application in order to run this gene function.
//
// The `StartInhibitor` is used to make this gene function
// run only once.
gene [Start, 0 StartInhibitor]
{
    call print_line(s: "hello world")
    express StartInhibitor
}

record Start
record StartInhibitor

Implementations for extern functions can be provided through the ProgramContext of the DriverExecutionState.

let mut exec_state = DriverExecutionState::default();

let ctx = exec_state.program_context();
ctx.set_extern_function("print_line", |s: String| println!("{}", s);
ctx.set_extern_function("print_string", |s: String| print!("{}", s);
ctx.set_extern_function("print_int", |i: isize| print!("{}", i));

License

AGPLv3. Please see the LICENSE file.

You might also like...
 Gecko is a high-level, general-purpose programming language built on top of the LLVM project.
Gecko is a high-level, general-purpose programming language built on top of the LLVM project.

Gecko is a high-level, general-purpose programming language built on top of the LLVM project. Gecko Technology & principles Gecko is a general-purpose

This repository contains the source of "The Rust Programming Language" book.

The Rust Programming Language This repository contains the source of "The Rust Programming Language" book. The book is available in dead-tree form fro

A short exercise to introduce people to the Rust programming language

Searching primes by brute force This code is ment to be an exercice to teach rust and give a first impression on how to work with the language during

A turing-complete programming language using only zero-width unicode characters, inspired by brainfuck and whitespace.

Zero-Width A turing-complete programming language using only zero-width unicode characters, inspired by brainfuck and whitespace. Currently a (possibl

The Rust Programming Language, Chapter 8, Exercise 1

Rust Common Collections - Exercise 1 In the book The Rust Programming Language by Steve Klabnik and Carol Nichols, chapter 8 - Common Collections - pr

clone of grep cli written in Rust. From Chapter 12 of the Rust Programming Language book

minigrep is a clone of the grep cli in rust Minigrep will find a query string in a file. To test it out, clone the project and run cargo run body poem

The Rust Compiler Collection is a collection of compilers for various languages, written with The Rust Programming Language.

rcc The Rust Compiler Collection is a collection of compilers for various languages, written with The Rust Programming Language. Compilers Language Co

The Ribbon Programming Language, made in Rust.

The Ribbon Programming Language (WIP) This language is designed to be quick to write and is heavily inspired by Rust, which is also the language it wa

The orez programming language (a toy langauge for now obviously)

orezc The main repository for the orez programming language (a toy langauge for now obviously) Yes I've looked into the rust compiler, if you are curi

Releases(c-ffi-nightly)
Owner
null
A repository for showcasing my knowledge of the Rust programming language, and continuing to learn the language.

Learning Rust I started learning the Rust programming language before using GitHub, but increased its usage afterwards. I have found it to be a fast a

Sean P. Myrick V19.1.7.2 2 Nov 8, 2022
Nyah is a programming language runtime built for high performance and comes with a scripting language.

?? Nyah ( Unfinished ) Nyah is a programming language runtime built for high performance and comes with a scripting language. ??️ Status Nyah is not c

Stacker 3 Mar 6, 2022
lelang programming language is a toy language based on LLVM.

lelang leang是一门使用Rust编写,基于LLVM(inkwell llvm safe binding library)实现的编程语言,起初作为课程实验项目,现在为个人长期维护项目。 Target Features 支持8至64位的整形类型和32/64位浮点 基本的函数定义,调用,声明外部

Aya0wind 5 Sep 4, 2022
Nixt is an interpreted programming language written in Rust

Nixt Nixt is an interpreted lisp inspired programming language written in Rust Index About Examples Installation Build About Nixt goal is to provide a

Wafelack 17 Jul 18, 2022
Orion lang is a lispy programming language that is strongly and statically typed.

Orion Orion is a lisp inspired statically typed programming language written in Rust Install To install orion you can either: Download binary from the

Wafelack 226 Dec 17, 2022
Mote is a systems-programming language designed to be practical, performant, and simple.

Mote NOTE: this following lists the goals for what Mote is supposed to be. It does not promise that any of the features here will be accomplished or a

The Mote Programming Language 14 Jul 28, 2021
a function programming language for real world applications made in rust

a function programming language for real world applications made in rust

Tanay Pingalkar 6 Jun 12, 2022
Rust implementation of µKanren, a featherweight relational programming language.

µKanren-rs This is a Rust implementation of µKanren, a featherweight relational programming language. See the original Scheme implementation here for

Eric Zhang 99 Dec 8, 2022
A stack based interpreted programming language.

Nightmare Nightmare is a dynamically-typed, procedural programming language that aims to be fast & simple. let user = input() as Int; print("You were

&potato 4 Nov 12, 2021
lints and suggestions for the nix programming language

statix Lints and suggestions for the Nix programming language. statix highlights antipatterns in Nix code. statix --fix can fix several such occurrenc

Akshay 311 Dec 25, 2022