: opt_for_initializer SEMICOLON
{
((For) $0).Initializer = (Statement) $1;
+
+ // Pass the "For" object to the iterator_part4
+ oob_stack.Push ($0);
}
- opt_for_condition SEMICOLON
- {
- ((For) $0).Condition = (BooleanExpression) $4;
- }
- opt_for_iterator CLOSE_PARENS
- {
- ((For) $0).Iterator = (Statement) $7;
- }
+ for_condition_and_iterator_part
embedded_statement
{
- if ($10 is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE)
- Warning_EmptyStatement (GetLocation ($10));
+ var locations = (Tuple<Location,Location>) $4;
+ oob_stack.Pop ();
+ if ($5 is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE)
+ Warning_EmptyStatement (GetLocation ($5));
For f = ((For) $0);
- f.Statement = (Statement) $10;
- lbag.AddStatement (f, current_block.StartLocation, GetLocation ($2), GetLocation ($5), GetLocation ($8));
+ f.Statement = (Statement) $5;
+ lbag.AddStatement (f, current_block.StartLocation, GetLocation ($2), GetLocation (locations.Item1), GetLocation (locations.Item2));
$$ = end_block (GetLocation ($2));
}
}
;
+for_condition_and_iterator_part
+ : opt_for_condition SEMICOLON
+ {
+ For f = (For) oob_stack.Peek ();
+ f.Condition = (BooleanExpression) $1;
+ }
+ for_iterator_part {
+ $$ = new Tuple<Location,Location> (GetLocation ($2), (Location) $4);
+ }
+
+ // Handle errors in the case of opt_for_condition being followed by
+ // a close parenthesis
+ | opt_for_condition close_parens_close_brace {
+ report.Error (1525, GetLocation ($2), "Unexpected symbol expected ';'");
+ For f = (For) oob_stack.Peek ();
+ f.Condition = (BooleanExpression) $1;
+ $$ = new Tuple<Location,Location> (GetLocation ($2), GetLocation ($2));
+ }
+ ;
+
+for_iterator_part
+ : opt_for_iterator CLOSE_PARENS {
+ For f = (For) oob_stack.Peek ();
+ f.Iterator = (Statement) $1;
+ $$ = GetLocation ($2);
+ }
+ | opt_for_iterator CLOSE_BRACE {
+ report.Error (1525, GetLocation ($2), "Unexpected symbol expected ')'");
+ For f = (For) oob_stack.Peek ();
+ f.Iterator = (Statement) $1;
+ $$ = GetLocation ($2);
+ }
+ ;
+
+close_parens_close_brace
+ : CLOSE_PARENS
+ | CLOSE_BRACE { lexer.putback ('}'); }
+ ;
+
opt_for_initializer
: /* empty */ { $$ = new EmptyStatement (lexer.Location); }
| for_initializer
if (yacc_verbose_flag > 0)
throw;
- report.Error (589, lexer.Location, "Internal compiler error during parsing");
+ report.Error (589, lexer.Location, "Internal compiler error during parsing" + e);
}
}
}