📝 add interesting gifs into docs

This commit is contained in:
ValKmjolnir 2022-09-13 23:00:48 +08:00
parent 0e682b7c07
commit 518ce7fcb9
11 changed files with 32 additions and 25 deletions

View File

@ -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).
![usage](./doc/gif/help.gif)
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__
![error](./doc/gif/error.gif)
<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__
![stackoverflow](./doc/gif/stackoverflow.gif)
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__
![dbg](./doc/gif/dbg.gif)
We added a debugger in `v8.0`.
Use command `./nasal -dbg xxx.nas` to use the debugger,
and the debugger will print this:

View File

@ -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程序。
![usage](../doc/gif/help.gif)
下面这个命令可以用于查看使用方法:
> ./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解释器的不同之处__
![error](../doc/gif/error.gif)
<details><summary>必须用 var 定义变量</summary>
这个解释器使用了更加严格的语法检查来保证你可以更轻松地debug。这是非常有必要的严格否则debug会非常痛苦。
@ -721,6 +719,8 @@ code: undefined symbol "arg"
## __堆栈追踪信息__
![stackoverflow](../doc/gif/stackoverflow.gif)
当解释器崩溃时,它会反馈错误产生过程的堆栈追踪信息:
<details><summary>内置函数 die</summary>
@ -847,6 +847,8 @@ local (0x7fffe0ffedf0 <sp+45>)
## __调试器__
![dbg](../doc/gif/dbg.gif)
在`v8.0`版本中我们添加了调试器。
使用这个命令`./nasal -dbg xxx.nas`来启用调试器,接下来调试器会打开文件并输出以下内容:

View File

@ -99,6 +99,8 @@ it will be harder for me to make the bytecode vm become more efficient.
## __Bytecode Virtual Machine__
![op](../doc/gif/opcode.gif)
### version 4.0 vm (last update 2020/12/17)
I have just finished the first version of bytecode-interpreter.

View File

@ -91,6 +91,8 @@ __该项目于2019/7/25正式开始__。
## __字节码虚拟机__
![op](../doc/gif/opcode.gif)
### version 4.0 vm (last update 2020/12/17)
我在这个版本实现了第一版字节码虚拟机。不过这个虚拟机仍然在测试中在这次测试结束之后我会发布v4.0发行版。

BIN
doc/gif/dbg.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 KiB

BIN
doc/gif/error.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
doc/gif/help.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 KiB

BIN
doc/gif/opcode.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

BIN
doc/gif/stackoverflow.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

View File

@ -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";
}

View File

@ -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');