Open japhib opened 2 years ago
I run across the same issue. PICO-8 extends standard Lua syntax with a few shorthands, including for single-line while
and if
statements: https://www.lexaloffle.com/dl/docs/pico-8_manual.html#PICO_8_Shorthand
Additional shorthands are operators like +=
and -=
.
Everything else you mentioned is already supported, just the one line while loop is not yet
Yep, exactly.
Any chance this could be prioritized? The "'do' expected" warnings are making me sad. (And yes, I'm working around it by adding do
and end
to my one-liners.)
I'd take a crack at a PR myself. I know Parser.parseWhileStatement
needs some special-case logic like this, but all the special edge cases and one-off manual finagling in there scares me a bit. A lot of that mess is dealing with the possible else
block, though, so I'm guessing the logic for Parser.parseWhileStatement
would be simpler.
Go for it! I haven't had much time to work on this myself but I'm happy to review PRs, and provide any pointers if you get stuck.
This is used in the
jelpi.p8
demo cart. The line looks like this:I think it's very similar to the single-line
if
statement.