codeasm 0.1.0

Generate code form ASTs.
Documentation
  • Coverage
  • 15.38%
    10 out of 65 items documented0 out of 56 items with examples
  • Size
  • Source code size: 15.96 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.93 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • ZJZCORE/codeasm
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ZJZCORE

codeasm

This library can translate AST into source code for multiple programming languages.

Currently, we support the following programming languages:

  • Go

Examples

Go Example

let mut pkg = Package::new("main");
let mut main_body = Block::new();
main_body
    .push(Stmt::raw(Expr::raw("fmt").attr("Println").call(["Hello world!".into()])));
pkg
    .push(Decl::import("fmt"))
    .push(Decl::func("main", Vec::<(String, Type)>::new(), None, main_body));
println!("{pkg}")

Generated golang code:

package main
import "fmt"
func main() {
    fmt.Println("Hello world!")
}