Closed dansanderson closed 7 years ago
This is actually a result of Pico-8's implementation of short-if using a preprocessor pass. if (cond) do\n ... end
becomes if (cond) then do end\n ... end
, which works accidentally. If this is ever important, picotool should probably rewrite its short-if support to match Pico-8's preprocessor. I don't think it's a high priority.
picotool now supports if-do as if it were language syntax. This successfully parses carts that use this accidental syntax, though it does so differently from how Pico-8 does it.
Entirely by accident, Pico-8 supports an illegal variant of
if (cond) then\n ... end
that looks likeif (cond) do\n ... end
. This is a result of Pico-8's "short-if" feature accidentally accepting the multiline do block as if it were on a single line. If it's supported, people will use it (intentionally or otherwise), e.g. 16314, 16350, 16992, 16999, 17135, 17238, 17406, 17550.Pico-8 is unlikely to remove support for this accident, so picotool should support it. Whether it needs to preserve it, I don't know. It's possible authors of old carts used this trick to reduce character count, though hopefully the relatively new emphasis on token count makes this obsolete. To preserve it, we'd need to extend the grammar. It might be easier to convert "do" to "then" and risk pushing carts over the limit, or it might not.