Skip to content

Syntax & Comments

Use indentation for structure and comments for intent.

AAL uses indentation to delimit blocks. Here, if belongs to the ability and return belongs to its branch. A comment begins with # and does not execute.

Complete example

Save the example as syntax.aal

syntax.aal
agent Tutorial is Agent
  public
    ability run(name: String) -> String effects()
      # Return early when the name is empty.
      if name == ""
        return "Hello!"
      return "Hello, {name}!"
Download .aal

Syntax explained

  1. Indent with spaces, not tabs. Keep sibling statements aligned; these examples use two spaces per level.

  2. A colon at a block header is optional; this tutorial consistently omits it.

  3. Calls, lists and records may span lines within delimiters. Strings use double quotes.

Build and run

Terminal
cargo run --locked --bin aalc -- check syntax.aal

cargo run --locked --bin aalc -- build syntax.aal -o syntax.aalc

cargo run --locked --bin aalc -- run syntax.aalc \
  --agent Tutorial --ability run \
  --args '{"name":""}' \
  --state-dir .aal-tutorial/syntax --invocation syntax-1

Run with a fresh state directory. The returned value is shown below; the CLI also prints execution information.

Expected result
"Hello!"

Try it yourself

Change the empty name to EasyNet and use a new invocation ID. The first return is skipped and the result becomes Hello, EasyNet!.

Language source and specification