Ruby parser: don't create an extra scope after "for .. in .. do"

When "do" appears as the separator after a "for", "while" or "until"
construct, don't improperly make it start its own scope too.
This commit is contained in:
Colomban Wendling 2012-09-13 16:07:44 +02:00
parent faeeaf4bd2
commit f1e88ca311

View File

@ -287,6 +287,9 @@ static void findRubyTags (void)
while ((line = fileReadLine ()) != NULL)
{
const unsigned char *cp = line;
/* if we expect a separator after a while, for, or until statement
* separators are "do", ";" or newline */
boolean expect_separator = FALSE;
if (canMatch (&cp, "=begin"))
{
@ -318,9 +321,14 @@ static void findRubyTags (void)
* puts("hello") \
* unless <exp>
*/
if (canMatch (&cp, "case") || canMatch (&cp, "for") ||
canMatch (&cp, "if") || canMatch (&cp, "unless") ||
if (canMatch (&cp, "for") || canMatch (&cp, "until") ||
canMatch (&cp, "while"))
{
expect_separator = TRUE;
enterUnnamedScope ();
}
else if (canMatch (&cp, "case") || canMatch (&cp, "if") ||
canMatch (&cp, "unless"))
{
enterUnnamedScope ();
}
@ -362,10 +370,17 @@ static void findRubyTags (void)
*/
break;
}
else if (canMatch (&cp, "begin") || canMatch (&cp, "do"))
else if (canMatch (&cp, "begin"))
{
enterUnnamedScope ();
}
else if (canMatch (&cp, "do"))
{
if (! expect_separator)
enterUnnamedScope ();
else
expect_separator = FALSE;
}
else if (canMatch (&cp, "end") && stringListCount (nesting) > 0)
{
/* Leave the most recent scope. */
@ -383,6 +398,11 @@ static void findRubyTags (void)
if (*cp == '"')
cp++; /* skip the last found '"' */
}
else if (*cp == ';')
{
++cp;
expect_separator = FALSE;
}
else if (*cp != '\0')
{
do