Getting started
You'll need Git, PowerShell on Windows, and the .NET 10 SDK. Node.js is only needed to work on this documentation site.
Build the compiler
git clone https://github.com/ClemCa/world.execute-me-.git world-language
cd world-language
dotnet build compiler/WorldCompiler.csproj -c Release
This builds compiler/bin/Release/net10.0/wec.exe. Run it directly from the repository root:
.\compiler\bin\Release\net10.0\wec.exe check examples/budget.world
The examples below use compiler/run.ps1, which takes the same arguments and also works if the checkout folder contains a semicolon, as in world.execute(me);.
Run a sample
.\compiler\run.ps1 check examples/budget.world
.\compiler\run.ps1 run --input price=35 --detailed examples/budget.world
check validates the file without running it. With price=35, look for "balance": "65" and a purchased event in the JSON output.
Run it again with --input price=101. Each run starts at 100. This time when can(purchase()): skips the purchase, so the balance stays at 100 and the verdict is still true.
Your first program
Save this as door.world in the repository root:
input badge: valid | expired
slot door.position: closed | open = closed
action unlock():
requires badge is valid
switch door.position from closed to open
emit unlocked()
when can(unlock()):
unlock()
claim(door.position is open)
.\compiler\run.ps1 check door.world
.\compiler\run.ps1 run --input badge=valid door.world
.\compiler\run.ps1 run --no-prompt --trace door.world
With a valid badge the door opens and the claim returns true. Without a badge observation the door stays closed and the claim returns false (exit 1). Omit --no-prompt to enter a badge value in the terminal, or press Enter to leave it unknown.
Next, model changes and alternatives, or check and run from VS Code.