官方的stupyd编程语言包
stupyd的Python项目详细描述
笨蛋
stupyd是一种用于编程教育的高级解释编程语言。它的目的是有一个易于阅读的语法和有用的集成数据结构与相关的操作方法,以帮助其用户了解编程和其他相关的计算机科学概念。
您可以获得有关我们项目page的更多信息。
开始
这些说明将引导您在计算机上安装stupyd解释器。
先决条件
stupyd基于Python3,因此必须先安装python3(3.6.0或更高版本)。您可以使用:
➜ ~ python3 -V
stupyd解释器在pypi上发布,因此需要首先安装pip。您可以看到安装指南here
安装
我们的PYPI页面是here。您可以使用以下命令轻松安装stupyd解释器:
➜ ~ pip install stupyd
安装后,在终端中键入“stupyd”,您将看到:
➜ ~ stupyd
usage: stupyd [-h] filename
positional arguments:
filename path of source code
optional arguments:
-h, --help show this help message and exit
现在您可以在您的计算机上运行愚蠢的代码:)
运行代码
让我们写一个简单的“hello_world.s p”:
stringstr"hello, world"->strprint(str)
我们可以通过以下方式运行此代码:
➜ stupyd-lang git:(master) ✗ stupyd test/hello_world.sp
The stupyd-interpreter.
"hello, world!"
在本地机器上测试
由于此存储库中的所有代码都用于打包,因此不能直接运行它们。要测试代码,有两个方法。
在本地机器上重新打包
步骤1:在本地环境中重新打包
➜ stupyd-lang git:(master) ✗ python3 setup.py sdist bdsit_wheel
步骤2:使用pip安装本地控制盘
在开发过程中,我们在test/目录中编写一个run.py,非常简单。 你可以用它来测试。 在1.0.18版本中,可以使用stupyd debugger调试源文件。安装后,键入'spd'启动它,下面是一个示例: 现在它只是一个简单的功能不完整的调试器,我们稍后会做得更好。 有关stupyd字节码指令和stupyd解释器的更多信息将在稍后的项目page中更新。 这个项目是在麻省理工学院的许可下授权的-详细信息请参见LICENSE文件 我们是来自中国兰州大学School of Information Science and Engineering的一个小组。➜ stupyd-lang git:(master) ✗ pip3 install dist/stupyd-1.0.14-py3-none-any.whl
使用run.py
import sys
sys.path.append("..")
from stupyd.main import main
main()
➜ test git:(master) ✗ python3 run.py hello_world.sp
"hello, world!"
调试
➜ stupyd-lang git:(master) ✗ spd test/hello_world.sp
The stupyd-debugger. Type 'help' or '?' for help.
spd >> ?
Documented commands (type help <topic>):
========================================
break help info next quit
spd >> ? info
print program general info
spd >> info
constant space: ['"hello, world!"']
variable space: ['a']
index ins_num op_num instruction operator
0 1 0 DECL_FAST a
2 17 0 LOAD_STRING "hello, world!"
4 2 0 STORE_FAST a
6 3 0 LOAD_FAST a
8 7 -1 PRINT none
10 13 -1 QUIT none
spd >> next
current instruction:
index ins_num op_num instruction operator
0 1 0 DECL_FAST a
variables:{}
data stack:[]
spd >> break 10
"hello, world!"
current instruction:
index ins_num op_num instruction operator
10 13 -1 QUIT none
variables:{'a': '"hello, world!"'}
data stack:[]
spd >> next
program ended.
spd >> quit
➜ stupyd-lang git:(master) ✗
许可证
致谢
推荐PyPI第三方库