autc04 / Retro68

a gcc-based cross-compiler for classic 68K and PPC Macintoshes
GNU General Public License v3.0
548 stars 54 forks source link

Fix compilation of empty resources as generated by MPW's DeRez #249

Closed briankendall closed 4 months ago

briankendall commented 4 months ago

MPW's DeRez command will produce empty resources in this format:

data 'ABCD' (128, "some resource name") {
};

Currently Retro68's reimplementation of Rez will see this as a syntax error. This PR makes a small change to RezParser to allow that syntax.

There are actually situations in classic mac apps where you're supposed to have a completely empty resource, namely when including a FONT resource. Each font family needs to have one extra FONT resource representing the family itself, and it contains no data.

(This is my first time working with Bison grammar, so please double check my work!)

autc04 commented 4 months ago

Yes, this will work.

Things might get slightly simpler if you add it as a second alternative to the data clause, such as | "data" res_spec "{" "}" { world.addData($res_spec, ""); } rather than introducing optional_string_expression.

But I'd be happy to merge this as is. Thanks!

briankendall commented 4 months ago

@autc04 That's quite a bit better solution than what I came up with! I went ahead and changed my PR to use that.

autc04 commented 4 months ago

Thanks again!