Skip to content

Commit

Permalink
added more methods
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonymousAAArdvark committed Jan 13, 2023
1 parent 57a532d commit a160a50
Show file tree
Hide file tree
Showing 38 changed files with 737 additions and 307 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,12 @@ For a more extensive look into Qi, go to the [Language Guide]().
- [x] Quick Start
- [x] Language Guide
- [x] Escape Sequences
- [ ] Bitwise operators
- [ ] Remove semicolons
- [ ] Support scientific notation, binary, etc. numbers
- [ ] More string methods
- [ ] More list methods
- [x] Bitwise operators
- [x] Remove semicolons
- [x] Support scientific notation, binary, etc. numbers
- [x] More string methods
- [x] More list methods
- [ ] Modules system
Expand Down
11 changes: 6 additions & 5 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,12 @@ All 274 tests passed (641 expectations).
- [x] 入门
- [x] 语言指南
- [x] 转义序列
- [ ] 按位运算符
- [ ] 删除分号
- [ ] 支持科学记数法、二进制等数字
- [ ] 更多字符串方法
- [ ] 更多列表方法
- [x] 按位运算符
- [x] 删除分号
- [x] 支持科学记数法、二进制等数字
- [x] 更多字符串方法
- [x] 更多列表方法
- [ ] 模块系统


<!-- CONTRIBUTING -->
Expand Down
13 changes: 7 additions & 6 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ After reading an article on how programming languages are created, I was inspire

**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!
```c
打印行("你好,世界"
系统。打印行("你好,世界"
```
### Features
- 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.
Expand Down Expand Up @@ -62,11 +62,12 @@ For a more extensive look into Qi, go to the [Language Guide](syntax.md).
- [x] Quick Start
- [x] Language Guide
- [x] Escape Sequences
- [ ] Bitwise operators
- [ ] Remove semicolons
- [ ] Support scientific notation, binary, etc. numbers
- [ ] More string methods
- [ ] More list methods
- [x] Bitwise operators
- [x] Remove semicolons
- [x] Support scientific notation, binary, etc. numbers
- [x] More string methods
- [x] More list methods
- [ ] Modules system

<!-- LICENSE -->
## License
Expand Down
8 changes: 4 additions & 4 deletions docs/boolean.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 布尔
Booleans can only have 2 values: 真 (true) or 假 (false). The value expresses the validity of a condition.
```c
打印行(真 和 真) // 真 because both statements are true.
打印行(真 和 假) // 假 because one of the statements are false.
打印行(真 或 假) // 真 because one of the statements is true.
打印行(假 或 假) // 假 because none of the statements are true.
系统。打印行(真 和 真) // 真 because both statements are true.
系统。打印行(真 和 假) // 假 because one of the statements are false.
系统。打印行(真 或 假) // 真 because one of the statements is true.
系统。打印行(假 或 假) // 假 because none of the statements are true.
```
26 changes: 13 additions & 13 deletions docs/class.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,31 @@ Methods are functions that are declared within a class and adds functionality to
```c
类 树 「
功能 打印()「
打印行("我是一个树!"
系统。打印行("我是一个树!"

变量 式 = 树()
打印行(式。打印()) // 我是一个树!
系统。打印行(式。打印()) // 我是一个树!
```
Like regular functions, you can add parameters to methods.
```c
类 树 「
功能 打印(形容)「
打印行("我是一个" + 形容 + "树!"
系统。打印行("我是一个" + 形容 + "树!"

变量 式 = 树()
打印行(式。打印("")) // 我是一个大树!
系统。打印行(式。打印("")) // 我是一个大树!
```

## Constructors
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.
```c
类 树 「
初始化(高度)「
打印行("初始化新树"
系统。打印行("初始化新树"

Expand Down Expand Up @@ -67,7 +67,7 @@ To get a property of an object, specify the object name and the property, separa

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

变量 式 = 树(3
打印行(式。高度) // 3
系统。打印行(式。高度) // 3
式。高度 = 4
打印行(式。高度) // 4
系统。打印行(式。高度) // 4
```
#### 这 (this) Keyword
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.
Expand All @@ -90,7 +90,7 @@ The keyword ```这``` is used to specify that the variable you are accessing or
这。高度 = 高度
多高()「
打印行(这。高度)
系统。打印行(这。高度)
```
Expand All @@ -102,23 +102,23 @@ To specify a parent class, use the ```:``` operator.
```c
类 树 「
功能 打印()「
打印行("我是一个树!"
系统。打印行("我是一个树!"

类 橡木:树「

变量 式 = 橡木()
打印行(式。打印()) // 我是一个树!
系统。打印行(式。打印()) // 我是一个树!
```
When a class inherits from a superclass, all of the parent class's methods and properties are "passed down" to the child class.
#### 超 (super) Keyword
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.
```c
类 树 「
功能 打印(种)「
打印行("我是一个" + 种 + "树!"
系统。打印行("我是一个" + 种 + "树!"

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

变量 式 = 橡木()
打印行(式。打印()) // 我是一个橡木树!
系统。打印行(式。打印()) // 我是一个橡木树!
```
64 changes: 32 additions & 32 deletions docs/control_flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@ Control flow is used to determine which chunks of code are executed and how many
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:
```c
如果(真)「
打印行("会打印"// 会打印
系统。打印行("会打印"// 会打印
如果(假)「
打印行("不会打印"// Won't print because statement is 假.
系统。打印行("不会打印"// Won't print because statement is 假.
```
#### 否则 (else) Statement
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:
```c
如果(假)「
打印行("不会打印"// Won't print because statement is 假.
系统。打印行("不会打印"// Won't print because statement is 假.
」否则「
打印行("会打印"// 会打印
系统。打印行("会打印"// 会打印
```
#### 如果 否则 (if else) Statement
To chain extra conditions after the previous ones fail, you can combine the else clause with the if condition, forming ```否则 如果```.
```c
如果(假)「
打印行("不会打印"// Won't print because statement is 假.
系统。打印行("不会打印"// Won't print because statement is 假.
」否则 如果(真)「
打印行("会打印"// 会打印
系统。打印行("会打印"// 会打印
」否则 如果(真)「
打印行("不会打印"// Won't print because previous condition evaluated to 真.
系统。打印行("不会打印"// Won't print because previous condition evaluated to 真.
」否则「
打印行("不会打印"// Won't print because an if condition evaluated to 真.
系统。打印行("不会打印"// Won't print because an if condition evaluated to 真.
```

Expand All @@ -39,25 +39,25 @@ There are many situations in which you need to match a specific value to many, m
```c
变量 数字 = 6
如果(数字 等 0)「
打印行(""
系统。打印行(""
否则 如果(数字 等 1)「
打印行(""
系统。打印行(""
否则 如果(数字 等 2)「
打印行(""
系统。打印行(""
否则 如果(数字 等 3)「
打印行(""
系统。打印行(""
否则 如果(数字 等 4)「
打印行(""
系统。打印行(""
否则 如果(数字 等 5)「
打印行(""
系统。打印行(""
否则 如果(数字 等 6)「
打印行(""
系统。打印行(""
// Output: 六
```
Expand All @@ -68,25 +68,25 @@ Make sure to include a ```打断``` (break) statement at the end of the case if
变量 数字 = 6
切换(数字)「
案例 0
打印行(""
系统。打印行(""
打断
案例 1
打印行(""
系统。打印行(""
打断
案例 2
打印行(""
系统。打印行(""
打断
案例 3
打印行(""
系统。打印行(""
打断
案例 4
打印行(""
系统。打印行(""
打断
案例 5
打印行(""
系统。打印行(""
打断
案例 6
打印行(""
系统。打印行(""
打断
// Output: 六
Expand All @@ -97,28 +97,28 @@ The ```预设``` statement is executed if the inputted value does not match any
变量 数字 = 7
切换(数字)「
案例 0
打印行(""
系统。打印行(""
打断
案例 1
打印行(""
系统。打印行(""
打断
案例 2
打印行(""
系统。打印行(""
打断
案例 3
打印行(""
系统。打印行(""
打断
案例 4
打印行(""
系统。打印行(""
打断
案例 5
打印行(""
系统。打印行(""
打断
案例 6
打印行(""
系统。打印行(""
打断
预设:
打印行("未知数字"
系统。打印行("未知数字"
打断
// Output: 未知数字
Expand All @@ -134,10 +134,10 @@ If you want the code in the next case to be executed if the current case passes,
案例 3
案例 4
案例 5
打印行("在1到5之间"
系统。打印行("在1到5之间"
打断
预设:
打印行("没有在1到5之间"
系统。打印行("没有在1到5之间"
打断
// Output: 在1到5之间
Expand Down
8 changes: 4 additions & 4 deletions docs/function.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Functions are pieces of code that you can execute in various areas of a program.
To declare a function, use the ```功能``` keyword followed by the function name:
```c
功能 说你好()「
打印行("你好"
系统。打印行("你好"

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

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

打印行(加一(1)) // 2
系统。打印行(加一(1)) // 2
```

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

打印行(斐波(20)) // 6765
系统。打印行(斐波(20)) // 6765
```
Loading

0 comments on commit a160a50

Please sign in to comment.