codegen

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package codegen translates the Meow AST into Go source code. The generated code depends on the meowrt runtime package for dynamic typing.

Generated Code Structure

The output is a self-contained Go main package with the following layout:

package main
import meow "github.com/135yshr/meow/runtime/meowrt"
// user-defined functions
func main() { /* top-level statements */ }

All Meow values are represented as meow.Value at runtime.

Runtime Dependency

Generated code calls functions from the meowrt package for arithmetic, comparisons, built-in operations (nya, lick, picky, curl), and pattern matching.

Supported Constructs

  • Variable declarations and assignments
  • Function definitions and calls (including lambdas)
  • Arithmetic, comparison, and logical operators
  • If/else, while loops
  • List literals and index access
  • Pipe expressions (|=|)
  • Error recovery expressions (~>)
  • Pattern matching (peek)
  • Error raising (hiss) and recovery (gag/isFurball)

Usage

gen := codegen.New()
goSource, err := gen.Generate(prog)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

Generator produces Go source code from a Meow AST.

func New

func New() *Generator

New creates a new code generator.

func (*Generator) Generate

func (g *Generator) Generate(prog *ast.Program) (string, error)

Generate produces Go source code from a Program AST.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL