Because the compiler depends on the structure of the program to determine what is valid and is not valid, sometimes errors earlier in the program can make a later line be detected as an error.
If the line it is whining about looks correct, look closely at the previous lines. Often you may have an error there like not having a closing quote or a closing bracket.