dansanderson / picotool

Tools and Python libraries for manipulating Pico-8 game files. http://www.lexaloffle.com/pico-8.php
MIT License
367 stars 46 forks source link

Proper support for the ?-print shortcut #84

Open Liquidream opened 2 years ago

Liquidream commented 2 years ago

Hey Dan, Just wanted to let you know that I'm receiving the following errors, while running latest luamin against the following lines of code:

fillp(▒) .\pico-dune.p8: Syntax error (remaining:b'\xe2\x96\x92)\n') at line 1601 char 9

?"mission "..(endstate<3 and "complete" or "failed"),36,60,p_col1 .\pico-dune.p8: Expected b'end' at line 327 char 15

?sub("000000", #strnum+1)..strnum, 103,2, p_col2 .\pico-dune.p8: Expected b'end' at line 1493 char 32

?selected_subobj.name,30,26,7 .\pico-dune.p8: Expected b'end' at line 1633 char 14

?selected_subobj.description,30,34,6 .\pico-dune.p8: Expected b'end' at line 1635 char 16

?self.text,self.x+2,85,(#text>1) and 0 or (self.hover and p_col1 or 6) .\pico-dune.p8: Expected b'end' at line 1668 char 79

Once these particular lines are commented out - it completes and the output seems to work well (I'm also using the new "keep" list too!)

If you need any further info, please let me know. Thx

dansanderson commented 2 years ago

High char support is still missing, and explains the first error. https://github.com/dansanderson/picotool/issues/36

I'll rename this issue to track proper ?-print support, which I know for sure isn't fully implemented. I added ? to the token list but that's not a complete solve: ? is a line macro and either needs explicit grammatical support (like short-if) or needs to be translated to print(...) during a build. Adding it to the grammar is probably the best solution for picotool's use cases.

(This is a general issue with what picotool is trying to do vs. how PICO-8 is designed. PICO-8 can get away with all of these preprocessor macros because it never has to reverse the process and regenerate the code. Unfortunately this means PICO-8 can make all kinds of grammatical choices for those macros that complicate picotool's task.)

dansanderson commented 2 years ago

Also a note to future self: 0.2.2d will make this more complex by supporting short-if-with-?-print. 🤪

Liquidream commented 2 years ago

Good point (high char), forgot about that.

Also, I must confess that I suggested the "short-if-with?-print" feature to Zep (selfishly for Tweetcarts/Pico1k) - sorry! 😬😇