3 Star 36 Fork 4

Laomo. / AIL

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
2_2.md 2.93 KB
一键复制 编辑 原始数据 按行查看 历史
Laomo. 提交于 2022-03-20 00:12 . new: yield, yield from 表达式

AIL 2.2 Klee 版本更新

2022-3-12

AIL 2.2 带来了更为详细的语法错误信息,并提高了整体的稳定性。

== 更新内容 ==

一、适配 Python 3.10

AIL 2.2 版本将开始适配 Python 3.10 的部分功能,源码上会在尽可能兼容 Python 3.7 的基础上进行针对 Python 3.10 的特性的优化。

Python 3.10 版本更新说明: py3.10

二、更清晰的语法错误提示

新的 AIL 2.2 带来了更为清晰详细的语法错误提示信息。新增加的语法提示包括但不仅限于下面的内容:

错误位置指示

新的 AIL 版本中,当出现语法错误时,AIL 将会给出错误的大致位置:

>> a = match x {};
  File "<shell>", line 1
    a = match x {};
                 ^
SyntaxError: match body cannot be empty

括号配对错误提示

新的 AIL 版本中,将对配对错误的括号给出提示:

>> a = (1, 2];
  File "<shell>", line 1
    a = (1, 2];
             ^
SyntaxError: closing parenthesis ']' does not match opening parenthesis '(' (at line 1, col 6)

字符串未结束提示

新的 AIL 版本中,未结束的字符串将会给出更详细的提示详细:

>> name = 'klee
  File "<shell>", line 1
    name = 'klee
               ^
SyntaxError: unterminated string literal (detected at line 1)

三、标准库更新

maptools 模块新增 xmapwith, traverse 函数。

四、其他更新内容:

1. AIL shell 中增加 commit id 和 branch 的显示

AIL 2.2 Klee alpha 2 [727] (2.2/d24235a) (Python 3.8.0 (default, Dec  5 2019, 10:53:43)
[Clang 8.0.7 (https://android.googlesource.com/toolchain/clang b55f2d4ebfd35bf6)
Type 'help(...)', '$help', 'copyright()', 'python_copyright()' to get more information, 'exit()' to exit.

>> 

2. 增加 not in 运算符

not in 运算符可以用于快速判断某元素是否存在于一个可迭代对象中:

>> knights_of_favonius = ['Jean', 'Kaeya', 'Eula', 'Amber', 'Rosaria', 'Klee'];
>> 'Klee' not in knights_of_favonius;
False
>> 'Diona' not in knights_of_favonius;
True
>>
>> 1 not in [1, 2, 4, 8, 16];
False
>> 'a' not in 'Jean';
False
>>

注意: 相比于 not ... in ... 表达式,not in 作为一个运算符存在,相比前者,使用 not in 运算符可以提高程序的执行效率。

增加 if-else 三元运算符

使用 if-else 三元运算符可以在一个表达式中对值进行选择:

>> passed = true
>> result = 'OK' if passed else 'FAILED'
>> result
OK

五、重大 BUG 修复与优化

  1. 修复 |= 运算符解析异常问题
  2. 修复 not 表达式引导的表达式解析问题
  3. 修复 复合下标运算表达式(如 x[1][2]) 的解析问题
  4. 优化 下标、成员访问、调用三个表达式的解析,提高稳定性
  5. 修复非当前目录下 import 出现异常的问题
1
https://gitee.com/LaomoBK/ail.git
git@gitee.com:LaomoBK/ail.git
LaomoBK
ail
AIL
3.0

搜索帮助