@@ -583,6 +583,7 @@ private Expression ParseYieldExpression() {
583583 FunctionDefinition current = CurrentFunction ;
584584 if ( current != null ) {
585585 current . IsGenerator = true ;
586+ current . GeneratorStop = GeneratorStop ;
586587 }
587588
588589 var start = GetStart ( ) ;
@@ -889,6 +890,9 @@ private FromImportStatement ParseFromImportStmt() {
889890 // Ignored in Python 3
890891 } else if ( name == "unicode_literals" ) {
891892 // Ignored in Python 3
893+ } else if ( name == "generator_stop" ) {
894+ // New in 3.5, mandatory in 3.7
895+ _languageFeatures |= ModuleOptions . GeneratorStop ;
892896 } else if ( name == "nested_scopes" ) {
893897 } else if ( name == "generators" ) {
894898 } else {
@@ -2500,6 +2504,7 @@ private Expression ParseGeneratorExpression(Expression expr) {
25002504 Parameter parameter = new Parameter ( "__gen_$_parm__" , 0 ) ;
25012505 FunctionDefinition func = new FunctionDefinition ( fname , new Parameter [ ] { parameter } , root ) ;
25022506 func . IsGenerator = true ;
2507+ func . GeneratorStop = GeneratorStop ;
25032508 func . SetLoc ( _globalParent , root . StartIndex , GetEnd ( ) ) ;
25042509 func . HeaderIndex = root . EndIndex ;
25052510
@@ -3159,6 +3164,8 @@ private Token EatEndOfInput() {
31593164 return PythonOps . BadSourceEncodingError ( message , lineNum , _sourceUnit . Path ) ;
31603165 }
31613166
3167+ private bool GeneratorStop => ( _languageFeatures & ModuleOptions . GeneratorStop ) == ModuleOptions . GeneratorStop ;
3168+
31623169 private void StartParsing ( ) {
31633170 if ( _parsingStarted )
31643171 throw new InvalidOperationException ( "Parsing already started. Use Restart to start again." ) ;
0 commit comments