-
Notifications
You must be signed in to change notification settings - Fork 118
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
BASIC does not report error location #2199
Comments
Basic does report the line number for which the error occurred, as long as there is a line number - see host.c::loop():
The error you are receiving, "Unexpected Input" is returned in basic.c in only two places, in the function nextToken (ERROR_LEXER_UNEXPECTED_INPUT). The first case is:
This error is returned when a $ is encountered that is not at the end of an identifier. The other case:
is returned when no valid Basic language token is parsed. Based on this, but without looking at your program, I would guess they're either some invalid ASCII characters in the file, or the first issue of $ not at end of a variable. To further debug, try cutting your program in halves and loading it, successively until you find out the error. A line number is not valid possibly because the error is before the first line number? |
Oops - further inspection of the basic tokenization process shows that the program source is first loaded using a call to tokenize function:
It appears during this process that program is merely being tokenized into a token input buffer, and no line numbers have yet been assigned. This is why the error does not display a line number. Let me look into how we might be able to learn where the tokenization got an error. |
I've tracked it down. Please apply this patch to basic/host.c, which should display the input line from which any tokenization error occurs. This will display the input line having the error, followed by the error. If this works, I'll prepare a PR for you.
|
So I put this in a file called basic_line_error.patch and I do
Actually it is hard for me to test because I just can not copy .bas files inside an image. I mount fat ELKS images with a special program on Windows. But it is a very laborious work. |
For displayed patches, just do:
I've created PR #2202 since testing this isn't easy for you. ELKS Basic is available as a host program
I plan to build all the host-available applications automatically, I'll try to get that done sooner.
I sometimes copy files to the ELKS /root before building an image, which makes things easier. To do this:
|
Thank you! hostbasic is a 64 bit version? Nice, but how is the graphic implemented then? Not sure I get it. |
Yes. But no graphics in the host versions: each platform, host, ibmpc and pc98 have their own host-xxx.c platform file. I only suggested using hostbasic to quickly learn where your syntax error is, which is what this open issue is all about? |
Yes. SDL2 for C can be used for the host. In theory it should be easy to implement. I can look into this when I have time. |
Yes. I'm quite familiar with SDL2 and have a full driver for that for the real Microwindows - but not sure it'd be worth the effort to build all that since 1) few people use ELKS basic, and 2) native support for ELKS basic would be far less resolution than would be available on the host. There would have to be work required to emulate the smaller resolution on the high resolution host, which involves additional effort. |
I can not build the host basic. I am using gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
|
The math library is missing on Linux. Add -lm as follows to the Makefile:
|
Thanks. |
Glad you were able to find the error. Where did gorilla.bas come from, another basic or did you write it yourself? I'm wondering whether we should consider allowing underscore to be in identifiers or not? If gorillas.bas is from another basic, we might want to allow it to be more compatible, otherwise we probably should not as other basics don't allow it. |
It seems our basic does not support multi-line IF ELSE ... |
Actually looking at basic.h it look like "ELSE" is not a supported token. |
Yes, that's definitely the case. I think our basic is pretty good, small and fast; I looked around a while before finding this one. It's language support is very similar to Sinclair Basic, but unfortunately there seem to be a ton of dialects and even extensions to Sinclair Basic. I remember running into this issue a while ago - of course an ELSE capability could be added, but even then we're not guaranteed it'd be compatible with other programs already written. |
One solution that I am already using for Gorillas.bas is to give Chatgpt the list of supported features in our basic based on the README. You need to create a good prompt where the missing features are clearly explained. After that this prompt can be used many times to rewrite existing basic code into our dialect. It works, but not perfectly. Still this method can only get better with time. |
@ghaerr Thanks for the line reporting. |
Is it possible that we add at which line (text file line) the error occurred?
The text was updated successfully, but these errors were encountered: