"In the beginning was the Word, and the Word was with God, and the Word was God." β John 1:1
Logos is an esoteric, imperative programming language whose syntax draws inspiration from Orthodox Christian liturgy and theological concepts. Beneath its uniquely themed surface, Logos functions as a robust, interpreted language built on Python and leveraging the Lark parsing library. It features advanced capabilities such as Tail Call Optimization (TCO) for efficient recursion, a Foreign Function Interface (FFI) powered by ctypes, comprehensive Runtime Type Enforcement, and a dedicated Language Server Protocol (LSP) implementation for enhanced developer experience.
To begin your journey with Logos, ensure you have Python 3.10+ installed.
-
Clone the Repository:
git clone https://github.com/nikanats/nikanats-logos.git cd nikanats-logos -
Set Up Virtual Environment: It is best practice to work within a virtual environment to manage dependencies.
python -m venv .venv # Activate on Linux/macOS: source ./.venv/bin/activate # Activate on Windows (Cmd/Git Bash): ./.venv/Scripts/activate # Activate on Windows (PowerShell): ./.venv/Scripts/Activate.ps1
-
Install Core Dependencies: The Logos interpreter relies primarily on
lark.pip install lark
-
Run a Sample Liturgy: Execute the
smoke_test.lgexample to confirm everything is working:python logos.py examples/smoke_test.lg
This script performs basic system checks, including time, math, and file I/O operations, proclaiming the results to your console.
-
Interactive Confessional (REPL): For immediate exploration, run Logos in interactive mode:
python logos.py
Type
silence;to execute a statement andexitordepart(0);to leave.
Logos is designed with specific "canonical" principles, offering a unique set of programming capabilities:
- Liturgical Syntax: Core language constructs are re-imagined with theological terms:
mystery: Function definitionvigil/confess: Exception handling (try/catch)icon: Data structure (struct/object) definitionproclaim: Output to console (print)offer: Return value
- The Apocrypha (FFI): Seamlessly bind and call functions from native C libraries (shared objects on Unix-like systems, DLLs on Windows) using the
apocryphakeyword. - Runtime Type Dogma: Logos supports optional gradual typing (e.g.,
inscribe x: HolyInt). These type annotations are strictly enforced at runtime and validated by the LSP. - Tail Call Optimization (TCO): To prevent "Pride" (recursion depth exceeded errors), Logos implements a trampolining mechanism for tail-recursive
mysteryinvocations. - The Iconostasis (Structs): Define custom data structures using
icon. These icons support field validation during instantiation (write Icon { ... }) and mutable attributes. - LSP Support: A custom Language Server, powered by Python's
pyglslibrary, provides real-time diagnostics, syntax validation, and semantic highlighting for compatible editors like VS Code.
- Declare variables with
inscribe. - Modify existing variables using
amend. - Primitive types:
HolyInt(int),HolyFloat(float),Text(string),Bool(Verily/Nay). - Aggregate types:
Procession(list),Icon(struct).
// Declare an integer variable 'age'
inscribe age: HolyInt = 30;
// Mutate the value of 'age'
amend age = 31;
// Declare a string variable 'name'
inscribe name: Text = "Theophilus";
// Proclaim values to the console
proclaim name + " is " + transfigure age into Text; // Output: Theophilus is 31- Loops:
chant(while loop). - Conditionals:
discern/otherwise(if/else). - Pattern Matching:
contemplate/aspect(switch/match).
// A chant (while loop)
chant age < 100 {
amend age = age + 1;
proclaim age;
} amen // 'amen' signifies the end of a block
// A discernment (if-else)
discern (age >= 100) {
proclaim "A century of devotion reached.";
} otherwise {
proclaim "Pilgrimage continues.";
} amen
// Contemplation (pattern matching)
contemplate (age) {
aspect 100: proclaim "The time is fulfilled.";
aspect _: proclaim "Still journeying...";
} amenFunctions are defined as mystery and values are returned using offer.
mystery calculate_penance(sins: HolyInt) -> HolyInt {
discern (sins > 10) {
offer sins * 2;
} otherwise {
offer sins;
} amen
} amenvigil {
inscribe x = 1 / 0; // Runtime error
} confess sin {
proclaim "A fault occurred during the vigil:";
proclaim sin;
} amen// Binds to the 'cos' function in msvcrt.dll (Windows) or libm.so (Linux)
apocrypha "msvcrt" mystery cos(x: HolyFloat) -> HolyFloat;
inscribe pi = 3.14159;
proclaim cos(pi); // Output: ~ -1.0The Logos VS Code extension resides in packages/logos-vscode and provides syntax highlighting and LSP diagnostics.
- Navigate to the Extension Directory:
cd packages/logos-vscode - Install Node.js Dependencies:
npm install
- Language Server Dependencies:
pip install -r server/requirements.txt
- Launch Extension Development Host:
In VS Code, press
F5to open a window with the extension loaded.
The extension can ship with a bundled native executable of the Language Server (built with PyInstaller), eliminating the Python requirement for end-users.
- Building the Windows Server Binary:
This generates
cd packages\logos-vscode\server .\build_server_win.ps1packages\logos-vscode\server\bin\win32\logos-lang-server.exe.
Logos maintains a robust test suite to ensure the integrity of its "Canon."
To run all tests:
python -m unittest discover testsTo include coverage reports:
pip install coverage
coverage run -m unittest discover tests
coverage report -mThe suite covers grammar, runtime internals (logos_lang), security sandboxing, and LSP protocol integrity.
The project is architected into the core language package, the standard library (lib), and external tooling.
nikanats-logos/
βββ logos.py # Entrypoint: CLI and REPL wrapper.
βββ logos_lang/ # The Core Logic (The Soul):
β βββ interpreter.py # The Runtime (The Spirit).
β βββ grammar.py # The Grammar Definition (Lark).
β βββ ffi.py # Foreign Function Interface logic.
β βββ scope.py # Variable scoping and stack management.
β βββ stdlib.py # Native Python bindings for the Standard Lib.
β βββ ... # Models, Types, and Module management.
βββ lib/ # The Standard Library (The Canon - .lg files):
β βββ canon.lg # General utilities.
β βββ genesis.lg # System, Time, and File I/O.
β βββ numeri.lg # Mathematics.
β βββ psalms.lg # String manipulation.
βββ examples/ # Small liturgies showcasing features.
βββ programs/ # Complex, multi-file programs (e.g., monk.lg, creed.lg).
βββ packages/ # Editor integrations:
β βββ logos-vscode/ # The primary VS Code extension.
β β βββ server/ # Python-based LSP implementation.
β β βββ src/ # TypeScript client.
β β βββ syntaxes/ # TextMate grammar.
β βββ logos-liturgy/ # (Legacy) Alternative client structure.
βββ tests/ # The Inquisitor (Test Suite):
βββ fixtures/ # Isolated code snippets for testing.
βββ fuzz/ # Fuzz testing for parser stability.
βββ security/ # Security regression tests (sandbox escapes).
βββ stress/ # TCO benchmark tests.
graph TD
User("π€ <b>The Pilgrim</b><br/>(User)")
subgraph Stage1 ["π¦ Phase 1: Creation"]
direction LR
Editor("π <b>VS Code</b><br/>(Client)")
LSP("π‘ <b>Logos Server</b><br/>(LSP/pygls)")
end
subgraph Stage2 ["πͺ Phase 2: Execution"]
direction LR
CLI("logos.py")
Core("βοΈ <b>logos_lang</b><br/>(Interpreter)")
Lib("π <b>lib/*.lg</b><br/>(Canon)")
end
subgraph Stage3 ["π© Phase 3: Revelation"]
Console("π₯οΈ <b>Proclamation</b><br/>(Output)")
end
User ==>|Writes| Editor
Editor <-->|Diagnostics| LSP
User ==>|Executes| CLI
CLI --> Core
Core -->|Imports| Lib
Core -->|Proclaims| Console
This project is licensed under the MIT License.
Copyright (c) 2025 NikaNats