skoolkit icon indicating copy to clipboard operation
skoolkit copied to clipboard

#R macro parsing error is not fully helpful

Open Rui1973Martins opened this issue 2 years ago • 7 comments

If we by chance get something like this by mistake in some description/comment: #R$$5C48 We get this not fully helpful message ERROR: Error while parsing #R macro: No parameters (expected 1)

Please add a line (and column) number of the offending source, somewhere to the message.

This applies to other Error messages to, but it's easier and more concrete to report a specific one.

Rui1973Martins avatar Aug 15 '22 13:08 Rui1973Martins

By the time macros are expanded, line and column number information is no longer available, so it's not feasible to include them.

What I'll look at for that error (No parameters) in particular is whether the faulty parameter string can be included in the error message, so that at least you can then search for it in the source file.

skoolkid avatar Aug 15 '22 13:08 skoolkid

OK, that is a a work around. You could also output the full line being processed, if available.

However, if you don't have the line information when processing, that means that is something that you can improve in the implementation. You can add some kind of "context", to keep this type of transversal information.

You can even include some form o Macro processing Stack Frame, that will allow you to reach whatever info you may need.

I have been able to blow up the skool2html.py several times. It just prints out a dump of where the python application blowed up (not very useful for final user).

Rui1973Martins avatar Aug 15 '22 14:08 Rui1973Martins

Maybe unrelated, since the error is different.

ERROR: Error while parsing #R macro: Could not find instruction at $5C48

Same problem, message is not very helpful. Specially because the cause doesn't seem to be related with an instruction.

This usually happens, because there is no entry that defines this particular value as a data block (b).

Rui1973Martins avatar Aug 15 '22 14:08 Rui1973Martins

ERROR: Error while parsing #R macro: Could not find instruction at $5C48

Same problem, message is not very helpful. Specially because the cause doesn't seem to be related with an instruction.

That error message is stating that there is an #R macro whose address argument is $5C48, but it could not be expanded because there is no instruction at that address.

skoolkid avatar Aug 15 '22 16:08 skoolkid

That's exactly why it's confusing, since at that address it's supposed to be a variable and not an ASM instruction.

Here the problem seems to be the wording of the error message. Because an address can point to code (instructions) or data.

Maybe a message more specific about the address and not what is or is NOT on the address location, would be more helpful.

Something like: ERROR: Error while parsing #R macro: Could not find declaration/definition for addr $5C48. Check if the addr $5C48 is defined.

Rui1973Martins avatar Aug 15 '22 16:08 Rui1973Martins

When I do this, I just link to the Spectrum ROM disassembly rather than duplicate anything in my own disassembly;

$61E6,$04 #HTML(Write #N$00 to <a href="https://skoolkit.ca/disassemblies/rom/hex/asm/5C48.html">BORDCR</a>.)

https://github.com/pobtastic/ultimate/blob/main/sources/cookie/cookie.ctl#L312

pobtastic avatar Aug 15 '22 20:08 pobtastic

d269d187f68ccdc4ebd1635ff0ce594c27c2a68d improves the 'No parameters' error message by including the faulty parameter string (well, up to 10 characters of it, anyway).

skoolkid avatar Aug 16 '22 20:08 skoolkid