Syntax basics
This page covers the smallest pieces of AEL, the Agent Engineering Language: how source text will be written, how statements will end, and how names, literals and operators will work.
Status
Planned for AEL Beta 0.0.1. AEL is not available yet.
Package names on this page are preview naming and may change before launch.
Source text and names
- A source file will be UTF-8 text. Text and comments may use any Unicode characters; everything else will be ASCII.
- White space will be the space, the tab and the line break. Any other spacing character outside a string or a comment will be refused rather than silently read as a space.
- A name (an identifier) will be letters, digits and
_, and will not start with a digit:total,max_items,_draft. Names will be case-sensitive, sototalandTotaldiffer. - A reserved keyword will not be allowed as a name, but a name may start with one:
fnxandiffyare names. Keywords lists them. _on its own will be the wildcard of amatchpattern, never a name.printwill be a built-in name that you cannot declare again.
Comments
A # will start a comment that runs to the end of the line.
# The discount applies to every order line.
let rate: u64 = 10; # percent
A comment will also be able to span several lines: three backticks in a row open it, and the next three close it. Comments will not nest. Comments will stay in your source: compiled files and package files will carry none of their text.
Statements and blocks
- Every statement will end with
;. A line break will never end a statement. - Function bodies and the blocks of
if,else,whileandmatchwill be written in braces,{ … }. An empty block will be allowed. - A block will be able to stand on its own to limit where its names are visible.
- A function will not be allowed to be declared inside another function.
Bindings
let will bind a name to a value. The type will follow a colon; when the value makes the type clear, you will be able to leave it out.
let limit: u32 = 500;
let count = 4; # an integer literal on its own is an i64
let mut attempts: u8 = 0;
attempts = attempts + 1;
- A binding will not be able to change unless it is declared with
let mut. - A binding declared without a value will need its type, and will have to receive a value on every path before it is read. Ownership describes the rule.
- An inner block will be able to declare a name that hides an outer one. Declaring the same name twice in one block will be refused.
- A binding's name will become visible after its value, so in
let x: i64 = x + 1;thexon the right is an earlierx.
Literals
| Literal | Examples | Notes |
|---|---|---|
| Integer | 0, 42, 1_024 | Decimal only. A single _ may separate digits; leading zeros stay decimal. A minus sign is an operator, as in -5. |
| Boolean | true, false | Not an integer. |
| Text | "hello", "line\n" | Double-quoted UTF-8. It will need a bounded text type with room for it; see Types. |
The escapes in text will be \", \\, \n, \r, \t, \0 and \u{…} with one to six hexadecimal digits for a Unicode character. Any other escape, and a raw line break inside the quotes, will be refused.
Operators
From the tightest binding to the loosest:
| Operators | Meaning |
|---|---|
f(x), a.b, a[i] | Call, field, index |
-, !, ~, *, &, &mut | Negation, logical not, bitwise not, and the reference operators of Ownership |
*, /, % | Multiplication, division, remainder |
+, - | Addition, subtraction |
<<, >> | Shifts |
& | Bitwise and |
^ | Bitwise exclusive or |
| | Bitwise or |
<, <=, >, >= | Comparison |
==, != | Equality |
&& | Logical and |
|| | Logical or |
- Operators of one level will group from the left:
a - b - cwill be(a - b) - c. - Comparisons will not chain:
a < b < cwill be refused. Writea < b && b < c. &&and||will take booleans and evaluate their right side only when needed.!will take only a boolean.- Arithmetic, bitwise operators and ordered comparisons will take two integers of the same type. Errors and checked arithmetic describes overflow, division and shifts.
Order of evaluation
Evaluation will always run left to right. A call will evaluate all of its arguments, in order, before the function starts. An assignment will evaluate its target, such as values[i], before the value it stores.
Keywords
| Group | Keywords |
|---|---|
| Component roles | main, config, global, reuse, node, edge, agent, hook, and routes in a scope that selects the server/http package |
| Declarations and statements | fn, let, mut, return, if, else, while, match, true, false, type, struct, enum, as |
| File headers | import, refer, select |
| Records | pack, metadata |
The declaration and statement keywords, agent, config and import will be reserved and never usable as names. The other component roles, refer, select, pack and metadata will have their meaning where they start a declaration, a header entry or a record; which of them may also be used as names elsewhere will be confirmed when the syntax is final.
These will also be reserved, and not usable as names: pub, task, tool, service, prompt, region, await, unsafe, extern and static. Their use, if any, will be described when the syntax is final.
Formatting source describes how source will be formatted.