nandi/code-transpiler-rust-frontend-findingspublic⑂ Fork 0Commits
5375d17f26e5be6bd30310edeabaaa1211437b03
⬇ Clone ▾
| Reproducible bug report for the Rust frontend in Code-Transpiler | 1 | package main |
| 2 | ||
| 3 | import ( | |
| 4 | "encoding/json" | |
| 5 | "fmt" | |
| 6 | "os" | |
| 7 | "regexp" | |
| 8 | ||
| 9 | "github.com/tarekwasfy01/Code-Transpiler/v2/internal/backend" | |
| 10 | ) | |
| 11 | ||
| 12 | func main() { | |
| 13 | code, _ := os.ReadFile(os.Args[2]) | |
| 14 | p, err := backend.ParseSemantic(os.Args[1], string(code)) | |
| 15 | fmt.Println("err:", err) | |
| 16 | if p == nil || p.UniversalAST == nil { | |
| 17 | return | |
| 18 | } | |
| 19 | b, _ := json.Marshal(p.UniversalAST) | |
| 20 | re := regexp.MustCompile(`"kind":"([A-Za-z]+)"`) | |
| 21 | counts := map[string]int{} | |
| 22 | for _, m := range re.FindAllStringSubmatch(string(b), -1) { | |
| 23 | counts[m[1]]++ | |
| 24 | } | |
| 25 | fmt.Println("node kinds:", counts) | |
| 26 | } |