Files
blackroad/roadc/ROADC_LANGUAGE_SPEC.md
Alexa Amundson 558634c0e6
Some checks failed
Lint & Format / detect (push) Has been cancelled
Lint & Format / js-lint (push) Has been cancelled
Lint & Format / py-lint (push) Has been cancelled
Lint & Format / sh-lint (push) Has been cancelled
Lint & Format / go-lint (push) Has been cancelled
Monorepo Lint / lint-shell (push) Has been cancelled
Monorepo Lint / lint-js (push) Has been cancelled
sync: 2026-03-16 22:00 — 21 files from Alexandria
RoadChain-SHA2048: f31122b68d27a309
RoadChain-Identity: alexa@sovereign
RoadChain-Full: f31122b68d27a30949e6be04538b248fc34fc9a056bbb0cce1a6d2bcd333a83956b6c6bf6c4771ca9bb6fb6a284c367ebf6eee3d2c1d97ab6d2d5913fa4ae58c85045eabcef75c88329792905fa71b79e4f7b0d79616f32e99a806df1b0d1ad1e4abc1fb3ae950e91f79f029e0f17ed3463e5e5f05a7c81585955c3c8b8b50f8d10007d33237e1e87a601333aa33f6b48e14a6d1f78c40e178e7e3050b609668d2e323ee30df27dd63f3267dc46b08df2348aa4e8b64de024ff350c5191b04a15f588a43e0f1b6d97ef309ea6dc68e8e138a7060faff35fd3f1b38bcb702e49bea951f4e792cb4d2b7dd2a314b5eb72c4d350ceb9b29a2c9436e34192aee0e43
2026-03-16 22:00:02 -05:00

112 lines
3.0 KiB
Markdown

# RoadC Language Specification
**RoadC** is the official programming language of BlackRoad OS. Every agent, every Claude session, every system writes RoadC.
## Why RoadC
1. **English IS a programming language.** Greenbaum & Nelson proved 7 sentence structures generate all of English. RoadC maps those 7 structures to code.
2. **Simple rules, infinite complexity.** Pascal's insight: recursive composition from simple units creates unbounded complexity. RoadC embodies this.
3. **Sovereign.** No dependency on any corporation's language. We own the lexer, parser, interpreter, and compiler.
## Quick Reference
```road
# Variables
let name = "BlackRoad"
let count: int = 42
let color = #FF1D6C
const PI = 3.14159
# Functions
fun greet(name):
return "Hello, {name}!"
# Control flow
if count > 10:
print("big")
elif count > 0:
print("small")
else:
print("zero")
while count > 0:
count = count - 1
for item in [1, 2, 3]:
print(item)
# Collections
let list = [1, 2, 3, 4, 5]
let dict = {"key": "value", "name": "Alexa"}
let colors = {#FF1D6C, #F5A623, #2979FF}
# String interpolation
let msg = "Hello {name}, count is {count}"
# Member access
print(list.length)
print("hello".upper())
print(dict["name"])
```
## The 7 Sentence Structures
Every function in RoadC follows one of 7 English sentence patterns:
| Pattern | English | RoadC | Meaning |
|---------|---------|-------|---------|
| SV | "It runs" | `run()` | No args, subject acts alone |
| SVA | "Deploy to Cecilia" | `deploy("cecilia")` | Verb + location/manner |
| SVC | "Alice is online" | `status("alice") -> "online"` | Identity/state check |
| SVO | "Search the repos" | `search("repos")` | Verb acts on object |
| SVOO | "Send Alexa the report" | `send("alexa", "report")` | Two objects: who + what |
| SVOA | "Store data in R2" | `store("data", "r2")` | Object + where |
| SVOC | "Make code clean" | `make("code", "clean")` | Object becomes complement |
## Implementations
| Implementation | Language | Lines | Status |
|---------------|----------|-------|--------|
| Interpreter | Python | 1,764 | Working |
| Compiler | C99 | 618 | Working |
| Playground | Web | - | At roadc-playground |
## File Extension
`.road`
## Run
```bash
# Python interpreter
python3 roadc.py run program.road
# REPL
python3 roadc.py repl
# C compiler
./roadc program.road
```
## Design Principles
1. **Python-style indentation** — no braces, no semicolons
2. **Explicit types optional**`let x = 42` or `let x: int = 42`
3. **String interpolation**`"Hello {name}"` not `f"Hello {name}"`
4. **Color literals**`#FF1D6C` is a first-class type
5. **Space keyword**`space MyScene:` for 3D/spatial computing
6. **Fun keyword** — functions are fun: `fun greet(name):`
7. **English-first** — code reads like English sentences
## For Agents
When writing RoadC, think in English sentence structures:
- Name your functions as verbs
- Name your parameters as objects
- Structure matches intent
- If you can say it in English, you can write it in RoadC
## License
Proprietary — BlackRoad OS, Inc.