中文原生脚本 · 数学公式 · notion 数据库 · 一体化运行示例
覆盖:变量、运算符、if/elif/else、for/while、列表推导式、with、json、math、random、lambda、match/case、位运算、try/except/finally。
演示 cnsh 运行时直接调用 longhun-math-formula-core 函数,并查询 notion db3367、同步种子模块。
覆盖:class 定义、继承与 super、@property / @classmethod / @staticmethod / @abstractmethod、生成器 yield / yield from / 生成器表达式、异常类。
覆盖:async/await、async for/async with、@contextlib.contextmanager、enum.enum + @enum.unique、@dataclasses.dataclass、dataclasses.field。
覆盖:函数签名类型注解、typing 泛型 / typevar / generic、自定义参数化装饰器、@functools.lru_cache、全中文异常类名(valueerror/keyerror/typeerror/...)、自定义异常继承。
覆盖:人格基态声明、系统构建、任务测量、酉演化、协作概率读取、三色审计。cnsh v2.1 原生支持,编译后调用 longhun_braket 引擎。
计数 = 10
计数 加等于 5
如果 计数 大于 10:
打印("大于10")
否则:
打印("小于等于10")
平方 = [x * x 对于 x 在 范围(10) 如果 x > 1]
使用 打开("test.txt", "w") 作为 f:
f.写入("hello")
匹配 值:
分支 1:
打印("一")
分支 _:
打印("其他")
数据 = 查询数据库("3367125a9c9f808a9692f0c6752e92fa", 最大条数=5)
cd ~/longhun-system/cnsh-core/cnsh-v2.1 python3 run.py examples/braket_persona.cnsh --compile --target python --run-compiled cd ~/longhun-system/cnsh-core/cnsh-runtime python3 cnsh_runner.py examples/cnsh_syntax_v1.1.cnsh python3 cnsh_runner.py examples/cnsh_class_decorator_generator.cnsh python3 cnsh_runner.py examples/cnsh_async_enum_dataclass.cnsh python3 cnsh_runner.py examples/cnsh_advanced_syntax.cnsh python3 cnsh_runner.py examples/notion_math_bridge.cnsh