Skip to content

Peefy/kclvm-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KCLVM-Py

KCLVM binding for Python

How to use

Installation

Run the cmd for the installation and help:

python3 -m pip install kclvm && python3 -m kclvm --help

Command Line Tools

Write 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.k

The output is:

name: kcl
age: 1
x0:
  name: kcl
  age: 1
x1:
  name: kcl
  age: 101

API

Run 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

About

kclvm-py: KCLVM binding for Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages