【Install:pip install ulangsee the usage and routine PyPI. The source code is located in Kaiyuan China. Note: Python 3.7 is required, and the source code file needs to be encoded in UTF-8

Summary for 2022

Last year, the project went silent for a while after the release of version 0.0.22 in July.Beginning at the end of January this year The bounty mission began to advance in strides again. Reproducibility is heavy, so a large version is released.

Thanks to all involved for their cooperation, patience and inquiry!

This version reproduces the functionality

Each reward task will be introduced one by one in the order of completion.

More incremental operations

+= -= was done earlier, now the rest *= ^= |= &= /= %= etc.:

Mulan source code converted to Python

Now the –dump-python command line option can convert Mulan source code to Python source code:


> 木兰 --dump-python 测试\算法\排序\冒泡.ul
import sys
from math import *
ARGV = sys.argv[1:]
def 冒泡(数列):
  换过 = True
  while 换过:
    换过 = False
    for i in range(0, len(数列) - 2 + 1):
      前项 = 数列[i]
      后项 = 数列[i + 1]
      if (前项 > 后项):
        (数列[i], 数列[i + 1]) = (后项, 前项)
        换过 = True
打乱数列 = [5, 2, 1, 8, 4]
冒泡(打乱数列)
print(打乱数列)

Anonymous functions support multiple parameters and no parameters

and annotation parameter types


> 体积 = (长:int, 宽:int, 高:int) -> 长*宽*高
print(体积(2, 3, 4))
24
> a = () -> 3
print(a())
3

The first parameter was found during The default value is not supported, and I don’t understand why.

The function supports several formal parameters (dots dots)

Include ordinary functions


>func 哈(...) {{
    __varargs__ = tuple('ha', 'ha')
    print(...)
}
哈(2, 3, 3, 3)
hah

and an anonymous function


>b = (...) -> max(...))
print(b(3, 1, 2))
3

The following is completed after the end of October.

.. as a module path

See this pr for details


using * in ..

func talk() {
    module_py.talk('..')
}

More super class syntax, but running error, unknown purpose

See last two lines for example. There is an error when running, the same behavior as the original Mulan, so only the syntax tree test is added.See details This pr.


type Person : list {
  func $Person {
    super.__init__()
  }
}
p = Person()
v = p.super
Person.super(None)

define a type within a type


type Animal {
    type Child {
        func $Child(name) {
            $name = name
        }
    }
    func getChildName() {
        c = Animal.Child('Animal.Child').name
        return c
    }
}

p = Animal()
print(p.getChildName())

hexadecimal number


> n = 12 + 0x1F + 0X1a + 0xab + 0XCD
print(n)
445

However, the format is wrong and the error is more puzzling:


> print(0xg)
   请先定义‘xg’再使用,见第1行<br/>

Mulan should support Multiplication omits the multiplication sign side effects.

(semantics to be determined) complex type annotation

See details This pr supports nested type annotations syntactically, but I don’t know the purpose and suggested usage.


func hello(a : tuple [ int ]) : int [ float, list [ str ], dict ] {
  print(a)
}
a : list [ int ] = 2

Complement try … catch … finally


try f=open('__init__.py', 'r') {
  print(len(f.read()))
  print([][int('0')])
} catch e : ValueError {
  print('v')
} catch e : IndexError {
  print('i')
} finally {
  print('f')
}

Overload all remaining operators, including binary, unary, etc.

Including the 26 operators in the following example, see this document.


type P : str {
    operator + (a) {
        return str(self) + str(a) + '啊'
    }
    
    {}
}
a = P("你")
b = P("好")
print(a+b)  // 输出“你好啊”

other maintenance

#Mulan #language #shows #results #years #reward #task #News Fast Delivery

Leave a Comment

Your email address will not be published. Required fields are marked *