parse

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package api defines the parser and code generator public interface.

The parser is a single-pass recursive descent compiler that converts Lua source into Proto (compiled function prototypes). The public API is minimal: Parse() is the sole entry point.

FuncState, ExpDesc, and BlockCnt are compiler-internal types. They are defined here for documentation but will be used only within the parse and codegen implementation.

Reference: .analysis/06-compiler-pipeline.md §3-§4

Code generator for Lua — translates expression descriptors into bytecode.

This is the Go translation of C Lua's lcode.c (1972 lines). It handles instruction emission, constant pool management, register allocation, jump list management, expression discharge, and operator codegen.

Reference: lua-master/lcode.c, .analysis/06-compiler-pipeline.md §4

Parser for Lua — single-pass recursive descent compiler.

This is the Go translation of C Lua's lparser.c (2202 lines). It parses Lua source into bytecode by calling codegen functions.

Reference: lua-master/lparser.c, .analysis/06-compiler-pipeline.md §3

Index

Constants

View Source
const (
	VDKREG     byte = 0 // regular local
	RDKCONST   byte = 1 // local constant
	RDKVAVAR   byte = 2 // vararg parameter (was incorrectly 3)
	RDKTOCLOSE byte = 3 // to-be-closed (was incorrectly 2)
	RDKCTC     byte = 4 // local compile-time constant (was missing)
	GDKREG     byte = 5 // regular global (was incorrectly 4)
	GDKCONST   byte = 6 // global constant (was incorrectly 5)
)

Variable kinds (C6 FIX: matches C lparser.h:102-108 exactly)

Variables

This section is empty.

Functions

func Parse

func Parse(source string, reader lex.LexReader) *object.Proto

Parse compiles Lua source code into a Proto (function prototype). This is the sole public API of the parser.

Mirrors: luaY_parser + mainfunc in lparser.c

Types

This section is empty.

Jump to

Keyboard shortcuts

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