1.3. 语法支持
支持 python3 标准语法的子集。
1.3.1. 对象支持
语法 | 编译时 | 运行时 | Shell |
---|---|---|---|
模块定义 | √ | - | - |
模块导入 | √ | √ | √ |
类定义 | √ | √ | √ |
类继承 | √ | √ | √ |
方法定义 | √ | √ | √ |
方法重载 | √ | √ | √ |
方法调用 | √ | √ | √ |
参数定义 | √ | √ | √ |
参数赋值 | √ | √ | √ |
对象新建 | √ | √ | √ |
对象销毁 | √ | √ | √ |
对象嵌套 | √ | √ | √ |
控制流 | √ | √ | √ |
1.3.2. Operator
+ | - | * | / | == | > | < | >= | <= | % | ** | // | != | & | >> | << | and | or | not | in | += | -= | *= | /= |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
√ | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ |
1.3.3. Control flow
Syntax | State |
---|---|
if | √ |
while | √ |
for in [list] | √ |
for in range(a, b) | √ |
for in [dict] | √ |
if elif else | √ |
for break/continue | √ |
while break/continue | √ |
1.3.4. Module
Syntax | Python Module | C Module |
---|---|---|
import [module] | √ | √ |
import [module] as | √ | - |
from [module] import [class/function>] | √ | - |
from [module] import [class/function>] as | √ | - |
from [module] import * | - | PikaObj Module Only |
1.3.5. List/Dict
Syntax | State |
---|---|
l = list() | √ |
l = [a, b, c] | √ |
d = dict() | √ |
d = {'a':x, 'b':y, 'c':z} | √ |
1.3.6. Slice
Syntax | str | bytes | list |
---|---|---|---|
test[i] | √ | √ | √ |
test[a : b] | √ | √ | √ |
test[a :] | √ | √ | √ |
1.3.7. Function Arguments
Syntax | State |
---|---|
Default Arguments | √ |
Keyword Arguments | √ |
Variable Positional Arguments (*args) | √ |
Variable Keyword Arguments (**kwargs) | √ |
1.3.8. String Formatting
Syntax | State |
---|---|
%-formatting | √ |
str.format() | - |
f-strings (formatted string literals) | - |
1.3.9. Comparison Operations
Syntax | Number | List | Dictionary |
---|---|---|---|
Equal (==) | √ | - | - |
Greater Than (>) | √ | - | - |
Less Than (<) | √ | - | - |
Greater Than or Equal To (>=) | √ | - | - |
Less Than or Equal To (<=) | √ | - | - |
Membership (in) | - | √ | √ (keys) |
Non-membership (not in) | - | √ | √ (keys) |
Identity (is) | √ | √ | √ |
Non-identity (is not) | √ | √ | √ |
1.3.10. Exception
Syntax | State |
---|---|
try: | √ |
except: | √ |
except [Exception]: | - |
except [Exception] as [err]: | - |
except: ... else: | - |
raise: | √ |
raise [Exception]: | - |
finally: | - |
1.3.11. Context Managers
Syntax | State |
---|---|
with statement | - |
custom context managers (using enter and exit methods) | - |
1.3.12. Generators
Syntax | State |
---|---|
generator functions (using 'yield') | - |
generator expressions | - |