Lexical Syntax
This section defines the lexical structure of AodhML — how source code is broken into tokens.
Whitespace
Whitespace (spaces, tabs, newlines) is significant only as a token separator. AodhML is not whitespace-sensitive — indentation is for readability only.
Comments
// Line comment — extends to end of line
/* Block comment — can span
multiple lines */
Identifiers
Identifiers begin with a letter or underscore, followed by letters, digits, or underscores:
valid_ident
_valid
alsoValid123
Valid_Identifier
Keywords
| Keyword | Purpose |
|---|---|
fn | Function declaration |
let | Immutable variable binding |
mut | Mutable variable binding |
type | Type alias or definition |
struct | Struct type |
enum | Enumeration type |
trait | Trait definition |
impl | Trait implementation |
import | Module import |
pub | Public visibility |
return | Return from function |
if, else | Conditional |
for, in | Iteration |
while | While loop |
match | Pattern matching |
break, continue | Loop control |
Operators
| Operator | Description | Precedence |
|---|---|---|
:: | Namespace / associated function | Highest |
. | Field access | Highest |
[] | Indexing | Highest |
() | Function call | Highest |
! | Logical NOT | Unary |
- | Negation | Unary |
*, /, % | Multiplication, division, modulo | High |
+, - | Addition, subtraction | Medium |
@ | Matrix multiplication | Medium |
==, != | Equality | Low |
<, >, <=, >= | Comparison | Low |
&& | Logical AND | Lower |
|| | Logical OR | Lowest |
= | Assignment | Lowest |
Literals
42 // i32 integer
42u64 // u64 integer
3.14 // f64 float
3.14f32 // f32 float
true // bool
"hello" // String
[1, 2, 3] // Array literal
{ a: 1 } // Struct literal