$ show traefik/yaegi
Yaegi is a Go interpreter written in Go, designed for embedding scripting capabilities into Go applications, running Go scripts, or providing an interactive REPL. The architecture consists of a core interpreter package (`interp`) that parses Go source code into an AST, performs type checking and control flow graph (CFG) generation, and executes the CFG via a runtime engine. Standard library support is provided through auto-generated reflective wrappers (`stdlib/`) that expose Go's standard library symbols to the interpreter. A command-line tool (`cmd/yaegi`) offers subcommands for running scripts, testing, and extracting stdlib wrappers. The project also includes code generators (`internal/cmd/genop`, `extract/extract.go`) that automate the creation of operator implementations and stdlib bindings. External dependencies are limited to the Go standard library; the interpreter itself has no third-party runtime dependencies. Key entry points are `interp.New()`, `interp.Eval()`, and `interp.Use()` for embedding, and the `yaegi` CLI for standalone use.
The LLM identified 2 files worth highlighting for reuse:
Generates Go source code for all arithmetic, bitwise, comparison, and assignment operators used by the Yaegi interpreter. It produces type-specific closures with special handling for constants and interfaces. This pattern can be reused to generate operator implementations for any interpreter or DSL that needs efficient operator dispatch.
Generates Go source code that wraps standard library packages for use in the Yaegi interpreter. It analyzes Go packages using go/types and produces reflective wrappers (constants, functions, types, interfaces). This pattern is reusable for creating interpreter bindings for any Go package, enabling dynamic access to compiled Go code.