diff --git a/README.md b/README.md index 9b99eaa..396e0d8 100644 --- a/README.md +++ b/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). +![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) +
Must use `var` to define variables 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 , limit 10, total 12):
-
Stack overflow crash info +
Stack overflow Here is an example of stack overflow: @@ -895,6 +894,8 @@ local (0x7fffe0ffedf0 ) ## __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: diff --git a/doc/README_zh.md b/doc/README_zh.md index 64b1302..a9e0718 100644 --- a/doc/README_zh.md +++ b/doc/README_zh.md @@ -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) +
必须用 var 定义变量 这个解释器使用了更加严格的语法检查来保证你可以更轻松地debug。这是非常有必要的严格,否则debug会非常痛苦。 @@ -721,6 +719,8 @@ code: undefined symbol "arg" ## __堆栈追踪信息__ +![stackoverflow](../doc/gif/stackoverflow.gif) + 当解释器崩溃时,它会反馈错误产生过程的堆栈追踪信息:
内置函数 die @@ -847,6 +847,8 @@ local (0x7fffe0ffedf0 ) ## __调试器__ +![dbg](../doc/gif/dbg.gif) + 在`v8.0`版本中我们添加了调试器。 使用这个命令`./nasal -dbg xxx.nas`来启用调试器,接下来调试器会打开文件并输出以下内容: diff --git a/doc/dev.md b/doc/dev.md index f2a1fb6..19fb01b 100644 --- a/doc/dev.md +++ b/doc/dev.md @@ -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. diff --git a/doc/dev_zh.md b/doc/dev_zh.md index 66670ec..eb5b7ce 100644 --- a/doc/dev_zh.md +++ b/doc/dev_zh.md @@ -91,6 +91,8 @@ __该项目于2019/7/25正式开始__。 ## __字节码虚拟机__ +![op](../doc/gif/opcode.gif) + ### version 4.0 vm (last update 2020/12/17) 我在这个版本实现了第一版字节码虚拟机。不过这个虚拟机仍然在测试中,在这次测试结束之后,我会发布v4.0发行版。 diff --git a/doc/gif/dbg.gif b/doc/gif/dbg.gif new file mode 100644 index 0000000..58b2525 Binary files /dev/null and b/doc/gif/dbg.gif differ diff --git a/doc/gif/error.gif b/doc/gif/error.gif new file mode 100644 index 0000000..56f2545 Binary files /dev/null and b/doc/gif/error.gif differ diff --git a/doc/gif/help.gif b/doc/gif/help.gif new file mode 100644 index 0000000..d5f07e6 Binary files /dev/null and b/doc/gif/help.gif differ diff --git a/doc/gif/opcode.gif b/doc/gif/opcode.gif new file mode 100644 index 0000000..e83383b Binary files /dev/null and b/doc/gif/opcode.gif differ diff --git a/doc/gif/stackoverflow.gif b/doc/gif/stackoverflow.gif new file mode 100644 index 0000000..1eed940 Binary files /dev/null and b/doc/gif/stackoverflow.gif differ diff --git a/nasal_vm.h b/nasal_vm.h index f929af8..57fe49d 100644 --- a/nasal_vm.h +++ b/nasal_vm.h @@ -219,7 +219,7 @@ void nasal_vm::traceback() if(same) std::cout <<" 0x"<