how do you get from a continued fraction in the form like this:

[0;1,5,2,2] 

to a fraction in the form like this:

27/32

this patch gets as far as that [0; 1,5,2,2] form.  but i'm still not sure how to get further