提交 2afee0ba 编写于 作者: chai2010's avatar chai2010

简化无参数和返回值函数定义

上级 078fe21b
......@@ -44,7 +44,7 @@ Instead of requiring complex toolchains to set up, you can simply go install it
打印字符和调用函数(Print rune and call function):
```
fn main() {
fn main {
print('凹')
print('语')
print('言')
......@@ -73,7 +73,7 @@ $ go run main.go hello.wa
```
# 版权 @2021 凹语言™ 作者。保留所有权利。
fn main() {
fn main {
for n := 2; n <= 30; n = n + 1 {
var isPrime int = 1
for i := 2; i*i <= n; i = i + 1 {
......
// 版权 @2021 凹语言 作者。保留所有权利。
package main
fn main() {
fn main {
a := 0.0
for y := 1.5; y > -1.5; y = y - 0.1 {
for x := -1.5; x < 1.5; x = x + 0.05 {
for y := 1.5; y > -1.5; y = y - 0.2 {
for x := -1.5; x < 1.5; x = x + 0.1 {
a = x*x + y*y - 1.0
if a*a*a < x*x*y*y*y {
print('@')
......
# 版权 @2019 凹语言 作者。保留所有权利。
fn main() {
fn main {
print('凹')
print('语')
print('言')
......
......@@ -935,6 +935,15 @@ func (p *parser) parseSignature(scope *ast.Scope) (params, results *ast.FieldLis
defer un(trace(p, "Signature"))
}
// 无参数和返回值时可省略 `()`
// fn main
// fn main { ... }
if p.tok == token.LBRACE || p.tok == token.EOF {
params = new(ast.FieldList)
results = new(ast.FieldList)
return
}
params = p.parseParameters(scope, true)
if p.tok == token.ARROW {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册