Mulan programming language 0.0.15.0: network-based operating environment; lexical error handling

[Installation: pip install ulangPlease refer to PyPI for usage and routines . The source code is located in Open Source China . Note: Python 3.7 is required, and the source file needs UTF-8 encoding ]

Previously, it was the Mulan source code editor implemented with tkinter, but I always wanted to get rid of the dependency on the Python UI library for the front end ( such as this kind of problem ). Now use a WebSocket client to make a running environment prototype (similar to the previous article, the server is written with Mulan source code). In the development, in order to avoid putting tk applications in other threads to run , switch to HTML-based code editor. The effect is as follows:

The left side is the code editor ( refer to the previous implementation ); the upper right side enters various commands, and the lower side displays the output.

On the server side, the Python code segment for parsing and running the Mulan code was intercepted from the Mulan main program, and rewritten to read the exec output (in order to display the output on the client), and then called on the Mulan server. Since Mulan language does not have built-in compile and exec functions, this Python code has not been rewritten into Mulan code.

Outside of the network-based operating environment, in the original interactive environment, if you encounter a lexical error, it will exit directly , and the experience is not good. It is corrected in this version. At the same time, it was discovered that there was a bug in the rply framework release version 0.7.7 used by Mulan. The row and column number information that caused the lexical error was missing. Fortunately, it was found that this bug has been fixed in rply , but it seems that some cases have not been covered. In.

Since the rply release version has not been updated for a long time, and I don't know when the release version containing the above patches will be updated, I did not think of a good way to bypass the current release version of rply and use the patch. When local development, rply can download the latest source code, python setup.py installinstall the patch available locally. The effect is as follows:

> func a{
>> 1#2
   词法错误:文件 "【标准输入】", 第2行, 第1列, 分词时没认出这个词 "#"
1✋#2
【下面暂时还有 rply 相关层信息,之后将除去】 

Attachment: Code amount statistics

The main part of the code line statistics, the format is: last time -> now.

  • Mulan code size 3114 -> 3204
    • Operating environment, most of the implementation and testing is Mulan code: 431 -> 524 (WebSocket server added)
    • Mulan test cases, including some useful small programs (such as Tic-Tac-Toe): 2683 -> 2680

 

  • Python code volume (Mulan implementation and testing framework): 2612 -> 2675
    • 分析器/语法分析器.py:1019 -> 1013
    • 分析器/词法分析器.py:207
    • 测试/运行所有.py, Check all Mulan test code fragments: 194 -> 195
    • 环境.py, Define the global method: 172
    • 交互.py, Interactive Environment (REPL): 138 -> 148
    • 分析器/语法成分.py, The enumeration constant extracted from the parser: 81 -> 82
    • 功用/反馈信息.py:71
    • 测试/unittest/语法树.pyTo ensure that the generated syntax tree is consistent with the original version: 66
    • 编辑器/运行木兰.py: 45
    • 分析器/错误.py:17 -> 26
    • Unchanged
      • 分析器/语法树.py:202
      • 中.py, The main program: 74
      • 功用/调试辅助.py,:57
      • setup.py, 34
      • 测试/unittest/交互.py, Interactive environment related tests: 28

Guess you like

Origin www.oschina.net/news/121034/mulan-0-0-15-0-released