-
-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Syntax error" message is way too obtuse #385
Comments
I have tried:
None of that works. |
The issue appears to stem from the variable not being defined. I don't understand how pokered manages to compile with this bug, however. |
Looks like the error was a conflicting variable name (register |
Yeah, the parser is less than ideal. For example, register |
Perhaps the handler for |
This is the Bison documentation on error reporting. https://www.gnu.org/software/bison/manual/html_node/Error-Reporting.html If we put You can also name the tokens like this: Then it prints the following: This would make things a little better. We need to ditch yacc if we want really nice errors. |
This is worth experimenting with, if only to slightly improve the experience. Wouldn't ditching yacc require basically a full rewrite? Not that it would be a bad thing, the code base reeks of 90's-era static buffer manipulation and other similar stuff, but that's a really bug project. |
Yeah. At that point, it might be better to just make a whole new assembler. It would be difficult to significantly improve rgbasm without drastically altering its design. |
HGBASM exists, but because it's built on JavaScript it's fairly slow compared to RGBDS (takes several seconds to assemble individual files in my project versus below half a second for RGBDS). I wanted to port it to C or C++, but sadly I don't understand how it works, so I dropped that idea. |
Yes, that's pretty much what I noticed ages ago... It's too much work, though. |
I like the idea of a new assembler, but I feel that any assembler that tries to be compatible with RGBDS will have to have hacky code to deal with the nature of |
As far as I know it has a few hacks to stay compatible, but is overall cleaner and more flexible. |
I took a look at it. It's a lot higher level than RGBDS and I suspect it would be slower than RGBDS even if you rewrote it in C++. I wouldn't even try to write something similar in C because it would be a lot more code in a lower-level language. It does look a lot cleaner, but it seems to me that it has some incompatibilities just from looking at its code. I would need to run it to confirm. |
Yes, it has some incompatibilities, since it doesn't try to emulate all quirks of the parser and custom lexer. It's more of a "99% compatibility" target, if you want. |
We may actually have to ditch POSIX yacc to get better and readable syntax errors:
|
Took another look at this, and we have a problem in the form of guessing where the line starts, printing the current line, and figuring out on which column the error occurred. I think the lexer would be the place to implement this in, but I'm worried in that there's a bunch of places where newlines could be read. |
Just to throw out an idea (but it's not a solution to the problem at hand): I've been building a generic assembler which primarily lets you define the syntax for a machine's instructions, and has some other nice features, like pretty error messages and math expression support everywhere. I've been following RGBDS for quite some time now, and unfortunately there's a bit of a long way before my assembler could become some kind of a replacement, but I nonetheless would like to know if there would be any interest in it! |
Separately from this issue if anything, the discussion is not about replacing this code base, but improving it. Besides,
sounds a lot like ASMotor. |
This, plus other QoL changes, sound to me like enough of a reason to switch to Bison instead of POSIX yacc. (Bison can print named symbols, and can also report where in the syntax it was). |
I'm not a BSD guy, I personally just use Debian at home. 😆 In general I have mixed feelings about dropping support for one tool. The way I see things, if switching tools means that the code can be clearer or easier to maintain, I'm generally for it, even if it means adding an extra explicit dependency. I guess that even BSD can install bison. |
Fixes the long-standing gbdev#385
Fixes the long-standing gbdev#385
Fixes the long-standing gbdev#385
Fixes the long-standing gbdev#385
Fixes the long-standing gbdev#385
Fixes the long-standing gbdev#385
Fixes the long-standing gbdev#385
Bison 3.6 introduced support for |
Actually, even |
I know, I tried, but it explodes with various colors. And I don't understand why yet. |
The text was updated successfully, but these errors were encountered: