-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhello.duang
More file actions
82 lines (71 loc) · 2.02 KB
/
hello.duang
File metadata and controls
82 lines (71 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
这是我的第一个duang程序,
现在就在你面前,
非喜勿喷,
欢迎大家多提语法方面的建议。
*/
// 单行注释将会被忽略
fn 左边(){
print("中华人民共和国万岁")
}
fn 右边(){
print("世界人民大团结万岁")
}
fn 测试表达式(){
let a = 1 + 1
print(a)
let b = 4 * 2
print(b)
let c = 2.2 + 2.0
print(c)
let d = 1 == 1
print(d)
}
fn 测试变量类型(){
let d :int = 1 + 1
print(d)
let a: float = 1.3 * 2.0
print(a)
let b: bool = 1 > 2
print(b)
}
/*
* 多行的
* 注释
* 将会被忽略
* 支持中文字符
*/
// 支持函数声明
fn 天安门(){
// 支持函数嵌套调用,支持省略函数调用末尾的;
print("我爱北京天安门")
左边()
右边()
}
fn 测试call(){
let result = call("cal")
print("下面是call的结果\n",result)
print("可以执行任意命令,获取结果\n",call("ls -l /tmp"))
let me = call("whoami")
printf("我的名字是\"%s\"\n", me)
printf("当前登录用户有\n%s\n", call("who"))
}
fn main(){
// 支持函数调用
天安门()
print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
测试表达式()
print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
测试变量类型()
print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
测试call()
print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
print("调用go写的函数,虽然调用方式还不是很完美,函数签名受到限制但是终于能调用了!!!!!")
// 支持引入go语言写的函数了!!!!
// 支持任意位置导入
import "test_data/src/github.com/gocode/hello/hello.go"
print(hello::hello("你好呀,go语言"))
print(hello::channel("go chan支持测试"))
print(hello::testStd("支持go标准库了"))
print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
}