Skip to main content

A tiny capability-based language where syntax and power are loaded through binary knouts.

Project description

Red Rope

Red Rope is a tiny capability-based language where syntax and runtime power are loaded explicitly from binary .kn modules, also called knouts.

This repository contains a dependency-free Python reference implementation for the 0.1.0 draft language spec. See SPEC.md for the current behavior.

Quick Start

Build the example knouts:

python -m redrope.tools.build_examples

Run the example program:

python -m redrope examples/hello.rr

After installing the package, the same program can be run with:

redrope examples/hello.rr

Expected output:

Hello from Red Rope

Example Program

load ../modules/printing.kn
load ../modules/pythonstyle.kn

print("Hello from Red Rope")

Nothing except load exists before modules are loaded. Runtime modules provide capabilities such as print; syntax modules provide statement forms such as print({x}).

Syntax modules merge when loaded. Newer syntax rules are checked first, so a later module can override a matching shape while earlier non-conflicting rules remain available.

Writing Knouts

Human-authored modules use .knsrc and compile to binary .kn with knc:

python -m redrope.knc module_src/pythonstyle.knsrc -o modules/pythonstyle.kn

After installing the package:

knc module_src/pythonstyle.knsrc -o modules/pythonstyle.kn

Example runtime module:

module printing runtime
metadata version=1.0
export print function
native print rr_print_stdout

Example syntax module:

module pythonstyle syntax
metadata version=1.0
rule print({x}) -> call print x

Rule actions may use shorthand calls, where identifiers are captures:

rule display {x} -> call print x

They may also use explicit VM actions separated by semicolons:

rule banner {x} -> load_const ">>> "; load_capture x; concat; invoke print 1

Project Layout

  • redrope/: reference interpreter, module loader, tokenizer, VM, and CLI.
  • redrope/knc.py: compiles .knsrc module source files to binary .kn knouts.
  • redrope/tools/build_examples.py: compiles the sample .knsrc modules and writes example .rr programs.
  • module_src/: human-readable sample module sources.
  • examples/hello.rr: minimal Red Rope program.
  • examples/merged.rr: demonstrates syntax merging.
  • tests/: unit tests for the core v0.1 behavior.

Current Scope

Implemented:

  • line-oriented .rr execution
  • core comments and load
  • local .kn module loading
  • .kn header and section validation
  • exports, native bindings, compiled syntax, and bytecode actions
  • .knsrc to .kn compiler
  • syntax merging with newest-rule precedence
  • stack-based VM opcodes: LOAD_CONST, LOAD_CAPTURE, CALL, HALT
  • stack/value VM opcodes: LOAD_NUMBER, POP, DUP, SWAP, CONCAT
  • host native binding for rr_print_stdout

Not implemented yet:

  • remote module loading or remote execution; both are reserved for a future trust-policy design
  • signatures/checksums/trust policy
  • unload, namespaces, variables, control flow, or user-defined functions

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

redrope_lang-0.1.0.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

redrope_lang-0.1.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file redrope_lang-0.1.0.tar.gz.

File metadata

  • Download URL: redrope_lang-0.1.0.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for redrope_lang-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fc43a905886d29771b26dd22a503cbc37c39eb6459cb92fd23fc5ffa497d592b
MD5 b62bdb3192f8a3b9f80abe665706919a
BLAKE2b-256 d693ff8968d096adf797f9dc318830808abf65349cceb07f736c7f1b42a1c0ed

See more details on using hashes here.

File details

Details for the file redrope_lang-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: redrope_lang-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for redrope_lang-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bfa98c5235119067f2d16afd5d577ed7df3469269d2acff7f86039806ec2aec4
MD5 9a928c1b2fed7a405a9a40f70088fad9
BLAKE2b-256 a120aa08687680e5329b8a93b3a9c164c378da4670a2f501b820db9244220224

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page