celeref程序设计语言的解释器
celeref-lang的Python项目详细描述
塞莱朗
python中的一个多功能解释器,用于执行用JSON编写的程序。在
安装
首先需要安装python3。现在您可以通过pip安装软件包:
$ python -m pip install --user -U celeref-lang # In linux, you might have to use `python3` instead.# Make sure to check `python --version` first.
测试是否安装成功:
^{pr2}$如果它显示找不到celeref
,请遵循以下帮助:
写你的第一个程序
您需要一个支持intellisense for JSON模式的代码编辑器。我的首选是visualstudio代码。在
- 在visualstudio代码中创建JSON文件
- 添加位于
src/schema
文件夹中的架构路径。 请参阅examples
文件夹中的示例以获取帮助。在
定义模式后,编辑器将捕捉模式错误并自动建议可用的表达式。在
以下是用celeref lang编写的示例程序:
{"$schema":"https://raw.githubusercontent.com/dipu-bd/celeref-lang/master/src/schema/schema.json","name":"Hello World","program":[{"state":"Hello World"},{"print":"state"}]}
将程序保存到hello-world.json
文件,并使用以下命令运行它:
$ celeref hello-world.json
----------
Hello World
------ 0.000 seconds ------
源代码构建
您需要Python3来执行这个脚本。在
- 首先克隆存储库
- 创建新的虚拟环境
python -m venv venv
- 激活它;
- 在Windows中:
venv\Scripts\activate
- 在Linux中:
venv/bin/activate
- 在MacOS中:
venv/bin/activate
- 在Windows中:
- 现在安装依赖项:
pip install -U wheel pip
pip install -r requirements.txt
- 现在要运行脚本:
python src <path/to/your-source.json>
例如,要运行hello-world.json
示例:
$ python src examples/hello-world.json Hello World
文件
这个项目正在开发中。API将来可能会发生变化。 文档还远着呢。现在请遵循基本文档的模式描述。在
注意一些基本事项:
- 在
在state
是这个程序中一个非常重要的变量。执行语句后, 结果总是以状态优先存储。在 - 在
程序运行完毕后,将得到
在state
的最终值。在 - 在
要将and数组或对象作为参数传递给
在call
方法, 您可以使用{ "state": <your array or object> }
。在 - 在
要显示所有可用函数的列表:
在
$ celeref -s
- 要搜索特定函数,请在
-s
后传递查询:
$ celeref -s mod ----- [divmod] ----- Return the tuple (x//y, x%y). Invariant: div*y + mod== x. ----- [math.fmod] ----- Return fmod(x, y), according to platform C. x % y may differ. ----- [math.modf] ----- Return the fractional and integer parts of x. Both results carry the sign of x and are floats. ----- [op.mod] ----- mod(a, b) -> number Same as `a % b` Find the modulus of two numbers
- 项目
标签: