You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/overview.md
+15-15Lines changed: 15 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ nav:
8
8
9
9
# MCFPP Overview
10
10
11
-
Before the start: sentences of mcfpp is end up with semicolon.
11
+
Before the start: statements of mcfpp is end up with semicolon.
12
12
13
13
## Project information file in JSON format<Badgetype="tip">WIP</Badge>
14
14
@@ -43,7 +43,7 @@ Project information file is situated on root of engineering catalogue, As an ent
43
43
44
44
### Variables
45
45
46
-
Declare : `type identifier (= expr)?;`
46
+
Defination : `type identifier (= expr)?;`
47
47
48
48
Such as : `int i = 5 + p;`,`int x,y,z;`
49
49
@@ -76,11 +76,11 @@ During Compiling, If any variable has been defined as literal, like `int i = 5;`
76
76
77
77
- const
78
78
79
-
`const` means a variable is always constant. That is, its value is given during compilation, and never changes. Such as `const int i = 5;`, `i` will be seem as constant during compiling. Constant is always static during compiling, and its value must be clear when we declare it, can't assign after declaring.
79
+
`const` means a variable is always constant. That is, its value is given during compilation, and never changes. Such as `const int i = 5;`, `i` will be seem as constant during compiling. Constant is always static during compiling, and its value must be clear when we define it, can't assign after declaring.
80
80
81
81
- import <Badgetype="warning">Deprecated</Badge>
82
82
83
-
`import` means a variable is import variable, it's value is imported from other place. Such as `import int i;`, `i` will be seen as import variable after compile. Often, variable only can be used after assignment, but if we use `import` modifier, Then variable can be used after declaration without assignment.
83
+
`import` means a variable is import variable, it's value is imported from other place. Such as `import int i;`, `i` will be seen as import variable after compile. Often, variable only can be used after assignment, but if we use `import` modifier, Then variable can be used after defination without assignment.
Each file's namespace can be declared independently
137
+
Each file's namespace can be defined independently
138
138
139
139
```cpp
140
140
namespacexxx;
141
141
```
142
142
143
-
If the file haven't declared a separate namespace, the namespace defaults to the namespace set in the project configuration file.
143
+
If the file haven't define a separate namespace, the namespace defaults to the namespace set in the project configuration file.
144
144
145
145
## Function
146
146
@@ -156,7 +156,7 @@ func test(int i) -> int{
156
156
157
157
```
158
158
159
-
Function's namespace is decided by the file's namespace. If the file haven't declared a separate namespace, the namespace defaults to the namespace set in the project configuration file.
159
+
Function's namespace is decided by the file's namespace. If the file haven't defined a separate namespace, the namespace defaults to the namespace set in the project configuration file.
160
160
161
161
:::tip Tip
162
162
In mcfpp, function name can contains most utf-8 characters, but the compiled mcfunction's name will only contains characters, underline and numbers. The illegal characters will be replaced by `_uxxxx`.
@@ -291,15 +291,15 @@ class Student{
291
291
292
292
### Abstract
293
293
294
-
Add `abstract` keyword before class can declare the class as abstract class. Abstract function can't be instantiate.
294
+
Add `abstract` keyword before class can define the class as abstract class. Abstract function can't be instantiate.
295
295
296
-
Add `abstract` keyword before function can declare the function as abstract function. Abstract function can't include function body.
296
+
Add `abstract` keyword before function can define the function as abstract function. Abstract function can't include function body.
297
297
298
298
### Extension Function
299
299
300
-
Extension Function makes you can "add" function to current types. And don't need to create new derived type, recompile or change original data type by other methods. Extension function declares out of the class, but it also can be called, as other functions in the class.
300
+
Extension Function makes you can "add" function to current types. And don't need to create new derived type, recompile or change original data type by other methods. Extension function defined out of the class, but it also can be called, as other functions in the class.
301
301
302
-
Declares extension function in the form of `Class name.Function name`, for example:
302
+
Define extension function in the form of `Class name.Function name`, for example:
303
303
304
304
```cpp
305
305
namespacetest;
@@ -341,13 +341,13 @@ interface InterfaceName{
341
341
}
342
342
```
343
343
344
-
You can declare abstract function in the interface. Interface can inherit from other interfaces.
344
+
You can define abstract function in the interface. Interface can inherit from other interfaces.
345
345
346
346
## Template <Badgetype="tip">WIP</Badge>
347
347
348
348
Structure is a datatype that totally makes up by score board. So structure only can contain score board, that's `int` type variables as members.
349
349
350
-
When declaring field, we can ignore type ‘int'. Except this, structure is almost the same as class.
350
+
During the defination of field, we can ignore type ‘int'. Except this, structure is almost the same as class.
351
351
352
352
Here's an example of structure:
353
353
@@ -387,9 +387,9 @@ MNI is similar with the JNI in Java, is a kind of programming framework, makes t
387
387
388
388
### native function
389
389
390
-
native can be declared in classes or functions, Used to run a specific Java function when **compiling**.
390
+
native can be defined in classes or functions, Used to run a specific Java function when **compiling**.
`if` statement is a condition statement, it can used to determine a condition is true or false. If true, then the code in the `if` statement block will be execute. The grammar of `if` is:
`if` statement can be used together with `else` statement, `else` statement used to execute the code when the condition in `if`is false. The grammar of `if-else` is shown:
`condition` is a boolean expression, it’s value is `true` or `false`. If the value of `condition` is `true`, then `#code1‘ will be execute; Else, ’#code2‘ will be execute.
`condition` is an boolean expression, when `condition` is `true`, it’ll execute the code block in `#code`. Then, determine the value of `condition` again. If value of `condition` is `true`, then `#code` will be execute; loop again and again, until the value of `condition` is `false`.
`do-while` statement is similar with `while` statement, but no matter the condition is true or false, it’ll execute the statement in the loop once, and then determine the condition to see continue execution or not. The grammar of `do-while` is shown below:
60
60
61
61
```mcfpp
62
62
do{
63
63
#code
64
64
}while (condition);
65
65
```
66
66
67
-
## for语句
67
+
## for statement
68
68
69
-
`for`语句是循环的一种稍复杂的版本,它的语法如下:
69
+
`for` statement is a more complex version of loop, it’s grammar is:
`forinit` is an initialization expression, used to initialize loop variable. `condition` is a boolean expression, used to determine if the loop keeps going on. `forupdate` is a update expression, used to update the variable of the loop. `#code` represents the loop body, which is the code in the loop. The execute process of `for` is shown below:
1.Execute `forinit`, initialize the loop variable.
80
+
2.Determine the value of `condition`, if the value of `condition` is `true`, execute `#code`, then execute `forupdate`, to update the loop variable, and determine the value of `condition` again.
81
+
3.If the value of `condition` is `false`, exit the loop.
82
82
83
-
`for`循环中,`forinit`声明的变量只在`for`循环中有效。
83
+
In `for` loop, the declaration of variable `forinit` only valid in the `for` loop.
84
84
85
-
## break和continue语句
85
+
## break and continue statement
86
86
87
-
`break`语句用来跳出整个循环,`continue`语句用来跳过本次循环。例如:
87
+
`break` statement used to jump out the whole loop, `continue` statement used to skip the current loop. For example:
In this example, when the value of `i` is `5`, `break`will jump out of the loop; when the value of `i` is `3`, `continue` will jump this loop, go to the next loop directly. So, the change of I in each loop are:`0`,`1`,`2`,`4`,`5`, and finally jump out.
102
102
103
-
`break`和`continue`语句只能在循环中使用。
103
+
`break` and `continue` statement only can be used in the loop
In MCFPP, allows programming statements in the start of the file and don’t need to define extra function, that’s the top statement. Top statement places in a hidden function, each file have one and only one of this function, and it cannot be called externally. Its returned value’s type is `void`.
8
8
9
9
```mcfpp
10
10
print("Top statement");
@@ -14,9 +14,9 @@ func main(){
14
14
}
15
15
```
16
16
17
-
在编译后,会生成两个函数——分别对应main函数以及顶层语句对应的默认函数。
17
+
After compiling, it’ll form two functions —— corresponding to main function and the default functions of top statement respectively.
18
18
19
-
顶层语句只能在文件的开始编写,即在函数定义或类定义之前。顶层语句可以调用文件中声明的其他函数和类
19
+
Top statement only can program in the start of the file, which is before the defination of any functions or classes. Top statement can call the other functions and classes that’s defined in the file.
The namespace in MCFPP is same as the namespace in Minecraft. That means, namespace only can be the combination of lowercase letters, numbers, dots and underlines.
8
8
9
-
你可以在文件中声明一个命名空间,这样文件中的所有函数和变量都会被放置在这个命名空间中。例如:
9
+
You can declare a namespace in a file, so all functions and variables in the file will be placed in the namespace. For example:
10
10
11
11
```mcfpp
12
12
namespace test;
13
13
14
-
func test(){ # test:test函数
14
+
func test(){ # test:test function
15
15
print(i);
16
16
}
17
17
```
18
18
19
-
一个文件中只能声明一次命名空间。
19
+
You can only define namespace once in a file.
20
20
21
-
同样的,你也可以在项目配置文件中声明这个命名空间。
21
+
The same, you can also define this namespace in the project configuration file.
22
22
23
23
```json
24
24
{
@@ -31,7 +31,7 @@ func test(){ # test:test函数
31
31
"D:/workspace/mcfpp/another_project.json"
32
32
],
33
33
"targetPath":"./out",
34
-
//工程的默认命名空间。可选,默认为default // [!code focus]
34
+
//The default namespace of the project. Optional, default is ‘default’ // [!code focus]
`func` is the key word of function `functionName` is the identifier or name of the function, the following `parameter1, parameter2, ...` is the parameter list of the function,`returnType`is optional, which is the returned type of the function. Function body is a series of statements surrounded by `{}`. Here’s a example below:
The name of the function is `add`, it have two integer-type parameters `a` and `b`, return value is also integer type. Its function is add the two parameters and return them.
`return` is same as the `return` command in Minecraft, both used to return the returned value of the function. It’s grammar is `return expression;`, `expression` is an expression, it’s value is the returned value of the function.
If a function defined the type of the returned value, then each branch of it must have `return` statement, so the function must would return a value. And the value that `return` statement returned must have the same type as the type of return value of the function, or the subtype of the returned value’s type.
If a function haven’t defined the return value’s type, then the default is `void`, which won’t return any value. Now, `return` statement is still available, but its grammar becomes `return;`, without any expression. Its function is stop the function immediately.
In MCFPP, grammar of call function is the same as in C/Java
40
+
, that’s `functionName(parameter1, parameter2, ...);`. In it, the `functionName` is the name of function,`parameter1, parameter2, ...` are the parameters to the function, here’s the example:
40
41
41
42
```mcfpp
42
43
func test(){
43
-
print(add(1, 2)); #上面定义的add函数
44
+
print(add(1, 2)); #the add function defined before
In this example, `test` function called `add` function, and sent two parameters `1` and `2`. `add` function returns `3`, so the `test` function will print `3`.
48
49
49
-
## 函数的传参
50
+
## The argument of function
50
51
51
-
函数中,对参数的修改不会影响到函数外部的变量。例如:
52
+
In the function, the change to the parameter won’t affect the variables out of the function. For example:
0 commit comments