📝 add interesting gifs into docs
This commit is contained in:
parent
0e682b7c07
commit
518ce7fcb9
21
README.md
21
README.md
|
@ -26,7 +26,7 @@ __Contact us if having great ideas to share!__
|
|||
|
||||
## __Introduction__
|
||||
|
||||
__[Nasal](http://wiki.flightgear.org/Nasal_scripting_language)__
|
||||
[Nasal](http://wiki.flightgear.org/Nasal_scripting_language)
|
||||
is an ECMAscript-like language that used in [FlightGear](https://www.flightgear.org/).
|
||||
The designer is [Andy Ross](https://github.com/andyross).
|
||||
|
||||
|
@ -89,18 +89,13 @@ If you think `-O3` isn't that safe and stable, you could choose:
|
|||
|
||||
## __How to Use__
|
||||
|
||||
First we should learn how to write and run a program using this language,
|
||||
click to see the [__tutorial__](#tutorial).
|
||||

|
||||
|
||||
Use this command to get help:
|
||||
|
||||
> ./nasal -h
|
||||
|
||||
If your system is __`Windows`__ and you want to output unicode,please use this command before running nasal interpreter:
|
||||
If your system is `Windows` and you want to output unicode,please use this command before running nasal:
|
||||
|
||||
> chcp 65001
|
||||
|
||||
or you could write this in your nasal code:
|
||||
or you could write this in nasal code:
|
||||
|
||||
```javascript
|
||||
if(os.platform()=="windows")
|
||||
|
@ -704,6 +699,8 @@ If get this, Congratulations!
|
|||
|
||||
## __Difference Between Andy's and This Interpreter__
|
||||
|
||||

|
||||
|
||||
<details><summary>Must use `var` to define variables</summary>
|
||||
|
||||
This interpreter uses more strict syntax to make sure it is easier for you to program and debug.
|
||||
|
@ -768,6 +765,8 @@ code: undefined symbol "arg"
|
|||
|
||||
## __Trace Back Info__
|
||||
|
||||

|
||||
|
||||
When interpreter crashes,
|
||||
it will print trace back information:
|
||||
|
||||
|
@ -802,7 +801,7 @@ vm stack (0x7fffcd21bc68 <sp+80>, limit 10, total 12):
|
|||
|
||||
</details>
|
||||
|
||||
<details><summary>Stack overflow crash info</summary>
|
||||
<details><summary>Stack overflow</summary>
|
||||
|
||||
Here is an example of stack overflow:
|
||||
|
||||
|
@ -895,6 +894,8 @@ local (0x7fffe0ffedf0 <sp+45>)
|
|||
|
||||
## __Debugger__
|
||||
|
||||

|
||||
|
||||
We added a debugger in `v8.0`.
|
||||
Use command `./nasal -dbg xxx.nas` to use the debugger,
|
||||
and the debugger will print this:
|
||||
|
|
|
@ -26,13 +26,13 @@ __如果有好的意见或建议,欢迎联系我们!__
|
|||
|
||||
## __简介__
|
||||
|
||||
__[Nasal](http://wiki.flightgear.org/Nasal_scripting_language)__
|
||||
[Nasal](http://wiki.flightgear.org/Nasal_scripting_language)
|
||||
是一个与ECMAscript标准语法设计相似的编程语言,并且作为运行脚本被著名的开源飞行模拟器 [FlightGear](https://www.flightgear.org/) 所依赖。
|
||||
该语言的设计者和初版解释器实现者为 [Andy Ross](https://github.com/andyross)。
|
||||
该语言的设计者为 [Andy Ross](https://github.com/andyross)。
|
||||
|
||||
这个解释器项目则由 [ValKmjolnir](https://github.com/ValKmjolnir) 完全使用 `C++`(`-std=c++14`)重新实现,没有复用 [Andy Ross的nasal解释器](https://github.com/andyross/nasal) 中的任何一行代码。尽管没有任何的参考代码,我们依然非常感谢Andy为我们带来了这样一个神奇且容易上手的编程语言。
|
||||
该解释器项目由 [ValKmjolnir](https://github.com/ValKmjolnir) 完全使用 `C++`(`-std=c++14`)重新实现,没有复用 [Andy Ross的nasal解释器](https://github.com/andyross/nasal) 中的任何一行代码。尽管没有任何的参考代码,我们依然非常感谢Andy为我们带来了这样一个神奇且容易上手的编程语言。
|
||||
|
||||
该项目已经使用 __MIT__ 协议开源 (2021/5/4)。
|
||||
该项目已使用 __MIT__ 协议开源 (2021/5/4)。
|
||||
|
||||
__我们为什么想要重新写一个nasal解释器?__
|
||||
2019年暑假,[FGPRC](https://www.fgprc.org.cn/) 的成员告诉我,在Flightgear中提供的nasal控制台窗口中进行调试很不方便,仅仅是想检查语法错误,也得花时间打开软件等待加载进去后进行调试。所以我就写了一个全新的解释器来帮助他们检查语法错误,甚至是检查运行时的错误。
|
||||
|
@ -78,17 +78,13 @@ __注意__: 如果你想直接下载发行版提供的zip/tar.gz压缩包来构
|
|||
|
||||
## __使用方法__
|
||||
|
||||
首先我们要通过[__教程__](#教程)知道这个语言的语法以及如何使用这个解释器来运行nasal程序。
|
||||

|
||||
|
||||
下面这个命令可以用于查看使用方法:
|
||||
|
||||
> ./nasal -h
|
||||
|
||||
如果你的操作系统是 __`Windows`__ 并且你想输出unicode,请保证你的控制台程序的代码页支持utf-8,若不支持,使用下面这个命令启用代码页:
|
||||
如果你的操作系统是 `Windows` 且想输出unicode,请保证控制台代码页支持utf-8,使用下面这个命令启用代码页:
|
||||
|
||||
> chcp 65001
|
||||
|
||||
或者你可以直接在nasal代码里写这个来开启:
|
||||
或者直接在nasal代码里写这个来开启:
|
||||
|
||||
```javascript
|
||||
if(os.platform()=="windows")
|
||||
|
@ -666,6 +662,8 @@ dylib.dlclose(dlhandle);
|
|||
|
||||
## __与andy解释器的不同之处__
|
||||
|
||||

|
||||
|
||||
<details><summary>必须用 var 定义变量</summary>
|
||||
|
||||
这个解释器使用了更加严格的语法检查来保证你可以更轻松地debug。这是非常有必要的严格,否则debug会非常痛苦。
|
||||
|
@ -721,6 +719,8 @@ code: undefined symbol "arg"
|
|||
|
||||
## __堆栈追踪信息__
|
||||
|
||||

|
||||
|
||||
当解释器崩溃时,它会反馈错误产生过程的堆栈追踪信息:
|
||||
|
||||
<details><summary>内置函数 die</summary>
|
||||
|
@ -847,6 +847,8 @@ local (0x7fffe0ffedf0 <sp+45>)
|
|||
|
||||
## __调试器__
|
||||
|
||||

|
||||
|
||||
在`v8.0`版本中我们添加了调试器。
|
||||
使用这个命令`./nasal -dbg xxx.nas`来启用调试器,接下来调试器会打开文件并输出以下内容:
|
||||
|
||||
|
|
|
@ -99,6 +99,8 @@ it will be harder for me to make the bytecode vm become more efficient.
|
|||
|
||||
## __Bytecode Virtual Machine__
|
||||
|
||||

|
||||
|
||||
### version 4.0 vm (last update 2020/12/17)
|
||||
|
||||
I have just finished the first version of bytecode-interpreter.
|
||||
|
|
|
@ -91,6 +91,8 @@ __该项目于2019/7/25正式开始__。
|
|||
|
||||
## __字节码虚拟机__
|
||||
|
||||

|
||||
|
||||
### version 4.0 vm (last update 2020/12/17)
|
||||
|
||||
我在这个版本实现了第一版字节码虚拟机。不过这个虚拟机仍然在测试中,在这次测试结束之后,我会发布v4.0发行版。
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 867 KiB |
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
Binary file not shown.
After Width: | Height: | Size: 207 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.0 MiB |
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
|
@ -219,7 +219,7 @@ void nasal_vm::traceback()
|
|||
if(same)
|
||||
std::cout
|
||||
<<" 0x"<<std::hex<<std::setw(8)<<std::setfill('0')
|
||||
<<prev<<std::dec<<": "<<same<<" same call(s)\n";
|
||||
<<prev<<std::dec<<" "<<same<<" same call(s)\n";
|
||||
same=0;
|
||||
std::cout<<" "<<codestream(bytecode[p],p,num_table,str_table,files)<<"\n";
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var fib=func(x)
|
||||
{
|
||||
if(x<2) return x;
|
||||
return fib(x-1)+fib(x-2);
|
||||
if(x<2) return x;
|
||||
return fib(x-1)+fib(x-2);
|
||||
}
|
||||
for(var i=0;i<31;i+=1)
|
||||
print(fib(i),'\n');
|
||||
print(fib(i),'\n');
|
||||
|
Loading…
Reference in New Issue