Skip to content

语法摘要

本文是声明形式的速查,不是完整文法。规范定义见语言规范的各节;两者冲突时以规范节为准。

Koine 的声明是平的。

声明

entity Name
value Name = { A, B, C }
value Name = { field: Type, ... }
value Name = { field: Type, ... } where condition
value Name = Type
value Name = Type where self op value
alias Name = Type
relation name(param: Type, ...)
state relation name(param: Type, ...) { key total (param) }
state relation name(param: Type, ...) { key partial (param) }
transition name(param: Type, ...) { ... }
axiom Name { formula }
define name(param: Type) -> Type { expr }
derived relation name(param: Type, ...) { formula }
derived relation name(param: Type, ...) key total (param) { formula }
derived relation name(param: Type, ...) key partial (param) { formula }
view name = { relation, ... }
init Name
init { ... }
state Name { ... }
scenario Name { ... }
module Name { ... }
quantity Name
quantity Name = dimension-expr
unit Name : Quantity = unit-expr

量纲与单位表达式

number
Name
Name * Name
Name / Name
Name ^ integer
number unit-expr
(unit-expr)

值构造与字段

Type { field: expr, ... }
expr.field
number unit-expr

transition body

require condition
relation(args)
not relation(args)
time = now() + duration

条件

运算符的类型规则、相等/排序、Decimal 除法和优先级见运算符。

relation(args)
relation(key) == value
not condition
condition and condition
condition or condition
condition implies condition
condition == condition
condition <= condition
forall (x: Type, y: Type). condition
exists (x: Type). condition

聚合

sum(expr for x: Type where condition)
count(x: Type where condition)
min(expr for x: Type where condition)
max(expr for x: Type where condition)
any(expr for x: Type where condition)
all(expr for x: Type where condition)

字面量

42
-1
100.50
"text"
true
false
2024-01-01
12:30:00
2024-01-01T12:30:00Z
30 days
Draft

输入关键词开始搜索…

↑↓ 选择↵ 打开Esc 关闭