text-compiler
v0.3.0
Published
Execute small algorithms written in natural language, pseudocode, flow-style instructions, or any human-friendly form
Maintainers
Readme
✨ textc (text-compiler)
The AI-Native Compiler for Mathematical & Logical Algorithms.
Speak your algorithm in plain English • Compiled via AI-native IR • Executed with 100% mathematical precision.
🎯 Built for Logical & Mathematical Algorithms Only
Important by Design:
textcis not a general-purpose programming language for building websites, UI, or mobile apps.
textc is a specialized, laser-focused algorithm compiler designed exclusively for:
- 🔢 Mathematical calculations & sequences (Fibonacci, Collatz, factorials, GCD/LCM, powers, geometry).
- 📊 Data analytics & statistics (averages, medians, standard deviations, filtering, finding extremes).
- 🔄 Array transformations & sorting (in-place sorting, reversing, slicing, partitioning, swapping).
- 🧩 Logical problem solving & puzzles (graph/path steps, conditionals, counting problems, simulation loops).
🤖 Engineered Specifically for AI
Traditional programming languages are designed for humans to type manually. textc’s Intermediate Representation (IR) is designed specifically for AI models:
- 🧠 Zero Ambiguity: Strict, unambiguous grammar that eliminates AI syntax confusion and hallucinated keywords.
- 🔒 Explicit Mutability (
letvsmut): Enforces clear distinction between constants and changing state so AI-generated algorithms never corrupt memory. - ⚡ Pure Determinism: Translates fuzzy, probabilistic human language into exact, deterministic machine bytecode (
.txtc).
flowchart LR
A["🗣️ Human Speaks Logic\n('Find all primes under 50 and sum them')"] --> B["🤖 AI Emits TextC IR\n(Designed for AI precision)"]
B --> C["📦 Standalone .txtc Bytecode\n(Compact, verified binary)"]
C --> D["🎯 100% Exact Answer\n(Instant VM execution)"]
style A fill:#7b1fa2,stroke:#ba68c8,color:#fff
style B fill:#1565c0,stroke:#64b5f6,color:#fff
style C fill:#2e7d32,stroke:#81c784,color:#fff
style D fill:#d84315,stroke:#ff8a65,color:#fff🚀 Quick Install
🐧 Linux, 🍏 macOS & 📱 Android Termux
curl -fsSL https://raw.githubusercontent.com/sapirrior/textc/main/installer/install.sh | bash🪟 Windows (PowerShell)
irm https://raw.githubusercontent.com/sapirrior/textc/main/installer/install.ps1 | iex📦 Via npm
npm install -g text-compiler🌈 Write Algorithms in ANY Natural Text
textc understands your logic in whatever format feels natural:
1️⃣ Conversational Data Analysis
scores.txt:
I have test scores: [88, 92, 79, 95, 61, 84].
Sort them, remove the single lowest score, and calculate the average of the remaining ones.
Print the final average.textc scores.txt --run842️⃣ Step-by-Step Simulation & Finance Logic
investment.txt:
1. Start with 1000 dollars.
2. For 5 years in a row:
- Grow the balance by 8% each year.
- Add a 200 dollar bonus at the end of each year.
3. Print the final balance.textc investment.txt --run26373️⃣ Mathematical Sequences & Iteration
collatz.txt:
Start with the number 27.
If it is even, cut it in half.
If it is odd, multiply by 3 and add 1.
Repeat until you reach 1, and count how many steps it took.
Print the total step count.textc collatz.txt --run1114️⃣ Data Extremes & Comparison
inventory.txt:
Prices: [45, 12, 89, 23, 67, 105, 34]
Find the cheapest item and the most expensive item.
Print the difference between the most expensive and cheapest items.textc inventory.txt --run935️⃣ Word & Symmetry Logic
palindrome.txt:
Given word letters: ["r", "a", "c", "e", "c", "a", "r"]
Reverse the letters and check if it spells the same word forwards and backwards.
Print true if it's a palindrome, false otherwise.textc palindrome.txt --runtrue⚡ Why textc?
- 🗣️ No Programming Knowledge Needed: Just express your logical thought or math problem.
- 🎯 100% Deterministic: Mathematical precision with no hallucinated math.
- ⚡ Lightning Fast: Precompiled
.txtcprogram files execute in under 1 millisecond. - 📦 Standalone Binaries: Compile once and run offline anywhere with zero external dependencies.
- 🛡️ Guaranteed Safe: Automatic bounds checking, safe math, and memory protection built into the VM.
⚙️ Configuration
Set your AI credentials once:
export TEXTC_BASE_URL="https://api.openai.com/v1"
export TEXTC_API_KEY="your-api-key"
export TEXTC_MODEL_NAME="gpt-4o-mini"🛠️ Handy Commands
# Compile and run your plain-text file in one go:
textc my_algorithm.txt --run
# Compile your natural text into a shareable .txtc bytecode binary:
textc my_algorithm.txt
# Run a saved .txtc binary instantly (offline, 0 tokens, 0ms):
textc my_algorithm.txtc
# View the AI-native Intermediate Representation (IR):
textc my_algorithm.txt --emit-ir📜 License
Distributed under the MIT License. Built for the future of AI-driven algorithmic computing.
