Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

1 Commit

Repository files navigation

lua5.js 🌙

A complete, single-file architectural port of the Lua 5.5 source tree implemented directly in pure JavaScript.

Unlike simple regex translators, lua5.js replicates the underlying design patterns of the official Lua engine, featuring a dedicated virtual stack, mixed array/hash tables, a lexical analyzer (llex), a syntactic parser (lparser), and an instruction-driven Virtual Machine (lvm).


🚀 Key Features

  • Zero Dependencies: Pure vanilla JavaScript. Runs anywhere without Webpack, Vite, or Node.js.
  • Double-Click Ready: Just link it inside your index.html and open it directly from your file manager (file:// protocol).
  • True C-to-JS Architecture: Every single core component and library file from the official lua.org source tree is represented as a structured layout module.
  • Isolate Engine State: Built around a custom lua_State tracking an isolated calculation registers stack.

📂 Lua 5.5 Source Tree Mapping

The monolithic engine fully maps out the internal layout of the original C files:

LayerMapped C/H FilesDescription
Includeslua.h, luaconf.h, lualib.h, lauxlib.hHolds type constants, numeric limits, and library definitions.
Core Enginelstate.c, lapi.c, llex.c, lparser.c, ltable.c, lvm.cCore pipeline handles tokenization, stack management, and instruction cycles.
Librarieslbaselib.c, lmathlib.c, ltablib.c, linit.cNative execution packages exposed directly inside the global environment maps.
Runtimelua.c, luac.cStandalone operational entry layers managing execution pipelines.

📦 Installation & Usage

1. Create lua5.js

Save the monolithic framework code into a file named lua5.js.

2. Setup your index.html

Create an HTML file in the exact same directory:

<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><title>Lua 5.5 Virtual Machine</title><scriptsrc="lua5.js"></script></head><body><divid="terminal"><h2>Lua 5.5 VM Status: Active</h2><divid="lua-output"></div></div><scripttype="text/lua5.5">--Scopedlocaldefinitionscompiledintovirtualstackinstructionslocalalpha=150localbeta=250localresult=alpha+beta--Executionroutesthroughlbaselibprinthooksprint("Hello from the architectural Lua VM!")print("Calculated stack balance: "..result)</script></body></html>

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages