98 lines
1.8 KiB
Plaintext
98 lines
1.8 KiB
Plaintext
==================
|
|
Core syntax
|
|
==================
|
|
|
|
io :: import "@std/io"
|
|
|
|
Status :: enum {
|
|
ok
|
|
bad
|
|
}
|
|
|
|
Pair :: struct {
|
|
left i32
|
|
right i32
|
|
}
|
|
|
|
sum func(a, b i32) i32 ! Status {
|
|
result :: a + b
|
|
if result > 0 {
|
|
return result
|
|
} else {
|
|
return .bad
|
|
}
|
|
}
|
|
|
|
---
|
|
|
|
(source_file
|
|
(import_declaration
|
|
(identifier)
|
|
(string
|
|
(string_content)))
|
|
(type_declaration
|
|
(identifier)
|
|
(enum_type
|
|
(enum_body
|
|
(enum_member
|
|
(identifier))
|
|
(enum_member
|
|
(identifier)))))
|
|
(type_declaration
|
|
(identifier)
|
|
(struct_type
|
|
(record_body
|
|
(record_field
|
|
(identifier)
|
|
(type
|
|
(builtin_type)))
|
|
(record_field
|
|
(identifier)
|
|
(type
|
|
(builtin_type))))))
|
|
(function_declaration
|
|
(identifier)
|
|
(parameter_list
|
|
(parameter
|
|
(identifier)
|
|
(identifier)
|
|
(type
|
|
(builtin_type))))
|
|
(type
|
|
(builtin_type))
|
|
(type
|
|
(named_type
|
|
(qualified_identifier
|
|
(identifier))))
|
|
(block
|
|
(statement
|
|
(constant_declaration
|
|
(identifier)
|
|
(expression
|
|
(binary_expression
|
|
(expression
|
|
(identifier))
|
|
(expression
|
|
(identifier))))))
|
|
(statement
|
|
(if_statement
|
|
(expression
|
|
(binary_expression
|
|
(expression
|
|
(identifier))
|
|
(expression
|
|
(integer))))
|
|
(statement
|
|
(block
|
|
(statement
|
|
(return_statement
|
|
(expression
|
|
(identifier))))))
|
|
(statement
|
|
(block
|
|
(statement
|
|
(return_statement
|
|
(expression
|
|
(enum_literal
|
|
(identifier))))))))))))
|