Mulan programming language 0.0.14.7: function coverage of the first version of the user manual; early adopters of the Gitee Go pipeline

The Mulan programming language has won 26 votes in the 2020 OSC China Open Source Project Selection, please vote for it!

At the beginning of the year , some functional explorations were made on the original Mulan executable file ulang-0.2.2.exe, and the basic functions were written in the first version of the user manual . After launching the reproduction project, I haven't repeated the routines in the manual. Last week I finally completed this "quiz" that integrates the functions of all parts. Most of the routines can run correctly in the previous version, and the remaining small parts are also passed in this version.

[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 ]

This version reproduces the function

String escaping

The more special one is the backslash (effect in Mulan interactive environment):

> 'c\\\'+'name'
c\name 

In Python, if the backslash is not matched, a syntax error will be reported:

>>> print('\')
  File "<stdin>", line 1
    print('\')
             ^
SyntaxError: EOL while scanning string literal
>>> print('\\\')
  File "<stdin>", line 1
    print('\\\')
               ^
SyntaxError: EOL while scanning string literal

The effect of Python after pairing:

>>> print('\\')
\
>>> print('\\\\')
\\ 

Compare the effect of backslash escape in Mulan:

> println('\')

> println('\\')

> println('\\\')
\
> println('\\\\')
\
> println('\\\\\')
\\
> println('\\\\\\')
\\

The implementation details can be seen in the source code. Personally, I feel a bit awkward to use it at first. There should not be many scenarios for this use.

In addition, there is no need to say more about quotation marks and newline escape:

> 'doesn\'t'
doesn't
> "\"吃了么?\""
"吃了么?"
> '第一行\n第二行'
第一行
第二行 

Function parameter specified type

> type Person {
>>   func $Person(name) {
>>     $name = name
>>   }
>> }
> func hello(p : Person) {
>> println("hi " + p.name)
>> }
> hello(Person("木兰"))
hi 木兰 

Python module import under current path

For example, under the current path larger.py:

def larger(a, b):
    if a > b:
        print(a)
    else:
        print(b)

Under Mulan interactive environment:

> using larger
> larger.larger(5,6)
6 

Built-in enumerate function

It is easier to define enumerations:

> for i, v in enumerate(['小', '中', '大']) { println(i, v) }
0 小
1 中
2 大

Remainder operation

> 11%3
2 

other

Gitee Go pipeline

I was pleasantly surprised to find that Gitee Go received 1,000 minutes of build time after opening, and I was very lucky that the Python version of the build environment just supports the 3.7 required by this project. Made a little modification on the basis of the novice template, and smoothly added a less time-consuming and more critical unittest test set (confirmed that the syntax tree was generated correctly), the widget looks good:

After the trigger, it seems that it takes a while to wait for the allocation of construction resources. I feel that the wait is quite short. Maybe there are not many users who have set up the pipeline? During the period, only one Chinese display problem was found in the log, and a report has been submitted to the official , looking forward to an early solution~

webpy is not yet available

Because the web.py routine needs to call globals():

web.application(urls, globals())

And the corresponding method of globals() in Mulan has not been found, so it is temporarily unavailable. I hope to find a useful and lightweight web service framework, and suggestions are welcome.

More error information

> using  不存在
   没找到模块:‘不存在’,见第1行<br/>

Attachment: Code amount statistics

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

  • Mulan code amount 2920 -> 2965
    • Editor, implementation and testing are all Mulan code: 432 (in the front and back ends to achieve the research network service framework)
    • Mulan test cases, including some useful small programs (such as Tic-Tac-Toe): 2488 -> 2533

 

  • Python code volume (Mulan implementation and testing framework): 2574 -> 2594
    • 分析器/语法分析器.py:1002 -> 1008
    • 分析器/词法分析器.py:201 -> 204
    • 测试/运行所有.py, Check all Mulan test code fragments: 191 -> 192
    • 环境.py, Define the global method: 162 -> 171
    • Unchanged
      • 分析器/语法树.py:202
      • 交互.py, Interactive Environment (REPL): 138
      • 分析器/语法成分.py, The enumeration constant extracted from the parser: 81
      • 中.py, The main program: 74
      • 功用/反馈信息.py:65
      • 功用/调试辅助.py,:57
      • setup.py, 34
      • 分析器/错误.py:17
      • 测试/unittest/语法树.pyTo ensure that the generated syntax tree is consistent with the original version: 67
      • 测试/unittest/交互.py, Interactive environment related tests: 28

Guess you like

Origin www.oschina.net/news/119605/mulan-0-0-14-7-released