Draft specification, RFCs, reference registries and examples, plus the reference-implementation skeleton: build.zig, diagnostic envelope with error-code registry synced to docs, aji CLI, conformance runner with seed tests, CI and contributor docs.
52 lines
1.9 KiB
EBNF
52 lines
1.9 KiB
EBNF
(* Aji draft grammar sketch. This is intentionally incomplete until syntax stabilizes. *)
|
|
|
|
program = { module_decl | import_decl | type_decl | function_decl } ;
|
|
|
|
module_decl = "module" qualified_name ";" ;
|
|
import_decl = "use" qualified_name [ "as" identifier ] ";" ;
|
|
|
|
function_decl = [ "pub" ] [ "unsafe" ] "fn" identifier
|
|
[ generic_params ]
|
|
"(" [ parameter_list ] ")"
|
|
[ "->" type ]
|
|
effect_decl
|
|
[ contract_block ]
|
|
block ;
|
|
|
|
effect_decl = "effects" "[" [ effect_list ] "]" ;
|
|
|
|
parameter_list = parameter { "," parameter } ;
|
|
parameter = identifier ":" param_type ;
|
|
param_type = [ "move" ] type
|
|
| "ref" "<" type ">"
|
|
| "mut" "<" type ">" ;
|
|
|
|
type = primitive_type
|
|
| qualified_name
|
|
| "Option" "<" type ">"
|
|
| "Result" "<" type "," type ">"
|
|
| "Own" "<" type ">"
|
|
| "Island" "<" type ">"
|
|
| "Frozen" "<" type ">"
|
|
| "Arc" "<" type ">"
|
|
| "slice" "<" type ">"
|
|
| "slice_mut" "<" type ">"
|
|
| "ref" "<" type ">"
|
|
| "mut" "<" type ">"
|
|
| "[" type ";" integer_literal "]" ;
|
|
|
|
primitive_type = "bool" | "byte" | "void" | "never"
|
|
| "u8" | "u16" | "u32" | "u64" | "u128" | "usize"
|
|
| "i8" | "i16" | "i32" | "i64" | "i128" | "isize"
|
|
| "f32" | "f64" ;
|
|
|
|
block = "{" { statement } "}" ;
|
|
statement = let_stmt | var_stmt | return_stmt | expr_stmt | block ;
|
|
let_stmt = "let" identifier [ ":" type ] "=" expression ";" ;
|
|
var_stmt = "var" identifier [ ":" type ] "=" expression ";" ;
|
|
return_stmt = "return" [ expression ] ";" ;
|
|
expr_stmt = expression ";" ;
|
|
|
|
qualified_name = identifier { "." identifier } ;
|
|
identifier = letter { letter | digit | "_" } ;
|