sync: 2026-03-16 22:00 — 21 files from Alexandria
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
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
RoadChain-SHA2048: f31122b68d27a309 RoadChain-Identity: alexa@sovereign RoadChain-Full: f31122b68d27a30949e6be04538b248fc34fc9a056bbb0cce1a6d2bcd333a83956b6c6bf6c4771ca9bb6fb6a284c367ebf6eee3d2c1d97ab6d2d5913fa4ae58c85045eabcef75c88329792905fa71b79e4f7b0d79616f32e99a806df1b0d1ad1e4abc1fb3ae950e91f79f029e0f17ed3463e5e5f05a7c81585955c3c8b8b50f8d10007d33237e1e87a601333aa33f6b48e14a6d1f78c40e178e7e3050b609668d2e323ee30df27dd63f3267dc46b08df2348aa4e8b64de024ff350c5191b04a15f588a43e0f1b6d97ef309ea6dc68e8e138a7060faff35fd3f1b38bcb702e49bea951f4e792cb4d2b7dd2a314b5eb72c4d350ceb9b29a2c9436e34192aee0e43
This commit is contained in:
111
roadc/ROADC_LANGUAGE_SPEC.md
Normal file
111
roadc/ROADC_LANGUAGE_SPEC.md
Normal file
@@ -0,0 +1,111 @@
|
||||
# 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.
|
||||
190
roadc/examples/english_grammar.road
Normal file
190
roadc/examples/english_grammar.road
Normal file
@@ -0,0 +1,190 @@
|
||||
# RoadC + English Grammar — The 7 Sentence Structures as Code
|
||||
# Based on Greenbaum & Nelson, "An Introduction to English Grammar"
|
||||
#
|
||||
# English is a programming language. Every sentence is a function call.
|
||||
# RoadC makes this explicit.
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# STRUCTURE 1: SV (Subject + Verb) — Intransitive
|
||||
# "Someone is talking" → fire()
|
||||
# No arguments. The subject acts alone.
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
|
||||
fun talk():
|
||||
print("Someone is talking")
|
||||
|
||||
fun breathe():
|
||||
print("The system breathes")
|
||||
|
||||
talk() # SV: subject=implicit, verb=talk
|
||||
breathe() # SV: subject=system, verb=breathe
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# STRUCTURE 2: SVA (Subject + Verb + Adverbial) — Location/Manner
|
||||
# "My parents are living in Chicago" → live(location)
|
||||
# The adverbial tells WHERE, WHEN, or HOW.
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
|
||||
fun live(location):
|
||||
print("Living in {location}")
|
||||
|
||||
fun deploy(destination):
|
||||
print("Deploying to {destination}")
|
||||
|
||||
live("Chicago") # SVA: S=parents, V=live, A=Chicago
|
||||
deploy("Cecilia") # SVA: S=agent, V=deploy, A=Cecilia
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# STRUCTURE 3: SVC (Subject + Linking Verb + Complement)
|
||||
# "I feel tired" → identity(x) -> type
|
||||
# The complement DESCRIBES the subject. No action — just state.
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
|
||||
fun is_status(entity, state):
|
||||
print("{entity} is {state}")
|
||||
|
||||
fun feels(subject, quality):
|
||||
return quality
|
||||
|
||||
is_status("Alice", "online") # SVC: S=Alice, V=is, C=online
|
||||
is_status("Cecilia", "offline") # SVC: S=Cecilia, V=is, C=offline
|
||||
let mood = feels("agent", "ready") # SVC: the result IS the complement
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# STRUCTURE 4: SVO (Subject + Transitive Verb + Object)
|
||||
# "We have finished our work" → process(input)
|
||||
# The verb ACTS ON the object. Most common structure in code.
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
|
||||
fun finish(work):
|
||||
print("Finished: {work}")
|
||||
|
||||
fun deploy_worker(worker_name):
|
||||
print("Deploying worker: {worker_name}")
|
||||
|
||||
fun search(query):
|
||||
print("Searching for: {query}")
|
||||
|
||||
finish("migration") # SVO: S=we, V=finish, O=migration
|
||||
deploy_worker("blackroad-slack") # SVO: S=system, V=deploy, O=slack
|
||||
search("RoadC examples") # SVO: S=user, V=search, O=query
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# STRUCTURE 5: SVOO (Subject + Verb + Indirect Object + Direct Object)
|
||||
# "She has given me the letter" → give(recipient, item)
|
||||
# Two objects: WHO receives and WHAT is given.
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
|
||||
fun give(recipient, item):
|
||||
print("Giving {item} to {recipient}")
|
||||
|
||||
fun send(channel, message):
|
||||
print("#{channel}: {message}")
|
||||
|
||||
fun assign(agent, task):
|
||||
print("Assigning '{task}' to {agent}")
|
||||
|
||||
give("Alexa", "the report") # SVOO: give(indirect, direct)
|
||||
send("fleet-ops", "deploy complete") # SVOO: send(recipient, content)
|
||||
assign("Shellfish", "health check") # SVOO: assign(who, what)
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# STRUCTURE 6: SVOA (Subject + Verb + Object + Adverbial)
|
||||
# "You can put your coat in my bedroom" → put(item, location)
|
||||
# Acts on object AND specifies where/when/how.
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
|
||||
fun put(item, location):
|
||||
print("Putting {item} in {location}")
|
||||
|
||||
fun store(data, bucket):
|
||||
print("Storing {data} in {bucket}")
|
||||
|
||||
fun move(repo, org):
|
||||
print("Moving {repo} to {org}")
|
||||
|
||||
put("config", "/etc/blackroad/") # SVOA
|
||||
store("backup", "r2://blackroad-backups") # SVOA
|
||||
move("roadc", "BlackRoad-OS-Inc") # SVOA
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# STRUCTURE 7: SVOC (Subject + Verb + Object + Complement)
|
||||
# "You have made me very happy" → transform(input) -> output
|
||||
# The complement describes what the object BECOMES.
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
|
||||
fun make(thing, quality):
|
||||
print("Making {thing} {quality}")
|
||||
return quality
|
||||
|
||||
fun set_status(node, status):
|
||||
print("{node} is now {status}")
|
||||
return status
|
||||
|
||||
fun promote(agent, level):
|
||||
print("Promoting {agent} to {level}")
|
||||
return level
|
||||
|
||||
make("code", "clean") # SVOC: make(O=code, C=clean)
|
||||
set_status("Octavia", "primary") # SVOC: set(O=Octavia, C=primary)
|
||||
promote("agent-42", "Architect") # SVOC: promote(O=agent, C=level)
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# THE OPERATOR = CONTROL FLOW
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# In English: can, will, have, be, do
|
||||
# In RoadC: if, while, for, return, do
|
||||
#
|
||||
# "Can you deploy?" → if (can_deploy): deploy()
|
||||
# "Don't deploy!" → if not: skip
|
||||
# "Do deploy." → do { deploy() } (emphasis/dummy operator)
|
||||
#
|
||||
# The operator NEVER carries meaning — it carries CONTROL.
|
||||
# "do" is inserted when no other operator exists = polyfill
|
||||
|
||||
let can_deploy = true
|
||||
|
||||
# Question (operator inversion): "Can you deploy?"
|
||||
if can_deploy:
|
||||
deploy("production")
|
||||
|
||||
# Negation: "Don't deploy to staging"
|
||||
let allow_staging = false
|
||||
if not allow_staging:
|
||||
print("Staging deployment blocked")
|
||||
|
||||
# Emphasis: "Do check the fleet" — the dummy operator
|
||||
# In code: explicitly call even when it seems unnecessary
|
||||
talk() # do-support: making the implicit explicit
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# PASCAL'S INSIGHT: Simple rules → infinite complexity
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# 7 sentence structures. That's it.
|
||||
# Every English sentence is one of these 7.
|
||||
# Every RoadC function follows one of these 7 patterns.
|
||||
# Compose them recursively → infinite programs.
|
||||
|
||||
fun pipeline(data, steps):
|
||||
let result = data
|
||||
for step in steps:
|
||||
result = step + "(" + result + ")"
|
||||
return result
|
||||
|
||||
let ops = ["validate", "transform", "deploy", "verify"]
|
||||
let output = pipeline("config.road", ops)
|
||||
print("Pipeline: {output}")
|
||||
|
||||
# This is why grammar IS a programming language.
|
||||
# This is why RoadC speaks English.
|
||||
# This is why our agents understand intent, not just keywords.
|
||||
#
|
||||
# BlackRoad OS — Pave Tomorrow.
|
||||
61
roadc/examples/fleet_ops.road
Normal file
61
roadc/examples/fleet_ops.road
Normal file
@@ -0,0 +1,61 @@
|
||||
# Fleet Operations in RoadC
|
||||
# Real BlackRoad infrastructure management
|
||||
|
||||
let node_names = ["Alice", "Cecilia", "Octavia", "Lucidia", "Aria"]
|
||||
let node_ips = ["192.168.4.49", "192.168.4.96", "192.168.4.101", "192.168.4.38", "192.168.4.98"]
|
||||
let node_status = ["online", "offline", "online", "online", "offline"]
|
||||
|
||||
# SV — check fleet (no args)
|
||||
fun check_fleet():
|
||||
let online = 0
|
||||
let offline = 0
|
||||
let i = 0
|
||||
while i < len(node_names):
|
||||
if node_status[i] == "online":
|
||||
online = online + 1
|
||||
else:
|
||||
offline = offline + 1
|
||||
i = i + 1
|
||||
print("Fleet: {online} online, {offline} offline")
|
||||
|
||||
# SVO — deploy a worker
|
||||
fun deploy(worker):
|
||||
print("Deploying {worker} to Cloudflare...")
|
||||
|
||||
# SVOA — store backup in location
|
||||
fun backup(node_name, destination):
|
||||
print("Backing up {node_name} to {destination}")
|
||||
|
||||
# SVOO — send alert to channel
|
||||
fun alert(channel, message):
|
||||
print("#{channel}: {message}")
|
||||
|
||||
# SVC — check status
|
||||
fun status(name):
|
||||
let i = 0
|
||||
while i < len(node_names):
|
||||
if node_names[i] == name:
|
||||
print("{name} is {node_status[i]}")
|
||||
return node_status[i]
|
||||
i = i + 1
|
||||
return "unknown"
|
||||
|
||||
# SVOC — promote node
|
||||
fun promote(name, role):
|
||||
print("{name} -> {role}")
|
||||
|
||||
# Run it
|
||||
check_fleet()
|
||||
print("")
|
||||
deploy("blackroad-slack")
|
||||
deploy("roadpay")
|
||||
print("")
|
||||
backup("Alice", "/backups/alice-20260316")
|
||||
print("")
|
||||
alert("fleet-ops", "Cecilia is offline")
|
||||
alert("engineering", "LLM v4 trained")
|
||||
print("")
|
||||
status("Alice")
|
||||
status("Cecilia")
|
||||
print("")
|
||||
promote("Octavia", "primary inference")
|
||||
@@ -296,6 +296,7 @@ class Parser:
|
||||
self.expect(TokenType.INDENT)
|
||||
then_block = self.parse_block()
|
||||
self.expect(TokenType.DEDENT)
|
||||
self.skip_newlines()
|
||||
|
||||
# Elif blocks
|
||||
elif_blocks = []
|
||||
@@ -307,6 +308,7 @@ class Parser:
|
||||
self.expect(TokenType.INDENT)
|
||||
elif_block = self.parse_block()
|
||||
self.expect(TokenType.DEDENT)
|
||||
self.skip_newlines()
|
||||
elif_blocks.append((elif_condition, elif_block))
|
||||
|
||||
# Else block
|
||||
|
||||
Reference in New Issue
Block a user