# codeasm
This library can translate AST into source code for multiple programming languages.
Currently, we support the following programming languages:
- Go
- Python
## Examples
### Go Example
```rust
use codeasm::go_asm::*;
let pkg = Pkg(vec![
"package main".into(),
"import \"fmt\"".into(),
FuncDecl {
name: "main".into(),
body: vec![
Call { f: "fmt.Println".into(), args: vec!["\"Hello World\"".into()] }.into(),
],
..Default::default()
}.into(),
]);
print!("{pkg}")
```
Generated code:
```go
package main
import "fmt"
func main(){
fmt.Println("Hello World")
}
```
### Python Example
```rust
use codeasm::py_asm::*;
let file = File(vec![
FuncDef {
name: "main".into(),
body: vec![
Call {
f: "print".into(),
args: vec!["\"Hello World\"".into()],
kwargs: vec![],
}.into(),
],
..Default::default()
}.into(),
If {
main: (
"__name__==\"__main__\"".into(),
vec![Call { f: "main".into(), ..Default::default() }.into()],
),
..Default::default()
}.into(),
]);
print!("{file}")
```
Generated code:
```py
def main():
print("Hello World")
if __name__=="__main__":
main()
```