Log In  

Hi, I just released Depicofier, which converts PICO-8's syntax to regular Lua syntax. I looked at a couple existing solutions but they didn't work for me, so I made this. It's open source under the MIT license on Github.

It should be feature complete, but if I missed anything please let me know.

Depicofier

Converts/translates PICO-8 style Lua syntax to standard clean Lua syntax. Download the latest release here.

This tool uses a publicly available and well-tested Lua language grammar to parse PICO-8 source code, so that any enhanced or special syntax or shorthand will only be converted where it should be.

If you like this tool please consider kicking me a dollar on Patreon.

Usage

Depicofier.exe [inFile] [outFile]
Or to output source to console:
Depicofier.exe [inFile] -print
Switches:
-strict   Print warnings for Lua syntax not found in Pico 8 such as binary
          operators, integer division, and bitwise shifts
P#66019 2019-07-22 03:14

1

Interesting approach. The PICO-8 specializations are all implemented internally as a line-based preprocessing step and have line-based behaviors. Is it possible to implement line endings in these grammars? (I notice it doesn't do short-ifs yet.)

Other implementations, for comparison:

Cool to see an increased interest in using Lua processing tools with PICO-8!

P#66022 2019-07-22 07:08

It does do short-ifs and the print shorthand, but I realized it would be extremely hard to implement in the Lua grammar via ANTLR, because it cares about line endings and Lua's grammar does not. Instead I process those two cases line-by-line. I still use the Lua grammar for them, but I only look at tokens for them.

I had issues with what appeared to be if shorthand edge cases in picotool's --pure-lua flag. I'm sure with time those'll be solved but it was easier for me to create my own than try and figure out where picotool's parser was going wrong for me.

I also looked at pico8-to-lua, but noticed it uses regex so it has no context awareness, which made me incredibly nervous about using it.

P#66023 2019-07-22 08:05

Can I get an explanation on how to use this? I'm very lost

P#131574 2023-07-02 23:07

Looks cool. I wonder if it would be possible the opposite: Lua to P8. I would imagine a lot of cross compilers like moonscript, fennel, teal, etc are targeting canonical lua, but could run on P8 with slight modifications. Also, some libraries take a bit of work to get running on p8. I have written small "compat" files and sed scripts before, but never got beyond a clunky manual process.

P#132139 2023-07-19 18:41 ( Edited 2023-07-22 13:15)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 19:52:13 | 0.006s | Q:16