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
  • 现在安装依赖项:
    • 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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java我应该卸载Eclipse,还是只在上面安装一个新版本?   Java For Loop i++在For Loop中做什么?   java防止击键从JTable级联到顶层   java在为GUI和游戏划分类时遇到问题:GUI未连接到游戏   客户端调用时java RMI服务器ClassNotFoundException   java如何在libgdx/box2d中为特定实体强制执行最大速度?   java在Selenium Webdriver中调用href值   java IndexOutOfBounds异常向ArrayList添加项   java修剪JsonNode中的所有字符串值   带填充列表的thymeleaf中的java空索引异常   JPanel中的java插入按钮   java应该在实现中添加Javadoc注释吗?   java JNI不满意的链接错误,尽管一切似乎都很好   java使用Youtube Api V3搜索Youtube视频