#NEWLINE# def returnOrYield( tokenizer , staticContext ) : #NEWLINE# #INDENT# builder = staticContext . builder #NEWLINE# tokenType = tokenizer . token . type #NEWLINE# if ( tokenType == 'return' ) : #NEWLINE# #INDENT# if ( not staticContext . inFunction ) : #NEWLINE# #INDENT# raise SyntaxError ( 'Return not in function' , tokenizer ) #NEWLINE# #UNINDENT# node = builder . RETURN_build ( tokenizer ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not staticContext . inFunction ) : #NEWLINE# #INDENT# raise SyntaxError ( 'Yield not in function' , tokenizer ) #NEWLINE# #UNINDENT# staticContext . isGenerator = True #NEWLINE# node = builder . YIELD_build ( tokenizer ) #NEWLINE# #UNINDENT# nextTokenType = tokenizer . peek ( True ) #NEWLINE# if ( ( nextTokenType != 'end' ) and ( nextTokenType != 'newline' ) and ( nextTokenType != 'semicolon' ) and ( nextTokenType != 'right_curly' ) and ( ( tokenType != 'yield' ) or ( ( nextTokenType != tokenType ) and ( nextTokenType != 'right_bracket' ) and ( nextTokenType != 'right_paren' ) and ( nextTokenType != 'colon' ) and ( nextTokenType != 'comma' ) ) ) ) : #NEWLINE# #INDENT# if ( tokenType == 'return' ) : #NEWLINE# #INDENT# builder . RETURN_setValue ( node , Expression ( tokenizer , staticContext ) ) #NEWLINE# staticContext . hasReturnWithValue = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# builder . YIELD_setValue ( node , AssignExpression ( tokenizer , staticContext ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( tokenType == 'return' ) : #NEWLINE# #INDENT# staticContext . hasEmptyReturn = True #NEWLINE# #UNINDENT# #UNINDENT# if ( staticContext . hasReturnWithValue and staticContext . isGenerator ) : #NEWLINE# #INDENT# raise SyntaxError ( 'Generator returns a value' , tokenizer ) #NEWLINE# #UNINDENT# if ( tokenType == 'return' ) : #NEWLINE# #INDENT# builder . RETURN_finish ( node ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# builder . YIELD_finish ( node ) #NEWLINE# #UNINDENT# return node