> Somehow, the filename { causes rc.exe to think the filename token is actually the preceding token, so it's trying to interpret ICON as both the resource type and the file path of the resource. Who knows what's going on there.
> [...]
> Strangely, rc.exe will treat FOO [in place of the resource type, followed by EOF] as both the type of the resource and as a filename (similar to what we saw earlier in "BEGIN or { as filename").
Having written a stupid lexer recently, I’m almost certain I know what’s going on there. The lexer has a lexeme type global that it always sets, and a separate lexeme text global that it only sets for text-like tokens (numbers, identifiers, strings, and bare filenames, which it does not interpret other than to tell where they end, that being the easiest way to deal with ANSI C’s pp-numbers) but not for punctuation or EOF. Now have the code that looks for the resource filename blindly reach into the text global without first checking the type global (not even to check if it’s EOF), and you get exactly the behaviour above.
(Alternatively, the type could instead be returned by the next-lexeme function—that’s what my stupid lexer currently does, anyway, though I’m considering changing it. The result is the same.)
> For whatever reason, rc.exe will just take the last number literal in the expression and try to read from a file with that name [...].
I think I’m skilled enough to fuck that up too: the code to read the filename calls the expression parser (which is either not supposed to be called at EOF, or returns EOF that you’re supposed to check for in case that happens) and then blindly reaches into the lexeme text variable.
> [...]
> Strangely, rc.exe will treat FOO [in place of the resource type, followed by EOF] as both the type of the resource and as a filename (similar to what we saw earlier in "BEGIN or { as filename").
Having written a stupid lexer recently, I’m almost certain I know what’s going on there. The lexer has a lexeme type global that it always sets, and a separate lexeme text global that it only sets for text-like tokens (numbers, identifiers, strings, and bare filenames, which it does not interpret other than to tell where they end, that being the easiest way to deal with ANSI C’s pp-numbers) but not for punctuation or EOF. Now have the code that looks for the resource filename blindly reach into the text global without first checking the type global (not even to check if it’s EOF), and you get exactly the behaviour above.
(Alternatively, the type could instead be returned by the next-lexeme function—that’s what my stupid lexer currently does, anyway, though I’m considering changing it. The result is the same.)
> For whatever reason, rc.exe will just take the last number literal in the expression and try to read from a file with that name [...].
I think I’m skilled enough to fuck that up too: the code to read the filename calls the expression parser (which is either not supposed to be called at EOF, or returns EOF that you’re supposed to check for in case that happens) and then blindly reaches into the lexeme text variable.