Skip to content

Commit a160a50

Browse files
added more methods
1 parent 57a532d commit a160a50

38 files changed

+737
-307
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,12 @@ For a more extensive look into Qi, go to the [Language Guide]().
146146
- [x] Quick Start
147147
- [x] Language Guide
148148
- [x] Escape Sequences
149-
- [ ] Bitwise operators
150-
- [ ] Remove semicolons
151-
- [ ] Support scientific notation, binary, etc. numbers
152-
- [ ] More string methods
153-
- [ ] More list methods
149+
- [x] Bitwise operators
150+
- [x] Remove semicolons
151+
- [x] Support scientific notation, binary, etc. numbers
152+
- [x] More string methods
153+
- [x] More list methods
154+
- [ ] Modules system
154155
155156
156157

README.zh.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,12 @@ All 274 tests passed (641 expectations).
142142
- [x] 入门
143143
- [x] 语言指南
144144
- [x] 转义序列
145-
- [ ] 按位运算符
146-
- [ ] 删除分号
147-
- [ ] 支持科学记数法、二进制等数字
148-
- [ ] 更多字符串方法
149-
- [ ] 更多列表方法
145+
- [x] 按位运算符
146+
- [x] 删除分号
147+
- [x] 支持科学记数法、二进制等数字
148+
- [x] 更多字符串方法
149+
- [x] 更多列表方法
150+
- [ ] 模块系统
150151

151152

152153
<!-- CONTRIBUTING -->

docs/README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ After reading an article on how programming languages are created, I was inspire
1818

1919
**Why name it Qi?** Qi was derived from the pinyin of the Chinese character "气", which means "air" in English. I wanted this language to be quick and lightweight, as well as fully transparent, just like air!
2020
```c
21-
打印行("你好,世界"
21+
系统。打印行("你好,世界"
2222
```
2323
### Features
2424
- Qi is <ins>Chinese-based</ins>. Us English-speaking people don't often take for granted the fact that the programming languages we learn are all based on native tongues we're already fluent in. A native English speaker can reasonably infer what a piece of Python code does just from reading the keywords ("if", "int", "while", etc.). Making this language foreign-based allows programming to be more accessible to more people around the globe.
@@ -62,11 +62,12 @@ For a more extensive look into Qi, go to the [Language Guide](syntax.md).
6262
- [x] Quick Start
6363
- [x] Language Guide
6464
- [x] Escape Sequences
65-
- [ ] Bitwise operators
66-
- [ ] Remove semicolons
67-
- [ ] Support scientific notation, binary, etc. numbers
68-
- [ ] More string methods
69-
- [ ] More list methods
65+
- [x] Bitwise operators
66+
- [x] Remove semicolons
67+
- [x] Support scientific notation, binary, etc. numbers
68+
- [x] More string methods
69+
- [x] More list methods
70+
- [ ] Modules system
7071

7172
<!-- LICENSE -->
7273
## License

docs/boolean.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# 布尔
22
Booleans can only have 2 values: 真 (true) or 假 (false). The value expresses the validity of a condition.
33
```c
4-
打印行(真 和 真) // 真 because both statements are true.
5-
打印行(真 和 假) // 假 because one of the statements are false.
6-
打印行(真 或 假) // 真 because one of the statements is true.
7-
打印行(假 或 假) // 假 because none of the statements are true.
4+
系统。打印行(真 和 真) // 真 because both statements are true.
5+
系统。打印行(真 和 假) // 假 because one of the statements are false.
6+
系统。打印行(真 或 假) // 真 because one of the statements is true.
7+
系统。打印行(假 或 假) // 假 because none of the statements are true.
88
```

docs/class.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,31 @@ Methods are functions that are declared within a class and adds functionality to
1515
```c
1616
类 树 「
1717
功能 打印()「
18-
打印行("我是一个树!"
18+
系统。打印行("我是一个树!"
1919
2020
2121

2222
变量 式 = 树()
23-
打印行(式。打印()) // 我是一个树!
23+
系统。打印行(式。打印()) // 我是一个树!
2424
```
2525
Like regular functions, you can add parameters to methods.
2626
```c
2727
类 树 「
2828
功能 打印(形容)「
29-
打印行("我是一个" + 形容 + "树!"
29+
系统。打印行("我是一个" + 形容 + "树!"
3030
3131
3232

3333
变量 式 = 树()
34-
打印行(式。打印("")) // 我是一个大树!
34+
系统。打印行(式。打印("")) // 我是一个大树!
3535
```
3636

3737
## Constructors
3838
Constructors are called on initialization of a new object in a class. This is usually where class properties are declared and initialized. You are allowed to pass custom parameters into the constructor.
3939
```c
4040
类 树 「
4141
初始化(高度)「
42-
打印行("初始化新树"
42+
系统。打印行("初始化新树"
4343
4444
4545

@@ -67,7 +67,7 @@ To get a property of an object, specify the object name and the property, separa
6767
6868

6969
变量 式 = 树(3
70-
打印行(式。高度) // 3
70+
系统。打印行(式。高度) // 3
7171
```
7272
To set a property of an object, do the same thing that you would do with a normal variable using a ```=``` operator.
7373
```c
@@ -78,9 +78,9 @@ To set a property of an object, do the same thing that you would do with a norma
7878
7979

8080
变量 式 = 树(3
81-
打印行(式。高度) // 3
81+
系统。打印行(式。高度) // 3
8282
式。高度 = 4
83-
打印行(式。高度) // 4
83+
系统。打印行(式。高度) // 4
8484
```
8585
#### 这 (this) Keyword
8686
The keyword `````` is used to specify that the variable you are accessing or modifying belongs to the enclosing class. This is especially useful in constructors, where the compiler may not be able to differentiate between the constructor parameter and the class property.
@@ -90,7 +90,7 @@ The keyword ```这``` is used to specify that the variable you are accessing or
9090
这。高度 = 高度
9191
9292
多高()「
93-
打印行(这。高度)
93+
系统。打印行(这。高度)
9494
9595
9696
```
@@ -102,23 +102,23 @@ To specify a parent class, use the ```:``` operator.
102102
```c
103103
类 树 「
104104
功能 打印()「
105-
打印行("我是一个树!"
105+
系统。打印行("我是一个树!"
106106
107107
108108

109109
类 橡木:树「
110110
111111

112112
变量 式 = 橡木()
113-
打印行(式。打印()) // 我是一个树!
113+
系统。打印行(式。打印()) // 我是一个树!
114114
```
115115
When a class inherits from a superclass, all of the parent class's methods and properties are "passed down" to the child class.
116116
#### 超 (super) Keyword
117117
The keyword `````` is used within child classes to execute methods that they inherited from parent classes. This is useful when you are trying to execute a method when you want to access the superclass method being overridden.
118118
```c
119119
类 树 「
120120
功能 打印(种)「
121-
打印行("我是一个" + 种 + "树!"
121+
系统。打印行("我是一个" + 种 + "树!"
122122
123123
124124

@@ -129,5 +129,5 @@ The keyword ```超``` is used within child classes to execute methods that they
129129
130130

131131
变量 式 = 橡木()
132-
打印行(式。打印()) // 我是一个橡木树!
132+
系统。打印行(式。打印()) // 我是一个橡木树!
133133
```

docs/control_flow.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,32 @@ Control flow is used to determine which chunks of code are executed and how many
55
It is often useful to execute different pieces of code based on certain conditions. You might want to run an extra piece of code when an error occurs, or to display a message when a value becomes too high or too low. To do this, you make parts of your code conditional. In its simplest form, the ```如果``` statement has a single if condition. It executes a set of statements only if that condition is true:
66
```c
77
如果(真)「
8-
打印行("会打印"// 会打印
8+
系统。打印行("会打印"// 会打印
99
1010
如果(假)「
11-
打印行("不会打印"// Won't print because statement is 假.
11+
系统。打印行("不会打印"// Won't print because statement is 假.
1212
1313
```
1414
#### 否则 (else) Statement
1515
The ```如果``` statement can provide an alternative set of statements, known as an else clause, for situations when the if condition is false. These statements are indicated by the ```否则``` keyword:
1616
```c
1717
如果(假)「
18-
打印行("不会打印"// Won't print because statement is 假.
18+
系统。打印行("不会打印"// Won't print because statement is 假.
1919
」否则「
20-
打印行("会打印"// 会打印
20+
系统。打印行("会打印"// 会打印
2121
2222
```
2323
#### 如果 否则 (if else) Statement
2424
To chain extra conditions after the previous ones fail, you can combine the else clause with the if condition, forming ```否则 如果```.
2525
```c
2626
如果(假)「
27-
打印行("不会打印"// Won't print because statement is 假.
27+
系统。打印行("不会打印"// Won't print because statement is 假.
2828
」否则 如果(真)「
29-
打印行("会打印"// 会打印
29+
系统。打印行("会打印"// 会打印
3030
」否则 如果(真)「
31-
打印行("不会打印"// Won't print because previous condition evaluated to 真.
31+
系统。打印行("不会打印"// Won't print because previous condition evaluated to 真.
3232
」否则「
33-
打印行("不会打印"// Won't print because an if condition evaluated to 真.
33+
系统。打印行("不会打印"// Won't print because an if condition evaluated to 真.
3434
3535
```
3636

@@ -39,25 +39,25 @@ There are many situations in which you need to match a specific value to many, m
3939
```c
4040
变量 数字 = 6
4141
如果(数字 等 0)「
42-
打印行(""
42+
系统。打印行(""
4343
4444
否则 如果(数字 等 1)「
45-
打印行(""
45+
系统。打印行(""
4646
4747
否则 如果(数字 等 2)「
48-
打印行(""
48+
系统。打印行(""
4949
5050
否则 如果(数字 等 3)「
51-
打印行(""
51+
系统。打印行(""
5252
5353
否则 如果(数字 等 4)「
54-
打印行(""
54+
系统。打印行(""
5555
5656
否则 如果(数字 等 5)「
57-
打印行(""
57+
系统。打印行(""
5858
5959
否则 如果(数字 等 6)「
60-
打印行(""
60+
系统。打印行(""
6161
6262
// Output: 六
6363
```
@@ -68,25 +68,25 @@ Make sure to include a ```打断``` (break) statement at the end of the case if
6868
变量 数字 = 6
6969
切换(数字)「
7070
案例 0
71-
打印行(""
71+
系统。打印行(""
7272
打断
7373
案例 1
74-
打印行(""
74+
系统。打印行(""
7575
打断
7676
案例 2
77-
打印行(""
77+
系统。打印行(""
7878
打断
7979
案例 3
80-
打印行(""
80+
系统。打印行(""
8181
打断
8282
案例 4
83-
打印行(""
83+
系统。打印行(""
8484
打断
8585
案例 5
86-
打印行(""
86+
系统。打印行(""
8787
打断
8888
案例 6
89-
打印行(""
89+
系统。打印行(""
9090
打断
9191
9292
// Output: 六
@@ -97,28 +97,28 @@ The ```预设``` statement is executed if the inputted value does not match any
9797
变量 数字 = 7
9898
切换(数字)「
9999
案例 0
100-
打印行(""
100+
系统。打印行(""
101101
打断
102102
案例 1
103-
打印行(""
103+
系统。打印行(""
104104
打断
105105
案例 2
106-
打印行(""
106+
系统。打印行(""
107107
打断
108108
案例 3
109-
打印行(""
109+
系统。打印行(""
110110
打断
111111
案例 4
112-
打印行(""
112+
系统。打印行(""
113113
打断
114114
案例 5
115-
打印行(""
115+
系统。打印行(""
116116
打断
117117
案例 6
118-
打印行(""
118+
系统。打印行(""
119119
打断
120120
预设:
121-
打印行("未知数字"
121+
系统。打印行("未知数字"
122122
打断
123123
124124
// Output: 未知数字
@@ -134,10 +134,10 @@ If you want the code in the next case to be executed if the current case passes,
134134
案例 3
135135
案例 4
136136
案例 5
137-
打印行("在1到5之间"
137+
系统。打印行("在1到5之间"
138138
打断
139139
预设:
140-
打印行("没有在1到5之间"
140+
系统。打印行("没有在1到5之间"
141141
打断
142142
143143
// Output: 在1到5之间

docs/function.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Functions are pieces of code that you can execute in various areas of a program.
55
To declare a function, use the ```功能``` keyword followed by the function name:
66
```c
77
功能 说你好()「
8-
打印行("你好"
8+
系统。打印行("你好"
99
1010

1111
说你好() // 你好
@@ -17,7 +17,7 @@ To pass values to a function, you can provide a parameter list in the function d
1717
Parameters can be added by listing out argument names separated by commas (,).
1818
```c
1919
功能 说你好(名字)「
20-
打印行("你好" + 名字)
20+
系统。打印行("你好" + 名字)
2121
2222

2323
说你好("世界"// 你好世界
@@ -31,7 +31,7 @@ Functions without the ```返回``` (return) keyword returns ```空``` by default
3131
返回 数字 + 1
3232
3333

34-
打印行(加一(1)) // 2
34+
系统。打印行(加一(1)) // 2
3535
```
3636

3737
## Recursion
@@ -42,5 +42,5 @@ Function recursion is fully supported in Qi:
4242
返回 斐波(数字 - 2) + 斐波(数字 - 1
4343
4444

45-
打印行(斐波(20)) // 6765
45+
系统。打印行(斐波(20)) // 6765
4646
```

0 commit comments

Comments
 (0)