From 62f58cd83a48a6504dd1a6791e52b2eb030ea7e5 Mon Sep 17 00:00:00 2001 From: zhangxun <1958638841@qq.com> Date: Mon, 4 Aug 2025 14:52:02 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=20BugFarm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- playground/BugFarm/Bug1/Main.snow | 2 +- playground/BugFarm/Bug2/Main.snow | 2 +- playground/BugFarm/Bug2/OS.snow | 4 ++-- playground/BugFarm/Bug3/Main.snow | 2 +- playground/BugFarm/Bug3/OS.snow | 4 ++-- playground/BugFarm/Bug4/Main.snow | 2 +- playground/BugFarm/Bug4/a.snow | 2 +- playground/BugFarm/Bug4/b.snow | 2 +- playground/BugFarm/Bug5/Main.snow | 4 ++-- playground/BugFarm/Bug5/OS.snow | 4 ++-- playground/BugFarm/Bug6/Main.snow | 4 ++-- playground/BugFarm/Bug6/OS.snow | 4 ++-- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/playground/BugFarm/Bug1/Main.snow b/playground/BugFarm/Bug1/Main.snow index 3468433..df241ed 100644 --- a/playground/BugFarm/Bug1/Main.snow +++ b/playground/BugFarm/Bug1/Main.snow @@ -1,6 +1,6 @@ module: Main function: main - return_type: void + returns: void body: declare abc:int =1 end body diff --git a/playground/BugFarm/Bug2/Main.snow b/playground/BugFarm/Bug2/Main.snow index 674b74b..023a778 100644 --- a/playground/BugFarm/Bug2/Main.snow +++ b/playground/BugFarm/Bug2/Main.snow @@ -1,7 +1,7 @@ module: Main import: os function: main - return_type: void + returns: void body: loop: init: diff --git a/playground/BugFarm/Bug2/OS.snow b/playground/BugFarm/Bug2/OS.snow index 6026d43..1982627 100644 --- a/playground/BugFarm/Bug2/OS.snow +++ b/playground/BugFarm/Bug2/OS.snow @@ -1,9 +1,9 @@ module: os import: os function: print - parameter: + params: declare i1: int - return_type: void + returns: void body: syscall("PRINT",i1) end body diff --git a/playground/BugFarm/Bug3/Main.snow b/playground/BugFarm/Bug3/Main.snow index 7918328..7f76773 100644 --- a/playground/BugFarm/Bug3/Main.snow +++ b/playground/BugFarm/Bug3/Main.snow @@ -1,7 +1,7 @@ module: Main import: os function: main - return_type: void + returns: void body: // 合法 declare b1: byte = 127b diff --git a/playground/BugFarm/Bug3/OS.snow b/playground/BugFarm/Bug3/OS.snow index 6026d43..1982627 100644 --- a/playground/BugFarm/Bug3/OS.snow +++ b/playground/BugFarm/Bug3/OS.snow @@ -1,9 +1,9 @@ module: os import: os function: print - parameter: + params: declare i1: int - return_type: void + returns: void body: syscall("PRINT",i1) end body diff --git a/playground/BugFarm/Bug4/Main.snow b/playground/BugFarm/Bug4/Main.snow index 0efa4b1..6333a4d 100644 --- a/playground/BugFarm/Bug4/Main.snow +++ b/playground/BugFarm/Bug4/Main.snow @@ -1,7 +1,7 @@ module: Main import: ModuleB function: main - return_type: int + returns: int body: return ModuleB.fun() end body diff --git a/playground/BugFarm/Bug4/a.snow b/playground/BugFarm/Bug4/a.snow index d717032..56799b4 100644 --- a/playground/BugFarm/Bug4/a.snow +++ b/playground/BugFarm/Bug4/a.snow @@ -1,6 +1,6 @@ module: ModuleA function: fun - return_type: int + returns: int body: return 123 end body diff --git a/playground/BugFarm/Bug4/b.snow b/playground/BugFarm/Bug4/b.snow index 4db51a0..8f25548 100644 --- a/playground/BugFarm/Bug4/b.snow +++ b/playground/BugFarm/Bug4/b.snow @@ -1,7 +1,7 @@ module: ModuleB import: ModuleA function: fun - return_type: int + returns: int body: return ModuleA.fun() + ModuleA.fun() end body diff --git a/playground/BugFarm/Bug5/Main.snow b/playground/BugFarm/Bug5/Main.snow index 89c6c84..d517949 100644 --- a/playground/BugFarm/Bug5/Main.snow +++ b/playground/BugFarm/Bug5/Main.snow @@ -3,8 +3,8 @@ module: Main globals: declare sum: int = 0 function: main - parameter: - return_type: int + params: + returns: int body: sum = 20 diff --git a/playground/BugFarm/Bug5/OS.snow b/playground/BugFarm/Bug5/OS.snow index 6026d43..1982627 100644 --- a/playground/BugFarm/Bug5/OS.snow +++ b/playground/BugFarm/Bug5/OS.snow @@ -1,9 +1,9 @@ module: os import: os function: print - parameter: + params: declare i1: int - return_type: void + returns: void body: syscall("PRINT",i1) end body diff --git a/playground/BugFarm/Bug6/Main.snow b/playground/BugFarm/Bug6/Main.snow index 7a5bdae..34768c6 100644 --- a/playground/BugFarm/Bug6/Main.snow +++ b/playground/BugFarm/Bug6/Main.snow @@ -3,8 +3,8 @@ module: Main globals: declare sum: int = 123 function: main - parameter: - return_type: int + params: + returns: int body: os.print(sum) return 0 diff --git a/playground/BugFarm/Bug6/OS.snow b/playground/BugFarm/Bug6/OS.snow index 6026d43..1982627 100644 --- a/playground/BugFarm/Bug6/OS.snow +++ b/playground/BugFarm/Bug6/OS.snow @@ -1,9 +1,9 @@ module: os import: os function: print - parameter: + params: declare i1: int - return_type: void + returns: void body: syscall("PRINT",i1) end body From 9f3b3ad860eb8387f9eb6da6e015a926bbfd8bd9 Mon Sep 17 00:00:00 2001 From: zhangxun <1958638841@qq.com> Date: Mon, 4 Aug 2025 14:52:13 +0800 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=20Demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- playground/Demo/Demo1/Main.snow | 2 +- playground/Demo/Demo1/Math.snow | 4 ++-- playground/Demo/Demo10/Main.snow | 2 +- playground/Demo/Demo11/Main.snow | 2 +- playground/Demo/Demo12/Main.snow | 4 ++-- playground/Demo/Demo13/Main.snow | 2 +- playground/Demo/Demo14/Main.snow | 2 +- playground/Demo/Demo14/OS.snow | 4 ++-- playground/Demo/Demo15/Main.snow | 4 ++-- playground/Demo/Demo15/OS.snow | 4 ++-- playground/Demo/Demo16/Main.snow | 2 +- playground/Demo/Demo16/OS.snow | 4 ++-- playground/Demo/Demo17/Main.snow | 2 +- playground/Demo/Demo17/OS.snow | 4 ++-- playground/Demo/Demo18/Main.snow | 2 +- playground/Demo/Demo18/OS.snow | 4 ++-- playground/Demo/Demo19/Main.snow | 2 +- playground/Demo/Demo19/OS.snow | 4 ++-- playground/Demo/Demo2/Main.snow | 4 ++-- playground/Demo/Demo20/Main.snow | 2 +- playground/Demo/Demo20/OS.snow | 4 ++-- playground/Demo/Demo21/Main.snow | 4 ++-- playground/Demo/Demo21/OS.snow | 4 ++-- playground/Demo/Demo3/Main.snow | 4 ++-- playground/Demo/Demo4/Main.snow | 4 ++-- playground/Demo/Demo5/Main.snow | 4 ++-- playground/Demo/Demo6/Main.snow | 4 ++-- playground/Demo/Demo7/Main.snow | 4 ++-- playground/Demo/Demo8/Main.snow | 4 ++-- playground/Demo/Demo9/Main.snow | 8 ++++---- 30 files changed, 52 insertions(+), 52 deletions(-) diff --git a/playground/Demo/Demo1/Main.snow b/playground/Demo/Demo1/Main.snow index 9058208..090e5ac 100644 --- a/playground/Demo/Demo1/Main.snow +++ b/playground/Demo/Demo1/Main.snow @@ -1,7 +1,7 @@ module: Main import:Math function: main - return_type: int + returns: int body: Math.add(6,1) return 0 diff --git a/playground/Demo/Demo1/Math.snow b/playground/Demo/Demo1/Math.snow index 2e5963e..099c244 100644 --- a/playground/Demo/Demo1/Math.snow +++ b/playground/Demo/Demo1/Math.snow @@ -1,9 +1,9 @@ module: Math function: add - parameter: + params: declare n1: int declare n2: int - return_type: int + returns: int body: return n1 + n2 end body diff --git a/playground/Demo/Demo10/Main.snow b/playground/Demo/Demo10/Main.snow index de91d63..c5ee595 100644 --- a/playground/Demo/Demo10/Main.snow +++ b/playground/Demo/Demo10/Main.snow @@ -1,5 +1,5 @@ function: main - return_type: int + returns: int body: declare res: boolean = 8L > 7L if res then diff --git a/playground/Demo/Demo11/Main.snow b/playground/Demo/Demo11/Main.snow index 3dd121d..a64b5c8 100644 --- a/playground/Demo/Demo11/Main.snow +++ b/playground/Demo/Demo11/Main.snow @@ -1,5 +1,5 @@ function: main - return_type: int + returns: int body: return 65537 end body diff --git a/playground/Demo/Demo12/Main.snow b/playground/Demo/Demo12/Main.snow index 134096c..cadccb5 100644 --- a/playground/Demo/Demo12/Main.snow +++ b/playground/Demo/Demo12/Main.snow @@ -1,6 +1,6 @@ module: Main function: main - return_type: int + returns: int body: foo() @@ -9,7 +9,7 @@ module: Main end function function: foo - return_type: int + returns: int body: if false then return 1 diff --git a/playground/Demo/Demo13/Main.snow b/playground/Demo/Demo13/Main.snow index 7b6479b..92dd51e 100644 --- a/playground/Demo/Demo13/Main.snow +++ b/playground/Demo/Demo13/Main.snow @@ -1,6 +1,6 @@ module: Main function: main - return_type: int + returns: int body: 5 == 7 5 == 7s diff --git a/playground/Demo/Demo14/Main.snow b/playground/Demo/Demo14/Main.snow index 7bb005a..88322e4 100644 --- a/playground/Demo/Demo14/Main.snow +++ b/playground/Demo/Demo14/Main.snow @@ -1,7 +1,7 @@ module: Main import: os function: main - return_type: void + returns: void body: os.print(222) end body diff --git a/playground/Demo/Demo14/OS.snow b/playground/Demo/Demo14/OS.snow index 6026d43..1982627 100644 --- a/playground/Demo/Demo14/OS.snow +++ b/playground/Demo/Demo14/OS.snow @@ -1,9 +1,9 @@ module: os import: os function: print - parameter: + params: declare i1: int - return_type: void + returns: void body: syscall("PRINT",i1) end body diff --git a/playground/Demo/Demo15/Main.snow b/playground/Demo/Demo15/Main.snow index 65533fe..3ddb8b4 100644 --- a/playground/Demo/Demo15/Main.snow +++ b/playground/Demo/Demo15/Main.snow @@ -3,7 +3,7 @@ module: Main globals: declare num2:int=10 function: main - return_type: void + returns: void body: declare num1:int=11 os.print(num1+num2+abc()) @@ -11,7 +11,7 @@ module: Main end function function: abc - return_type: int + returns: int body: return 1 end body diff --git a/playground/Demo/Demo15/OS.snow b/playground/Demo/Demo15/OS.snow index 6026d43..1982627 100644 --- a/playground/Demo/Demo15/OS.snow +++ b/playground/Demo/Demo15/OS.snow @@ -1,9 +1,9 @@ module: os import: os function: print - parameter: + params: declare i1: int - return_type: void + returns: void body: syscall("PRINT",i1) end body diff --git a/playground/Demo/Demo16/Main.snow b/playground/Demo/Demo16/Main.snow index 4aa7b8d..6a85f02 100644 --- a/playground/Demo/Demo16/Main.snow +++ b/playground/Demo/Demo16/Main.snow @@ -1,7 +1,7 @@ module: Main import: os function: main - return_type: int + returns: int body: loop: init: diff --git a/playground/Demo/Demo16/OS.snow b/playground/Demo/Demo16/OS.snow index 6026d43..1982627 100644 --- a/playground/Demo/Demo16/OS.snow +++ b/playground/Demo/Demo16/OS.snow @@ -1,9 +1,9 @@ module: os import: os function: print - parameter: + params: declare i1: int - return_type: void + returns: void body: syscall("PRINT",i1) end body diff --git a/playground/Demo/Demo17/Main.snow b/playground/Demo/Demo17/Main.snow index 8c15d75..ecce2ae 100644 --- a/playground/Demo/Demo17/Main.snow +++ b/playground/Demo/Demo17/Main.snow @@ -1,7 +1,7 @@ module: Main import: os function: main - return_type: int + returns: int body: loop: init: diff --git a/playground/Demo/Demo17/OS.snow b/playground/Demo/Demo17/OS.snow index 6026d43..1982627 100644 --- a/playground/Demo/Demo17/OS.snow +++ b/playground/Demo/Demo17/OS.snow @@ -1,9 +1,9 @@ module: os import: os function: print - parameter: + params: declare i1: int - return_type: void + returns: void body: syscall("PRINT",i1) end body diff --git a/playground/Demo/Demo18/Main.snow b/playground/Demo/Demo18/Main.snow index 107f100..520803c 100644 --- a/playground/Demo/Demo18/Main.snow +++ b/playground/Demo/Demo18/Main.snow @@ -1,7 +1,7 @@ module: Main import: os function: main - return_type: int + returns: int body: loop: init: diff --git a/playground/Demo/Demo18/OS.snow b/playground/Demo/Demo18/OS.snow index 6026d43..1982627 100644 --- a/playground/Demo/Demo18/OS.snow +++ b/playground/Demo/Demo18/OS.snow @@ -1,9 +1,9 @@ module: os import: os function: print - parameter: + params: declare i1: int - return_type: void + returns: void body: syscall("PRINT",i1) end body diff --git a/playground/Demo/Demo19/Main.snow b/playground/Demo/Demo19/Main.snow index 5bcef84..e8aabfa 100644 --- a/playground/Demo/Demo19/Main.snow +++ b/playground/Demo/Demo19/Main.snow @@ -1,7 +1,7 @@ module: Main import: os function: main - return_type: void + returns: void body: declare n: int[][][][] = [ [ diff --git a/playground/Demo/Demo19/OS.snow b/playground/Demo/Demo19/OS.snow index 6026d43..1982627 100644 --- a/playground/Demo/Demo19/OS.snow +++ b/playground/Demo/Demo19/OS.snow @@ -1,9 +1,9 @@ module: os import: os function: print - parameter: + params: declare i1: int - return_type: void + returns: void body: syscall("PRINT",i1) end body diff --git a/playground/Demo/Demo2/Main.snow b/playground/Demo/Demo2/Main.snow index 1b1833f..a0f1396 100644 --- a/playground/Demo/Demo2/Main.snow +++ b/playground/Demo/Demo2/Main.snow @@ -1,7 +1,7 @@ module: Main function: main - parameter: - return_type: int + params: + returns: int body: return (1+2) / 3 * 4 + 2 *2 end body diff --git a/playground/Demo/Demo20/Main.snow b/playground/Demo/Demo20/Main.snow index c3ba2e4..e442ff4 100644 --- a/playground/Demo/Demo20/Main.snow +++ b/playground/Demo/Demo20/Main.snow @@ -1,7 +1,7 @@ module: Main import:os function: main - return_type: void + returns: void body: declare arr: int[] = [1, 2, 3] arr[0] = 5 diff --git a/playground/Demo/Demo20/OS.snow b/playground/Demo/Demo20/OS.snow index 6026d43..1982627 100644 --- a/playground/Demo/Demo20/OS.snow +++ b/playground/Demo/Demo20/OS.snow @@ -1,9 +1,9 @@ module: os import: os function: print - parameter: + params: declare i1: int - return_type: void + returns: void body: syscall("PRINT",i1) end body diff --git a/playground/Demo/Demo21/Main.snow b/playground/Demo/Demo21/Main.snow index f3b11ce..4ad4c48 100644 --- a/playground/Demo/Demo21/Main.snow +++ b/playground/Demo/Demo21/Main.snow @@ -3,8 +3,8 @@ module: Main globals: declare sum: int = 123 function: main - parameter: - return_type: int + params: + returns: int body: declare arr: int[][][][][][][][][][][][][][][][][][][][][][] = [[[[[[[[[[[[[[[[[[[[[[1], [2], [3]]]]]]]]]]]]]]]]]]]]]] loop: diff --git a/playground/Demo/Demo21/OS.snow b/playground/Demo/Demo21/OS.snow index 6026d43..1982627 100644 --- a/playground/Demo/Demo21/OS.snow +++ b/playground/Demo/Demo21/OS.snow @@ -1,9 +1,9 @@ module: os import: os function: print - parameter: + params: declare i1: int - return_type: void + returns: void body: syscall("PRINT",i1) end body diff --git a/playground/Demo/Demo3/Main.snow b/playground/Demo/Demo3/Main.snow index 4a13b7d..6e9de28 100644 --- a/playground/Demo/Demo3/Main.snow +++ b/playground/Demo/Demo3/Main.snow @@ -1,7 +1,7 @@ module: Main function: main - parameter: - return_type: int + params: + returns: int body: declare n1: int =1 declare n2: int =2 diff --git a/playground/Demo/Demo4/Main.snow b/playground/Demo/Demo4/Main.snow index 60d39a4..aa376bc 100644 --- a/playground/Demo/Demo4/Main.snow +++ b/playground/Demo/Demo4/Main.snow @@ -1,7 +1,7 @@ module: Main function: main - parameter: - return_type: boolean + params: + returns: boolean body: declare b1: boolean =true diff --git a/playground/Demo/Demo5/Main.snow b/playground/Demo/Demo5/Main.snow index c475980..5a5c2b8 100644 --- a/playground/Demo/Demo5/Main.snow +++ b/playground/Demo/Demo5/Main.snow @@ -1,7 +1,7 @@ module: Main function: main - parameter: - return_type: int + params: + returns: int body: declare b1: boolean = true loop: diff --git a/playground/Demo/Demo6/Main.snow b/playground/Demo/Demo6/Main.snow index 71b29c5..0f3b2dc 100644 --- a/playground/Demo/Demo6/Main.snow +++ b/playground/Demo/Demo6/Main.snow @@ -1,7 +1,7 @@ module: Main function: main - parameter: - return_type: int + params: + returns: int body: declare b1 :int = -1 return b1 diff --git a/playground/Demo/Demo7/Main.snow b/playground/Demo/Demo7/Main.snow index aae7e15..f7e551c 100644 --- a/playground/Demo/Demo7/Main.snow +++ b/playground/Demo/Demo7/Main.snow @@ -1,7 +1,7 @@ module: Main function: main - parameter: - return_type: boolean + params: + returns: boolean body: declare b1 :boolean = true return !b1 diff --git a/playground/Demo/Demo8/Main.snow b/playground/Demo/Demo8/Main.snow index 8ff76af..e5260f4 100644 --- a/playground/Demo/Demo8/Main.snow +++ b/playground/Demo/Demo8/Main.snow @@ -1,7 +1,7 @@ module: Main function: main - parameter: - return_type: long + params: + returns: long body: declare n: long n = 2147483647 diff --git a/playground/Demo/Demo9/Main.snow b/playground/Demo/Demo9/Main.snow index 82a6dbf..61d51a8 100644 --- a/playground/Demo/Demo9/Main.snow +++ b/playground/Demo/Demo9/Main.snow @@ -1,7 +1,7 @@ module: Math function: main - parameter: - return_type: int + params: + returns: int body: Math.factorial(6) return 0 @@ -9,9 +9,9 @@ module: Math end function function: factorial - parameter: + params: declare n:int - return_type: int + returns: int body: declare num1:int = 1 loop: From 9a61798d81ae000f32fe6bca905fa29239c49ca4 Mon Sep 17 00:00:00 2001 From: zhangxun <1958638841@qq.com> Date: Mon, 4 Aug 2025 14:52:24 +0800 Subject: [PATCH 3/3] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=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)