v0.13.2Control flow and dataflow are rebuilt on explicit semantics, Z3 translation matches executable C# numeric rules, and the build chain is hermetic and supply-chain verified with hash- and size-pinned Z3 binaries.See what's new

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. Reviewers still need to understand the contracts, effects, and verification results they approve. Stable IDs enable precise references, indentation defines structural scope, and Lisp-style expressions avoid operator-precedence ambiguity.


Quick Reference Table

ElementSyntaxExample
Module§M{name}§M{Calculator}
Function§F{name:visibility}§F{Add:pub}
Async Function§AF{name:visibility}§AF{FetchAsync:pub}
Method§MT{name:visibility}§MT{Process:pub}
Async Method§AMT{name:visibility}§AMT{ProcessAsync:pub}
Await§AWAIT expr§AWAIT §C{GetAsync} §/C
Lambda (inline)(params) → expr(x) → (* x 2)
Lambda (block)§LAM{params} (indented body)§LAM{x:i32}
Delegate§DEL{name} (indented signature)§DEL{Handler}
Event§EVT{name:vis:type}§EVT{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{var:from:to:step}§L{i:1:100:1}
While Loop§WH condition§WH (> i 0)
Do-While Loop§DO (body indented)§DO then §WHILE cond
If/ElseIf/Else§IF cond then §EI / §EL at same column§IF (> x 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)
Block enddedent (Python-style)(no §/X needed)
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

Stable IDs are optional on structural openers and are auto-assigned by the parser when omitted. Provide an explicit ID only when you want to reference the element from external tooling (e.g. calor navigate).

ElementAuto-assigned formExplicit form
Modules§M{Calculator}§M{m001:Calculator}
Functions§F{Add:pub}§F{f001:Add:pub}
Loops§L{i:1:10:1}§L{for1:i:1:10:1}
Conditionals§IF cond§IF{if1} cond

Complete Example

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

Blocks are delimited by indentation (default 2 spaces per nesting level). Legacy structural closers raise Calor0830; migrate them with calor fix --heal-closers. See Structure Tags for details.


Detailed Reference