Kampfkarren / full-moon

A lossless Lua 5.1 parser
Mozilla Public License 2.0
394 stars 52 forks source link

Playdate runtime support #282

Open Ruin0x11 opened 1 year ago

Ruin0x11 commented 1 year ago

Hello. For the Playdate console, a Lua 5.4 runtime is provided with some minor syntax changes:

https://sdk.play.date/inside-playdate/#playdate-sdk-lua-enhancements

I think most or all of these are already in the code but feature gated behind roblox. It would be nice to have a playdate configuration.

DataM0del commented 1 month ago

Ok, so base it off of Lua 5.4. This is all the non-standard syntax I've found in the docs, if you see more and it isn't listed, please tell me about it, and I can update this message: You can steal the compound assignment operator parsing (e.g. +=) from Luau. https://sdk.play.date/2.5.0/Inside%20Playdate.html#_assign_frequently_used_objects_to_local_variables It seems like they have a declaration, steal the Luau type handling and modify it a bit to remove the required colon + require brackets around "const" (if that's the only < bracket declaration)? https://sdk.play.date/2.5.0/Inside%20Playdate.html#_assign_frequently_used_objects_to_local_variables, https://sdk.play.date/2.5.0/Inside%20Playdate.html#_structuring_your_project Oh, imports too... Check for import statement, then parse the string.

DataM0del commented 1 month ago

Support seems simple on the surface, although I don't have a playdate, but it shouldn't matter (if the compiler is OSS, can we see the modifications and deviations from Lua 5.4?). I think I'll be able to do it.