JavaScript parser: Don't drop the token after an unbraced if

If an `if` haven't had braces, the code used to check itself for an
`else` after it, eating the next token if it wasn't actually an `else`.

So, drop the check for the else altogether since parseLine() handles
`else`s by calling parseIf() anyway.

This fixes constructs like:

	if (foo)
		bar();
	function baz() {
		// ...
	}

Closes #3568542.
This commit is contained in:
Colomban Wendling 2012-09-24 19:02:38 +02:00
parent 66888d580f
commit 297bca3799

View File

@ -805,36 +805,9 @@ static boolean parseIf (tokenInfo *const token)
{
findCmdTerm (token);
/*
* The IF could be followed by an ELSE statement.
* This too could have two formats, a curly braced
* multiline section, or another single line.
*/
if (isType (token, TOKEN_CLOSE_CURLY))
{
/*
* This statement did not have a line terminator.
*/
read_next_token = FALSE;
}
else
{
readToken (token);
if (isType (token, TOKEN_CLOSE_CURLY))
{
/*
* This statement did not have a line terminator.
*/
read_next_token = FALSE;
}
else
{
if (isKeyword (token, KEYWORD_else))
read_next_token = parseIf (token);
}
}
/* The next token should only be read if this statement had its own
* terminator */
read_next_token = isType (token, TOKEN_SEMICOLON);
}
return read_next_token;
}