Croteam-official/Serious-Engine

Possibly error in Bison Source file.

ljrk0 opened this issue · 7 comments

ljrk0 commented

At least I get:

Serious-Engine/Sources/Ecc/Parser.y:1076:96: error: expected ‘;’ before ‘}’ token

snippet (3rd line here is 1076 line in source):

statement
  : expression ';' {$$=$1+$2;}
  | k_switch '(' expression ')' '{' statements '}' {$$=$1+$2+$3+$4+$5+$6+$7}
  | k_case case_constant_expression ':' {$$=$1+" "+$2+$3+" ";}
  | '{' statements '}' {$$=$1+$2+$3;}
  | expression '{' statements '}' {$$=$1+$2+$3+$4;}

This seems correct as it's the only one where there's no ';' before the closing brace. I fixed this locally and on my devel branch and it builds correctly with this fix -- but I'm no expert in Bison so you might want to look into this yourself.

Unfortunately I cannot reproduce that, ECC builds fine for me. Are you using a version of Bison supplied with the engine? Does anyone else encounter this?

ljrk0 commented

Well, I think it works because it's not regenerated as you already supply a version. Possibly deleting the Parser.h/Parser.cpp file would do the trick of reproducing.

I'm actually building on Linux (Bison 3.0.4) but this does seem to be an issue anyway and nothing that should relate to the version (except that maybe your build tolerated the issue and just moved on or something).

I deleted all generated files before building, including Parser.h/Parser.cpp. I'm not an expert in Bison unfortunately, so I should see if your proposed change makes any difference in files generated by ECC.

ljrk0 commented

Okay, I try to reproduce on Windows as soon as I get on my Windows machine again, too ;-)

The .y file compiles fine on the older version of Bison because the older version automatically inserts a semi-colon to the end of every statement, thus there were no such issues (in fact statements with semi-colon ended up with 2 semicolons on the generated parser source).

However, the newer version of Bison does not do that (which makes more sense tbh). Can confirm the same error as @leonardkoenig, on cygwin32's Bison (3.0.4).

Since the older version of the bison executable is in the repo, @SLAwww your call on whether this should be fixed. I think no harm is done to fix this minor error though.

ljrk0 commented

@yamgent Thanks for the explanation! Yes, it really generates an additional ';' which is a NOP for the C/C++ code.
And since all the other statements put a ';' at the end and it's more compatible it wouldn't do any harm there either.

Okay, I agree with @yamgent on this one, commit 6e9fbef should contain the fix.