From 4ae77434dce4b174601d4377bd3a6a0836a8805a Mon Sep 17 00:00:00 2001 From: zhangxun <1958638841@qq.com> Date: Mon, 4 Aug 2025 14:52:24 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 20 ++++++++--------- docs/Snow-Lang-Journey/Snow-Lang-Journey.md | 8 +++---- docs/Snow-Lang-Syntax/Snow-Lang-Syntax.md | 24 ++++++++++----------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index d2fd83b..d88a658 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ SnowVM) 的完整编译-执行链路。 Snow 语言受到 LLM 驱动代码生成趋势的启发,强调简单而清晰的语法和严格的类型系统,以帮助 LLM 更好地理解程序。 -语言使用显式的 `module` 声明来组织代码,用 `function`,`parameter`,`return_type`,`body` 等关键字分隔不同代码块,语法结构固定且易读。此外,Snow +语言使用显式的 `module` 声明来组织代码,用 `function`,`parameter`,`returns`,`body` 等关键字分隔不同代码块,语法结构固定且易读。此外,Snow 实现了语义分析来检查变量作用域和类型一致性,在编译阶段捕获错误并确保生成的中间代码正确无误。这种自上而下的编译流程,使得代码设计和生成更加模块化,可解释,也有利于调试和优化。 相关背景: [心路历程](docs/Snow-Lang-Journey/Snow-Lang-Journey.md) @@ -111,7 +111,7 @@ Snow 语言受到 LLM 驱动代码生成趋势的启发,强调简单而清晰的 module: Main import:Math function: main - return_type: int + returns: int body: Math.add(6,1) return 0 @@ -135,7 +135,7 @@ Snow 语言受到 LLM 驱动代码生成趋势的启发,强调简单而清晰的 3 15 IDENTIFIER main 3 19 NEWLINE \n - 4 9 KEYWORD return_type + 4 9 KEYWORD returns 4 20 COLON : 4 22 TYPE int 4 25 NEWLINE \n @@ -174,10 +174,10 @@ Snow 语言受到 LLM 驱动代码生成趋势的启发,强调简单而清晰的 #### Math.snow module: Math function: add - parameter: + params: declare n1: int declare n2: int - return_type: int + returns: int body: return n1 + n2 end body @@ -195,7 +195,7 @@ Snow 语言受到 LLM 驱动代码生成趋势的启发,强调简单而清晰的 2 15 IDENTIFIER add 2 18 NEWLINE \n - 3 9 KEYWORD parameter + 3 9 KEYWORD params 3 18 COLON : 3 19 NEWLINE \n @@ -211,7 +211,7 @@ Snow 语言受到 LLM 驱动代码生成趋势的启发,强调简单而清晰的 5 25 TYPE int 5 28 NEWLINE \n - 6 9 KEYWORD return_type + 6 9 KEYWORD returns 6 20 COLON : 6 22 TYPE int 6 25 NEWLINE \n @@ -494,7 +494,7 @@ Snow 语言受到 LLM 驱动代码生成趋势的启发,强调简单而清晰的 ```snow module: Math function: main - return_type: int + returns: int body: Math.factorial(6) return 0 @@ -502,9 +502,9 @@ module: Math end function function: factorial - parameter: + params: declare n:int - return_type: int + returns: int body: declare num1:int = 1 loop: diff --git a/docs/Snow-Lang-Journey/Snow-Lang-Journey.md b/docs/Snow-Lang-Journey/Snow-Lang-Journey.md index c203998..4c2c5a8 100644 --- a/docs/Snow-Lang-Journey/Snow-Lang-Journey.md +++ b/docs/Snow-Lang-Journey/Snow-Lang-Journey.md @@ -76,8 +76,8 @@ module: Main import:Math function: main - parameter: - return_type: int + params: + returns: int body: Math.factorial(6L,1L) @@ -90,10 +90,10 @@ end module ## 源代码 (test.snow) module: Math function: factorial - parameter: + params: declare n1: long declare n2: long - return_type: long + returns: long body: return n1+n2 end body diff --git a/docs/Snow-Lang-Syntax/Snow-Lang-Syntax.md b/docs/Snow-Lang-Syntax/Snow-Lang-Syntax.md index 169fdb1..057f1b8 100644 --- a/docs/Snow-Lang-Syntax/Snow-Lang-Syntax.md +++ b/docs/Snow-Lang-Syntax/Snow-Lang-Syntax.md @@ -7,7 +7,7 @@ ```snow module: Main function: main - return_type: int + returns: int body: return 1 + 1 @@ -116,7 +116,7 @@ cond 可以是表达式(结果为 bool 类型)或者 bool 字面量 ```snow module: Main function: main - return_type: int + returns: int body: if 5 > 7 then return 5 @@ -154,7 +154,7 @@ end loop ```snow module: Main function: main - return_type: int + returns: int body: declare sum: int = 0 loop: @@ -179,17 +179,17 @@ end module 函数的形式如下: ```snow function: add - parameter: + params: declare a: int declare b: int - return_type: int + returns: int body: return a + b end body end function ``` -其中 add 是函数名,parameter 下面是参数列表(可省略),与变量的定义类似,但是不允许赋初值, -接着 return_type 设置返回值类型,最后的 body 为函数体。 +其中 add 是函数名,params 下面是参数列表(可省略),与变量的定义类似,但是不允许赋初值, +接着 returns 设置返回值类型,最后的 body 为函数体。 ## 模块 @@ -202,7 +202,7 @@ snow 会自动将同名模块的函数合并。 ```snow module: Main function: main - return_type: int + returns: int body: return 1 + 1 @@ -218,10 +218,10 @@ end module // Math.snow module: Math function: add - parameter: + params: declare a: int declare b: int - return_type: int + returns: int body: return a + b end body @@ -235,7 +235,7 @@ end module module: Main import: Math function: main - return_type: int + returns: int body: return Math.add(5, 7) @@ -250,7 +250,7 @@ end module module: Main import: Math, Time function: main - return_type: int + returns: int body: return Math.add(5, 7)