KCLVM binding for Python
Run the cmd for the installation and help:
python3 -m pip install kclvm && python3 -m kclvm --helpWrite the KCL file named hello.k:
name = "kcl"
age = 1
schema Person:
name: str = "kcl"
age: int = 1
x0 = Person {}
x1 = Person {
age = 101
}Run the cmd:
python3 -m kclvm hello.kThe output is:
name: kcl
age: 1
x0:
name: kcl
age: 1
x1:
name: kcl
age: 101Run KCL code with kclvm-py
import kclvm.program.exec as kclvm_exec
import kclvm.vm.planner as planner
print(planner.plan(kclvm_exec.Run(["hello.k"]).filter_by_path_selector()))Output
$ python3 main.py
name: kcl
age: 1
x0:
name: kcl
age: 1
x1:
name: kcl
age: 101