compiler

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: 10 Imported by: 0

Documentation

Overview

Package compiler orchestrates the Meow compilation pipeline: lexing, parsing, code generation, and invoking go build to produce a binary.

Pipeline

The compilation process follows these stages:

  1. Lex — source text is tokenized by github.com/135yshr/meow/pkg/lexer
  2. Parse — tokens are parsed into an AST by github.com/135yshr/meow/pkg/parser
  3. Codegen — the AST is translated to Go source by github.com/135yshr/meow/pkg/codegen
  4. Format — the generated Go code is formatted with go/format
  5. Build — go build compiles the Go source into an executable (optional)

Usage

// Transpile only
c := compiler.New(logger)
goCode, err := c.CompileToGo(source, "hello.nyan")
_ = goCode

// Build a binary
c := compiler.New(logger)
err := c.Build("hello.nyan", "hello")

// Compile and run
c := compiler.New(logger)
err := c.Run("hello.nyan")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Compiler

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

Compiler orchestrates the compilation pipeline.

func New

func New(logger *slog.Logger) *Compiler

New creates a new Compiler.

func (*Compiler) Build

func (c *Compiler) Build(nyanPath, outputPath string) error

Build compiles a .nyan file to an executable binary.

func (*Compiler) CompileToGo

func (c *Compiler) CompileToGo(source, filename string) (string, error)

CompileToGo compiles a .nyan file to Go source code.

func (*Compiler) Run

func (c *Compiler) Run(nyanPath string) error

Run compiles and runs a .nyan file.

Jump to

Keyboard shortcuts

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