solemnwarning / rehex

Reverse Engineers' Hex Editor
https://rehex.solemnwarning.net/
GNU General Public License v2.0
2.31k stars 116 forks source link

Parse error reports only at the function level, not at the parse failure location #158

Closed mdaniel closed 2 years ago

mdaniel commented 2 years ago

I was trying out the binary-template plugin after your announcement on Reddit and encountered a parse error. It took me forever to boil it down to a reproducible case because the error message implied it was the function signature that was the problem. However, it turned out one of the statements down in the function that was the problem all along

Given:

void thisFunctionIsBad() {
    local char c = '0';
}

it produces

...ns/REHex.app/Contents/PlugIns/binary-template/parser.lua:109: Parse error at /Applications/REHex.app/Contents/PlugIns/binary-template/templates/bob.bt:1 (at 'void thisFu')

instead of

Parse error at /Applications/REHex.app/Contents/PlugIns/binary-template/templates/bob.bt:2 (at "= '")

or similar

In hindsight (as with all good bugs!), I noticed that the docs actually don't mention character literals, so it was my "C muscle memory" leaking through. Given that it appears to be inspired by the 010 language, their strings page does seem to imply that single quotes are allowed, but it's unclear if they differ from just using " or when one would use which style

solemnwarning commented 2 years ago

oop, thanks for pointing these out. I'll try to get the error reporting ahd character literals sorted out tomorrow.