luaf

package module
v0.0.0-...-ca3e0e0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2025 License: MIT Imports: 4 Imported by: 0

README ¶

Luaf

Lua for learning and laufs

build status MIT License Go Reference

luaf is an experimental implementation of lua 5.4 for learning purposes and luafs 🤠. It aims to be fully feature compatible with lua 5.4 as well as additions that also aims to make lua a more feature complete language.

See luaf.dev for more information and documentation.

Getting Started

Prerequisites

  • Go version 1.23 or greater required.
  • golangci-lint: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
  • stylua: cargo install stylua --features lua54

Run

  • make install install luaf.
  • make repl run luaf repl from source.
  • make test run tests.
  • make help for more commands to develop with.

Documentation ¶

Overview ¶

Package luaf is an implementation of lua 5.4 for learning purposes and luafs 🤠. It aims to be fully feature compatible with lua 5.4 as well as additions to the standard library to make it more of an everyday use language instead of just as an embedded language.

`luaf` is still very WIP and really shouldn't be used by anyone except me and
maybe people who are interested in lua implementations.

`luaf` should be fully compatible with the lua APIs that are default in lua,
however it will not provide the same API as the C API. It will also be able to
precompile and run precompiled code however that precompiled code is not compatible
with `lua`. `luac` will not be able to run code from `luaf` and vise versa.
Since the point of this implementation is more for using lua than it's use in Go
there is less of an emphasis on a go API though a simple API exists.

Index ¶

Constants ¶

This section is empty.

Variables ¶

This section is empty.

Functions ¶

func File ¶

func File(filepath string, env Env, args ...string) ([]any, error)

File will parse and eval a lua source file.

func String ¶

func String(label, src string, env Env, args ...string) ([]any, error)

String will simply parse and run lua source code. Label is a replacement for a filename so that it will be easier to debug.

Types ¶

type Env ¶

type Env map[any]any

Env is a simple mapping for what will be exposed as a global in the lua source. This can be used to expose functions values as apis. The values in keys and values should only be - int64 - float64 - string - *runtime.GoFunc (use runtime.Fn() to create them easily) So this means that to add your own api, you can just create an env

env := map[any]any{
		"render": runtime.Fn("render", func(vm *runtime.VM, args []any) ([]any, error) {
			return nil, errors.New("not implemented")
		},
}

Directories ¶

Path Synopsis
cmd
luaf command
Package main is the main entrypoint to the luaf application
Package main is the main entrypoint to the luaf application
src
bytecode
Package bytecode handles formatting uint32 values which have meaning for the vm.
Package bytecode handles formatting uint32 values which have meaning for the vm.
conf
Package conf contains the constants that are used across packages for configuring versions and stack sizes.
Package conf contains the constants that are used across packages for configuring versions and stack sizes.
lerrors
Package lerrors are a unified errors package for lua parsing and runtime so that they can be formatted in a unified way and handled in a unified way.
Package lerrors are a unified errors package for lua parsing and runtime so that they can be formatted in a unified way and handled in a unified way.
lfile
Package lfile is a wrapper around os files to make them easier to use in lua.
Package lfile is a wrapper around os files to make them easier to use in lua.
lstring
Package lstring is a small collection of string utilities.
Package lstring is a small collection of string utilities.
lstring/pack
Package pack allows for serialization and deserialization of data into a string.
Package pack allows for serialization and deserialization of data into a string.
lstring/pattern
Package pattern is the package that implements lua patterns.
Package pattern is the package that implements lua patterns.
parse
Package parse contains the code that parses code text and transforms it into bytecode and constants that are able to be run in a virtual machine or translated into another format.
Package parse contains the code that parses code text and transforms it into bytecode and constants that are able to be run in a virtual machine or translated into another format.
runtime
Package runtime is a stack-based register VM to run the bytecode for the parsed lua
Package runtime is a stack-based register VM to run the bytecode for the parsed lua
types
Package types contains all the structures used to define types, and check them against each other.
Package types contains all the structures used to define types, and check them against each other.

Jump to

Keyboard shortcuts

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