gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > parse error?

#3286 - Garland - Fri Feb 21, 2003 8:16 pm

I know it is probably a very stupid question, but what is a parse error and how can I fix it? I have fixed every error in my game (read: the intro) except for the parse errors. Its says: Parse error before ';' token, and Parse error before ')' token. I use Devkitadvs GCC. Thanks.

#3287 - Rich - Fri Feb 21, 2003 8:20 pm

Parse errors are caused when the compiler doesn't understand the source that it's trying to comple.

Most common errors are missing brackets and braces and the like.

Can you post the lines of source code that the compiler is complaining about?

#3294 - Garland - Fri Feb 21, 2003 9:03 pm

sure, here it is:

int main(void)
{
SetMode(MODE_4 | BG2_ENABLE);

int x, y, z;
for(x = 0; x < 256; x++)
paletteMem[x] = KOElogoPalette[x];
for(y = 0; y < 160; y++)
{
for(x = 0; x < 120; x++)

{
PlotPixel(x,y,KOElogoData[y*120+x]);//logoData contains the color values of your pict

}
}
while (z = 0; z < 20000; z++ ); {}
}

and the he complains about "while (z = 0; z < 20000; z++ ); {}"

I got that command from a guy on this forum. For looping so that the program will wait.

Thanks

#3296 - BitWise - Fri Feb 21, 2003 9:17 pm

Woah, Change the while statement to read

while (z = 0; z < 20000; z++ ) /* Do nothing */ ;

#3298 - tom - Fri Feb 21, 2003 10:56 pm

i'd rather try
Code:

for (z = 0; z < 20000; z++ ) /* Do nothing */ ;

#3305 - Garland - Sat Feb 22, 2003 3:05 pm

thanks, the
Code:
for (z = 0; z < 20000; z++ ) /* Do nothing */ ;

worked. I think I can get on with my game now.

#3374 - CoolMan - Sun Feb 23, 2003 7:09 pm

Code:

/*
C syntax is very flexible, and conforms well to style, however you have to stay within bounds.
*/

while(sum_num) { ; } //This works. (My personal favorite syntax.)

while(sum_num) ; //This works.

while(sum_num)
        ; //This works too.

while(sum_num)
        {
        ; ; ; ; //Even this works.
        }

/*
The reason why yours failed was because you had brackets with no instructions in them. Brackets are there to keep (more then) one instruction apart from the others. (As in a logical flow chunk.)

If you don't have any instructions in a set of brackets, the compiler can only assume that something bad has happened.
*/

_________________
Moron! You don't herd chickens with a shotgun!

--CoolMan