-
Notifications
You must be signed in to change notification settings - Fork 18
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
Fix syntax errors in issue #34 #36
base: master
Are you sure you want to change the base?
Conversation
I guess I did break the build on windows at least. But there are no logs... I'll try to hack the NSC1040 error code back in. Not sure there's a place to hook the too many errors one (NSC1041) |
I fixed the NSCXXXX error messages, with the exception of a lowercase "syntax" versus an uppercase one. |
Tested this from your repo and got similar good results on error reporting. Great work! |
@ELadner, thanks for testing it! Hopefully someone has access to the logs and can see what's wrong with the other builds. |
@virusman - what's this need to get approved? Possibly updating the bison version in the build environment would fix the error: D:/a/nwnsc/nwnsc/_NscLib/NscParser.ypp:39.9-19: error: %define variable 'parse.error' is not used perse.error is Bison 3.8.1+ |
Hi @meaglyn! I'm sorry this took so long. I can't tell what it's failing on, but here's the last part of the build log. Let me know if you need more.
|
Edited for brevity...
This still looks like the If you are using bison.. what's |
For windows build you need For macos, path is messed up. It isn't using the bison installed with brew, but some ancient version. It's so long ago I saw this, I forget exactly. The logs are gone now, but something like Cheers. |
fixing more errors
Glad you got it to build. Sorry, I have not had much time for this lately. Thanks Jd28. |
Fix syntax error reporting by using bison's built in error messages. Remove the hand rolled recovery mechanism. This means it no longer supports bison <3.0 but it also means it works as is on both 3.0 and 3.6+. Set errors to verbose. Bison 3.6+ uses a type named context which was getting covered by the NscContext name and causing compilation to fail on the generated code. Change that to "ctxt".
Restore NSC1040 error code to syntax errors and implement hack to report NSC1041 when aborting for too many errors.
Remove NscBuildSyntaxError routine since it is no longer used.
There is no longer any code using the NWN_BISON_3 or NWN_BISON_3_6 defines so remove them from CmakeLists.txt.
I updated this to the latest to resolve the conflict. Plus it's on top of linux-lower since I require that one to be able to use the compiler. |
Also, I've started using this compiler instead of my older version since updating it to get the new features was getting ... old. So hopefully we can get this and the lowercase thing in at some point :) |
The main problem is the nwnsc docker build image is using an old version of bison.
Perhaps the fix would be to bump it to a more recent version? I'm not even sure what distro would be shipping a bison version that old. Bison 2.4.1 was released in 2008; 3.8.2 was released ~9 months ago. |
Daz indicated that nwserver-linux is built on Ubuntu 18.04. Perhaps that would be a better build platform than the older holy build box that the nwnsc docker image is derived from. |
Indeed. That would be good. I did try to preserve the older bison compatibility but it became a losing battle. |
The bad syntax error messages are caused by the bogus fix for
bison versions > 3.0. The original compiler all these are based
on was written for bison of 20 years ago and has a home rolled
error message generator and recovery mechanism. This doesn't work
with newer bison but bison can do this for us.
This removes support for bison <3.0 and enables the built in
syntax error reporting. This makes for a much better experience.
But it also removes all those compatibility macros since they were
only used for this handrolled error handling.
(Note, I don't know where the extra '\n's come from. They are in both
the before and after nwnsc when I build it. My nwnsscomp doesn't do that.)
err.nss
../nwnsc/nwnsc -i base_scripts err.nss
Before:
Compiling: err.nss
err.nss(5): Error: NSC1040: Syntax error at "J"
err.nss(6): Error: NSC1040: Syntax error at "�"
err.nss(7): Error: NSC1040: Syntax error at "�"
...
err.nss(104): Error: NSC1040: Syntax error at "�"
err.nss(104): Error: NSC1041: Compiler has reached the limit of 100 errors, aborting
Compilation aborted with errors.
After:
Compiling: err.nss
err.nss(5): Error: NSC1040: syntax error, unexpected '}', expecting ';'
Compilation aborted with errors.
I've set a limit of 32 errors. There was a limit of 100 but that's a lot for scripts. It's
hard to get to that now that it unwinds and recovers better.
I just noticed as I wrote this that it does drop the NSC1040 error number. Since this
path is all pretty much syntax errors it might be possible to hard code that back in...
V2: Added a fix for this and a hack to include the NSC1041 too many errors message
as well.
I've tested with a number of syntax errors on larger files and in includes and at different
places in the file etc. Also tested working scripts and 2nd pass errors (e.g. undefined
symbols and such) which all work as before since this really only effects the first pass
parsing.
I have not built or tested on MAC or Windows, as usual. Hopefully didn't break those.
Also, cleaned up a bit of code that was no longer needed.
Feel free to take this or not. I hope that it helps.
Cheers,
meaglyn