docs: 重构循环和条件语句的命名

- 将 loop 语句中的 initializer 改为 init
- 将 condition 改为 cond
- 将 update 改为 step
- 更新了相关文档和示例代码
This commit is contained in:
Luke 2025-07-14 23:45:22 +08:00
parent e18d7426bc
commit e2896eb37d
2 changed files with 11 additions and 11 deletions

View File

@ -391,11 +391,11 @@ module: Math
body:
declare num1:int = 1
loop:
initializer:
init:
declare counter:int = 1
condition:
cond:
counter <= n
update:
step:
counter = counter + 1
body:
num1 = num1 * counter

View File

@ -102,14 +102,14 @@ x = y + 1
if 语句的形式如下else 是可选的:
```snow
if condition then
if cond then
// 条件成立执行的代码
else
// 以上条件不成立执行的代码
end if
```
condition 可以是表达式(结果为 bool 类型)或者 bool 字面量
cond 可以是表达式(结果为 bool 类型)或者 bool 字面量
例:
@ -134,14 +134,14 @@ end module
loop 语句的形式如下:
```snow
loop:
initializer:
init:
// 循环开始前可声明循环变量,有且只能声明一个
declare i: int = 1
condition:
cond:
// 循环条件,成立则执行 body 的代码,
// 不成立则退出循环,有且只能写一条
i <= 100
update:
step:
// 循环体执行完后执行的代码,有且只能写一条
i = i + 1
body:
@ -158,11 +158,11 @@ module: Main
body:
declare sum: int = 0
loop:
initializer:
init:
declare i: int = 1
condition:
cond:
i <= 100
update:
step:
i = i + 1
body:
sum = sum + i