Keikaku (計画)

Keikaku is a dynamic, interpreted programming language designed for expressive control flow and structured state management. Its name is the Japanese word for “plan,” and the language leans into that theme throughout its keyword design: conditionals are foresee, loops are cycle, functions are protocol, and errors are treated as anticipated deviations handled by attempt/recover. It offers first-class support for lazy evaluation, generators with bidirectional communication, and asynchronous programming primitives. It is built with an ANTLR-defined grammar and a C interpreter core, packaged for Arch, Debian/Ubuntu/Kali, and Windows, and released under MIT by Regaan, founder of Rot Hackers.

Overview

Keikaku replaces the familiar keyword vocabulary of mainstream scripting languages with an intent-driven, themed one, while keeping semantics that will be recognizable to anyone who has used Python-style generators and async. You designate variables, branch with foresee/alternate/otherwise, iterate with cycle (in while, through, and from/to forms), define logic with protocol, and define generators with sequence. The generator system is the centerpiece: it supports delegation (delegate), bidirectional communication (transmit/receive), lazy generator expressions, and exception injection (disrupt). On top of that sits an async layer (async protocol, await, resolve, defer, sleep) and a structured error model (attempt/recover, disrupt, anomaly).

Key Features

  • Advanced generators: full sequence protocol with yield, delegate (yield-from), and bidirectional state passing via transmit/receive.
  • Asynchronous concurrency: built-in async/await, a promise model with resolve, deferred execution via defer, and sleep.
  • Structured control flow: foresee/alternate/otherwise conditionals and cycle loops in while, for-each, and range forms.
  • Lazy evaluation: generator expressions with optional filtering ((x * x for x through list where cond)).
  • Robust error handling: attempt/recover blocks, exception injection into generators via disrupt, and the anomaly block for deliberate deviations.
  • Interactive REPL and file execution: run keikaku for a REPL or keikaku script.kei to execute a file.
  • Cross-platform packaging: install scripts for Arch (makepkg), Debian/Ubuntu/Kali, and Windows (mingw-w64 cross-compile), plus a universal CMake build.

Architecture Summary

Keikaku is a tree-walking-style dynamic interpreter fronted by an ANTLR grammar. The language stack listed in the repository is ANTLR, C, CMake, Makefile, Python, and Shell: ANTLR defines the grammar and generates parser machinery, the C core implements the interpreter and runtime, CMake and Makefile drive the build, Shell scripts handle packaging and cross-compilation, and Python appears in the tooling. Source text is parsed against the ANTLR grammar into a syntax tree, and the C interpreter evaluates that tree, managing the runtime state that generators and async depend on: paused generator frames, the caller/generator communication channel, and the event-loop behavior behind async/await, defer, and sleep. Output is produced with declare, and programs run either through the REPL or by executing a .kei file.

Technology Stack

  • Grammar / parsing: ANTLR.
  • Interpreter core / runtime: C.
  • Build system: CMake and Makefile.
  • Packaging / scripting: Shell (Arch makepkg, Debian install script, Windows cross-compile via mingw-w64-gcc).
  • Tooling: Python.
  • Execution model: dynamic, interpreted; REPL and file execution.
  • CI: GitHub Actions (ci.yml, badge in README).
  • License: MIT.
  • File extension: .kei.

Problem Statement

Most scripting languages share a near-identical control-flow vocabulary (if, for, while, def, yield), which is familiar but semantically neutral: the keywords describe mechanism, not intent. Keikaku takes a different position, that a language’s surface vocabulary can express the intent of a construct rather than just its mechanism, and it organizes that vocabulary around a single coherent theme (planning and foresight). The practical problem it addresses is expressiveness and readability of control flow and stateful iteration: making generators, delegation, bidirectional communication, and async read as deliberate, named acts (foresee, delegate, transmit, disrupt) rather than as generic syntax.

Why This Project Exists

Keikaku exists as a designed, aesthetic language: an anime-inspired, plan-themed language for “masterminds,” built to be expressive and enjoyable to write while still supporting genuinely non-trivial features (bidirectional generators, delegation, async/await, exception injection). It is a language-design and interpreter-implementation project that pairs a distinctive keyword vocabulary with a real ANTLR-plus-C implementation, a REPL, cross-platform packaging, and full documentation of its semantics.

Sub-Articles (this knowledge base)

  • RedLang — a statically typed systems programming language for security research by the same author (currently private preview); the compiled, low-level counterpart to Keikaku’s dynamic, interpreted design.
  • Rothalyx, ProtoCrash, PoCSmith, Basilisk — the author’s security-tooling projects under Rot Hackers; Keikaku is the language-design entry in the same portfolio.