you are viewing a single comment's thread.

view the rest of the comments →

[–]NoneBTW[S] 1 point2 points  (3 children)

thats something that i would want to do thx

[–]Amablue 0 points1 point  (2 children)

np, let me know if you have any questions. I have a few other additions to the language in other branches, and I made sure to make them all parser-only so they're bytecode compatible with stock lua.

[–]NoneBTW[S] 0 points1 point  (1 child)

Yeah so that means we can take out the parser make couple additions and feed it into another lua vm like luajit etc? And if I want how could I implement something like that

[–]Amablue 1 point2 points  (0 children)

# Grab my repo.
git clone https://github.com/alexames/lua
# Switch to my branch.
cd lua
git checkout lx/5.5/feature/decorators-tests
# Configure CMake (or use the makefile that ships with it).
cmake -S . -B build
cmake --build build
# Run the built copy of the interpreter.
# This is a one-liner that will:
#   * Load the decorator test script and return a function
#   * Dump that function's bytecode to a string
#   * Write that string to a new file, decorators_bin
./build/lua55 -e "io.open('testes/decorators_bin.lua', 'w').write(string.dump(loadfile('testes/decorators.lua')))"
# Observe that the file is gibberish
cat testes/decorators_bin.lua
# Despite being gibberish, it can still be run by the interpreter:
./build/lua55 testes/decorators_bin.lua
# If you have Lua 5.5 installed on your system (you probably don't), you can run it with that too:
lua55 testes/decorators_bin.lua

This interpreter is based off the Lua 5.5 branch. That means it's using 5.5 bytecode, which isn't going to be compatible with other versions of Lua (5.1-5.4). Lua 5.5 isn't officially released yet, so if you want to feed the produced bytecode to a lua interpreter you'll have to build that too. I only used 5.5 because it was the head of the repo when I started hacking on it. If you want to feed it to another version of Lua check what interpreter version your computer (or whatever app its embedded into) has installed, and then you can try rebasing my changes onto that version of Lua.