Chiba Logo CHIBA v0.6.13
CHIBA blog RSS feed
CHIBA / DOCS / LEVEL-1 SPEC

表达式优先级与结合性

这里集中展示 CHIBA level-1 specification,覆盖 core language、control flow、memory、patterns、IR lowering 与 package system 等实现边界。

The docs surface keeps CHIBA level-1 specification pages browsable inside the site, with direct paths into language, control flow, memory, pattern, and lowering rules.

表达式优先级与结合性

语法

表达式层需要给每类运算符与复合结构赋予优先级与结合性。

语义

优先级与结合性决定 parser 如何在不加括号时构造 AST。

这直接影响:

  • 普通表达式解析
  • operator overload 的表面行为
  • Pratt 风格表达式子系统

当前方向的最低几层优先级应明确为:

  1. 最弱:= 绑定/定义语法
  2. 倒数第二弱::=
  3. 倒数第三弱:|>

其中:

  • = 不作为普通 operator 进入表达式运算符体系
  • := 作为位置更新表达式进入优先级表
  • |> 作为显式续接表达式进入优先级表

边界

需要单独明确:

  • =:= 是否完全共享 parser 分层
  • method call / indexing / field access 的绑定强度
  • .*.、call、index 的优先级关系