Skip to content

Commit

Permalink
added more static methods
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonymousAAArdvark committed Dec 13, 2022
1 parent f6f5d37 commit 224e19a
Showing 311 changed files with 2,132 additions and 1,813 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -30,7 +30,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.
2 changes: 1 addition & 1 deletion README.zh.md
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@

<ins>为什么叫「Qi」</ins>?Qi是从汉字的拼音中衍生出来的「气」, 这在英语中是「空气」的意思。我希望这种语言能够快速、轻巧,并且完全透明,就像空气一样!
```c
打印行("你好,世界"
打印行("你好,世界"
```
### 特征
-**在中文基础上**。说英语的人通常不会想当然地认为他们所学的编程语言都是基于他们已经很流利的母语。以英语为母语的人可以通过阅读关键字(“if”、“int”、“while” 等)合理地推断Python代码的功能。让这种语言以外语为基础,可以让全球更多的人更容易地使用编程。
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -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.
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.
```
54 changes: 27 additions & 27 deletions docs/class.md
Original file line number Diff line number Diff line change
@@ -15,82 +15,82 @@ 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
类 树 「
初始化(高度)「
打印行("初始化新树"
打印行("初始化新树"

变量 式 = 树() // 初始化新树
变量 式 = 树() // 初始化新树
```

## Properties
Properties are variables that are declared within a class that adds states to the objects that belong in that class.
```c
类 树 「
初始化(高度)「
这。高度 = 高度
这。高度 = 高度

变量 式 = 树(3
变量 式 = 树(3
```
#### Getting and Setting Properties
To get a property of an object, specify the object name and the property, separated by the `````` operator.
```c
类 树 「
初始化(高度)「
这。高度 = 高度
这。高度 = 高度

变量 式 = 树(3
打印行(式。高度) // 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
类 树 「
初始化(高度)「
这。高度 = 高度
这。高度 = 高度

变量 式 = 树(3
打印行(式。高度) // 3
式。高度 = 4
打印行(式。高度) // 4
变量 式 = 树(3
打印行(式。高度) // 3
式。高度 = 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.
```c
类 树 「
初始化(高度)「
这。高度 = 高度
这。高度 = 高度
多高()「
打印行(这。高度)
打印行(这。高度)
```
@@ -102,32 +102,32 @@ 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
类 树 「
功能 打印(种)「
打印行("我是一个" + 种 + "树!"
打印行("我是一个" + 种 + "树!"

类 橡木:树「
功能 打印()「
超。打印("橡木"
超。打印("橡木"

变量 式 = 橡木()
打印行(式。打印()) // 我是一个橡木树!
变量 式 = 橡木()
打印行(式。打印()) // 我是一个橡木树!
```
89 changes: 53 additions & 36 deletions docs/control_flow.md
Original file line number Diff line number Diff line change
@@ -5,123 +5,140 @@ 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 真.
```

## 切换 (switch) Statement
There are many situations in which you need to match a specific value to many, many conditions. Sure, you can chain multiple ```如果``` statements, but up to a certain point the code becomes repetitive and hard to read:
```c
变量 数字 = 6
变量 数字 = 6
如果(数字 等 0)「
打印行(""
打印行(""
否则 如果(数字 等 1)「
打印行(""
打印行(""
否则 如果(数字 等 2)「
打印行(""
打印行(""
否则 如果(数字 等 3)「
打印行(""
打印行(""
否则 如果(数字 等 4)「
打印行(""
打印行(""
否则 如果(数字 等 5)「
打印行(""
打印行(""
否则 如果(数字 等 6)「
打印行(""
打印行(""
// Output: 六
```
To make the above code shorter, a ```切换``` statement could be used. The switch statement is given a value, and compares it to the ```案例``` statements. It will only execute the code if the value and the case matches.

Make sure to include a ```打断``` (break) statement at the end of the case if you don't want execution to jump into the next case.
```c
变量 数字 = 6
变量 数字 = 6
切换(数字)「
案例 0
打印行("");打断;
打印行(""
打断
案例 1
打印行("");打断;
打印行(""
打断
案例 2
打印行("");打断;
打印行(""
打断
案例 3
打印行("");打断;
打印行(""
打断
案例 4
打印行("");打断;
打印行(""
打断
案例 5
打印行("");打断;
打印行(""
打断
案例 6
打印行("");打断;
打印行(""
打断
// Output: 六
```
#### 预设 (default) Statement
The ```预设``` statement is executed if the inputted value does not match any of the ```案例``` statements.
```c
变量 数字 = 7
变量 数字 = 7
切换(数字)「
案例 0
打印行("");打断;
打印行(""
打断
案例 1
打印行("");打断;
打印行(""
打断
案例 2
打印行("");打断;
打印行(""
打断
案例 3
打印行("");打断;
打印行(""
打断
案例 4
打印行("");打断;
打印行(""
打断
案例 5
打印行("");打断;
打印行(""
打断
案例 6
打印行("");打断;
打印行(""
打断
预设:
打印行("未知数字");打断;
打印行("未知数字"
打断
// Output: 未知数字
```
#### Fallthrough Cases
If you want the code in the next case to be executed if the current case passes, simply remove the ```打断``` statement at the end of the case. This is useful if you want multiple value matches to execute the same code.
```c
变量 数字 = 1
变量 数字 = 1
切换(数字)「
案例 0
案例 1
案例 2
案例 3
案例 4
案例 5
打印行("在1到5之间");打断;
打印行("在1到5之间"
打断
预设:
打印行("没有在1到5之间");打断;
打印行("没有在1到5之间"
打断
// Output: 在1到5之间
```
Loading

0 comments on commit 224e19a

Please sign in to comment.