An implementation of ksplang, the best programming language

Related tags

Command-line ksplang
Overview

A stack-based programming language with 33 instructions, independently designed by 33 people.

Tests Crates.io AUR Version

Introduction

This is an implementation of ksplang, the best programming language (as proven by the logic of a Czech children's story).

The famous Czech children's story Jak si pejsek s kočičkou dělali k svátku dort (English translation) by Josef Čapek teaches that you can bake the best cake by adding many good things into it. Yes, that is definitely the correct interpretation. We have decided to prove this experimentally, with a programming language.

We have done this within KSP, a Czech programming competition for high-school students. Within the first series of tasks of the 36th year, we have asked each competitor for a single original instruction for a stack-based language. The result is ksplang, and you are currently looking at its reference implementation in Rust.

The ksplang interpreter

This repository includes a ksplang executable which can be used to run ksplang programs. Input is given on the standard input as whitespace-separated numbers (or text).

Example usage

./ksplang program.ksplang < input.txt > output.txt

program.ksplang – the ksplang program:

pop ++

input.txt – the input stack:

41 12

output.txt – the result:

42

Text mode

The interpreter can also be used in text mode, which translates input from text to numbers and output from numbers to text (as Unicode code points). You can also do this only for input or output with --text-input and --text-output, respectively.

echo -n "aaa" | ./ksplang -t program.ksplang
# prints "ab"

More options

  • --stats (-s) - print statistics on stderr
  • --max-stack-size (-m) - set the maximum stack size

Building from source

  1. Clone the repository: git clone https://github.com/ksp/ksplang.git
  2. Within the ksplang directory, run cargo build -p ksplang-cli --release
  3. You can now run target/release/ksplang-cli

Online interpreter

An online version of the interpreter with a simple stepping debugger lives on the KSP webpage.

Contributing

If you have improvements to the reference implementation, the tooling, or the descriptions, feel free to create an issue or a pull request.

No changes to the language are allowed as the language is perfect.

License

This code is available under the MIT License. See the LICENSE file for details.

You might also like...
Yfin is the Official package manager for the Y-flat programming language
Yfin is the Official package manager for the Y-flat programming language

Yfin is the Official package manager for the Y-flat programming language. Yfin allows the user to install, upgrade, and uninstall packages. It also allows a user to initialize a package with the Y-flat package structure and files automatically generated. In future, Yfin will also allow users to publish packages.

A Text User Interface library for the Rust programming language
A Text User Interface library for the Rust programming language

Cursive Cursive is a TUI (Text User Interface) library for rust. It uses ncurses by default, but other backends are available. It allows you to build

Notes on learning the Rust programming language syntax.

notes-on-rust Notes on learning the Rust programming language syntax. Resources https://www.rust-lang.org/learn/get-started https://doc.rust-lang.org/

A clone of linux cal command, using rust programming language

CLI Calendar command What the project does This command was inspired by Linux Cal command that shows the current month calendar as output (by default)

A simple lexer which creates over 75 various tokens based on the rust programming language.

Documentation. This complete Lexer/Lexical Scanner produces tokens for a string or a file path entry. The output is a Vector for the user to handle ac

An embeddable dynamic programming language for Rust.

rune Visit the site 🌐 - Read the book 📖 An embeddable dynamic programming language for Rust. Contributing If you want to help out, there should be a

Idiomatic inotify wrapper for the Rust programming language

inotify-rs Idiomatic inotify wrapper for the Rust programming language. extern crate inotify; use std::env; use inotify::{ EventMask, Watch

Object Notation Programming Language?
Object Notation Programming Language?

You may have questions ONLang - Object Notation Language (jsON) VSCode extension - OnLang 1. God, what the f**** is this ONLang is an experimental, es

Programming language that compiles into Scratch blocks (SB3).

Claw Hello, and welcome to my cool project! I've spent... at least a month on this, and it's still not finished! Feel free to check it out though. :D

Releases(0.1.0)
  • 0.1.0(Feb 19, 2024)

    Česky

    Windows

    Stáhněte ksplang.exe, pak ho můžete spustit v příkazové řádce (doporučujeme Windows Terminal):

    ksplang.exe program.ksplang < input.txt
    

    Linux

    Stáhněte si ksplang, přidejte mu práva na spustitelnost, a můžete jej spustit v terminálu:

    chmod +x ksplang
    ./ksplang program.ksplang < input.txt
    

    English

    Windows

    Download ksplang.exe, then you can run it as follows:

    ksplang.exe program.ksplang < input.txt
    

    Linux

    Download ksplang, then you can run it as follows:

    chmod +x ksplang
    ./ksplang program.ksplang < input.txt
    
    Source code(tar.gz)
    Source code(zip)
    ksplang(13.94 MB)
    ksplang.exe(10.34 MB)
Owner
KSP MFF UK
Korespondenční Seminář z Programování MFF UK
KSP MFF UK
being Ariel's best friend!

Sebastian se·bas·tian - sɪˈbæstɪən A simple tool used to access UniMi services -- mainly ariel, but not only -- via CLI. Important: state First of all

null 2 Sep 2, 2022
Bam Error Stats Tool (best): analysis of error types in aligned reads.

best Bam Error Stats Tool (best): analysis of error types in aligned reads. best is used to assess the quality of reads after aligning them to a refer

Google 54 Jan 3, 2023
ABQ is a universal test runner that runs test suites in parallel. It’s the best tool for splitting test suites into parallel jobs locally or on CI

?? abq.build   ?? @rwx_research   ?? discord   ?? documentation ABQ is a universal test runner that runs test suites in parallel. It’s the best tool f

RWX 13 Apr 7, 2023
Solutions for exact and optimized best housing chains in BDO using popjumppush and MIP.

Work in progress. About This project is an implementation of the pop_jump_push algorithm. It uses graph data from the MMORPG Black Desert Online's tow

Thell 'Bo' Fowler 3 May 2, 2023
Best-effort attempt at rewriting Reticulum in Rust.

reticulum-rs WIP rewrite of Reticulum in Rust explicitly targeted at the ESP32 (no tokio, avoids memory-inefficient data structures. etc). Not ready f

Ellen Poe 8 Sep 25, 2023
Programming language made by me to learn other people how to make programming languages :3

Spectra programming language Programming language made for my tutorial videos (my youtube channel): Syntax Declaring a variable: var a = 3; Function

Adi Salimgereyev 3 Jul 25, 2023
The Amp programming language: a language designed for building high performance systems.

A language designed for building high performance systems. Platform Support x86_64-pc-windows ✅ x86_64-unknown-linux ⚠️ untested x86_64-unknown-darwin

The Amp Programming Language 5 Mar 17, 2023
Nexa programming language. A language for game developers by a game developer

NexaLang Nexa programming language. A language for game developers by a game developer. Features High-Level: Nexa is an easy high level language Two M

Sabe 3 Aug 21, 2023
A Text User Interface library for the Rust programming language

Cursive Cursive is a TUI (Text User Interface) library for rust. It uses ncurses by default, but other backends are available. It allows you to build

Alexandre Bury 3.3k Jan 9, 2023
🎄My Advent of Code 2021 solutions in the Rust programming language

Advent of Code 2021 in Rust My Advent of Code 2021 solutions in the Rust programming language. This repository holds a separate Rust project for each

Tim Visée 227 Dec 16, 2022