Syntax Reference

Complete reference for Calor syntax. Calor uses Lisp-style expressions for all operations.

Why this syntax? Calor's notation is optimized for AI agents, not human aesthetics. You don't need to learn this syntax—AI coding agents write Calor, not humans. This reference exists to help you understand what the AI generates and verify that contracts match your intent. Each design choice serves verification: unique IDs enable precise references, matched tags eliminate scope ambiguity, and Lisp-style expressions allow direct AST manipulation.


Quick Reference Table

ElementSyntaxExample
Module§M{id:name}§M{m001:Calculator}
Function§F{id:name:visibility}§F{f001:Add:pub}
Async Function§AF{id:name:visibility}§AF{f001:FetchAsync:pub}
Method§MT{id:name:visibility}§MT{mt001:Process:pub}
Async Method§AMT{id:name:visibility}§AMT{mt001:ProcessAsync:pub}
Await§AWAIT expr§AWAIT §C{GetAsync} §/C
Lambda (inline)(params) → expr(x) → (* x 2)
Lambda (block)§LAM{id:params}...§/LAM{id}§LAM{l1:x:i32}...§/LAM{l1}
Delegate§DEL{id:name}...§/DEL{id}§DEL{d1:Handler}...§/DEL{d1}
Event§EVT{id:name:vis:type}§EVT{e1:Click:pub:EventHandler}
Subscribe§SUB event handler§SUB btn.Click OnClick
Unsubscribe§UNSUB event handler§UNSUB btn.Click OnClick
Input§I{type:name}§I{i32:x}
Output§O{type}§O{i32}
Effects§E{codes}§E{cw,fs:r,net:rw}
Requires§Q expr§Q (>= x 0)
Ensures§S expr§S (>= result 0)
For Loop§L{id:var:from:to:step}§L{l1:i:1:100:1}
While Loop§WH{id} condition§WH{w1} (> i 0)
Do-While Loop§DO{id}...§/DO{id} cond§DO{d1}...§/DO{d1} (< i 10)
If/ElseIf/Else§IF...§EI...§EL§IF (> x 0) → §R x §EL → §R 0
Call§C{target}...§/C§C{Math.Max} §A 1 §A 2 §/C
C# Attribute[@Name] or [@Name(args)][@HttpPost], [@Route("api")]
Print§P expr§P "Hello"
Return§R expr§R (+ a b)
Binding§B{name} expr§B{x} (+ 1 2)
Operations(op args...)(+ a b), (== x 0)
Close tag§/X{id}§/F{f001}
List§LIST{id:type}§LIST{nums:i32}
Dictionary§DICT{id:kType:vType}§DICT{ages:str:i32}
HashSet§HSET{id:type}§HSET{tags:str}
Key-Value§KV key value§KV "alice" 30
Push§PUSH{coll} value§PUSH{nums} 5
Put§PUT{dict} key value§PUT{ages} "bob" 25
Set Index§SETIDX{list} idx val§SETIDX{nums} 0 10
Contains§HAS{coll} value§HAS{nums} 5
Count§CNT{coll}§CNT{nums}
Dict Foreach§EACHKV{id:k:v} dict§EACHKV{e1:k:v} ages
Switch§W{id} expr§W{sw1} score
Case§K pattern → result§K 200 → "OK"
Wildcard§K _§K _ → "default"
Relational§PREL{op} value§PREL{gte} 90
Var Pattern§VAR{name}§VAR{n}
Guard§WHEN condition§WHEN (> n 0)

Types

TypeDescriptionC# Equivalent
i3232-bit integerint
i6464-bit integerlong
f3232-bit floatfloat
f6464-bit floatdouble
strStringstring
boolBooleanbool
voidNo return valuevoid
?TOptional TT? (nullable)
T!EResult (T or error E)Result\<T, E\>

Operators

CategoryOperators
Arithmetic+, -, *, /, %
Comparison==, !=, <, <=, >, >=
Logical&&, ||, !

All operators use Lisp-style prefix notation: (+ a b), (&& x y)


Effect Codes

CodeEffectDescription
cwConsole writeConsole.WriteLine
crConsole readConsole.ReadLine
fs:wFilesystem writeFile system writes
fs:rFilesystem readFile system reads
fs:rwFilesystem read/writeFile system read and write
net:rNetwork readHTTP GET, etc.
net:wNetwork writeHTTP POST, etc.
net:rwNetwork read/writeHTTP, sockets, etc.
db:rDatabase readDatabase queries
db:wDatabase writeDatabase mutations
db:rwDatabase read/writeDatabase operations

ID Conventions

ElementConventionExample
Modulesm001, m002§M{m001:Calculator}
Functionsf001, f002§F{f001:Add:pub}
Loopsfor1, while1, do1§L{for1:i:1:10:1}
Conditionalsif1, if2§IF{if1} condition

Complete Example

Plain Text
§M{m001:FizzBuzz}
§F{f001:Main:pub}
  §O{void}
  §E{cw}
  §L{for1:i:1:100:1}
    §IF{if1} (== (% i 15) 0) → §P "FizzBuzz"
    §EI (== (% i 3) 0) → §P "Fizz"
    §EI (== (% i 5) 0) → §P "Buzz"
    §EL → §P i
    §/I{if1}
  §/L{for1}
§/F{f001}
§/M{m001}

Detailed Reference