Namespace current_namespace;
TypeContainer current_container;
+ IIteratorContainer iterator_container;
+
// <summary>
// Current block is used to add statements as we find
// them.
%token VOLATILE
%token WHILE
+/* v2 tokens */
+%token YIELD
+
/* C# keywords which are not really keywords */
%token GET "get"
%token SET "set"
}
current_namespace.DeclarationFound = true;
}
- | namespace_declaration
+ | namespace_declaration {
+ current_namespace.DeclarationFound = true;
+ }
;
type_declaration
;
method_declaration
- : method_header
+ : method_header {
+ iterator_container = (IIteratorContainer) $1;
+ }
method_body
{
Method method = (Method) $1;
- Block b = (Block) $2;
+ Block b = (Block) $3;
const int extern_abstract = (Modifiers.EXTERN | Modifiers.ABSTRACT);
if (b == null){
}
}
- method.Block = (Block) $2;
+ method.Block = (Block) $3;
CheckDef (current_container.AddMethod (method), method.Name, method.Location);
current_local_parameters = null;
+ iterator_container = null;
}
;
: statement_expression
{
// CHANGE: was `null'
- Block b = new Block (current_block, true);
+ Block b = new Block (current_block, Block.Flags.Implicit);
b.AddStatement ((Statement) $1);
$$ = b;
{
oob_stack.Push (current_block);
- Block foreach_block = new Block (current_block, true);
+ Block foreach_block = new Block (current_block, Block.Flags.Implicit);
LocalVariableReference v = null;
Location l = lexer.Location;
VariableInfo vi;
| goto_statement
| return_statement
| throw_statement
+ | yield_statement
;
break_statement
}
;
+yield_statement
+ : YIELD expression SEMICOLON
+ {
+ if (iterator_container == null){
+ Report.Error (204, lexer.Location, "yield statement can only be used within a method, operator or property");
+ $$ = null;
+ } else {
+ iterator_container.SetYields ();
+ $$ = new Yield ((Expression) $2, lexer.Location);
+ }
+ }
+ | YIELD BREAK SEMICOLON
+ {
+ if (iterator_container == null){
+ Report.Error (204, lexer.Location, "yield statement can only be used within a method, operator or property");
+ $$ = null;
+ } else {
+ iterator_container.SetYields ();
+ $$ = new YieldBreak (lexer.Location);
+ }
+ }
+ ;
+
opt_expression
: /* empty */
| expression
type fixed_pointer_declarators
CLOSE_PARENS
{
- Block assign_block = new Block (current_block, true);
+ Block assign_block = new Block (current_block, Block.Flags.Implicit);
ArrayList list = (ArrayList) $4;
Expression type = (Expression) $3;
Location l = lexer.Location;
// int j = 1; int k = j + 1;
//
if (current_block.Used) {
- implicit_block = new Block (current_block, true, loc, Location.Null);
+ implicit_block = new Block (current_block, Block.Flags.Implicit, loc, Location.Null);
implicit_block.AddChildVariableNames (current_block);
} else
implicit_block = current_block;
Block implicit_block;
if (current_block.Used)
- implicit_block = new Block (current_block, true);
+ implicit_block = new Block (current_block, Block.Flags.Implicit);
else
implicit_block = current_block;