123456789101112131415161718192021222324252627moduleP=Interpolation_parsermoduleE=Interpolation_emitterletparser_to_emitter(tokens:(P.token*Location.t)list):E.tokenlist=List.rev@@snd@@List.fold_left(fun(cur_fmt,acc)(token,loc)->matchtoken,cur_fmtwith|P.Formatfmt,None->Some(fmt,loc),acc|P.Expressione,curr_fmt->None,E.Expression((e,loc),curr_fmt)::acc|P.Variablev,curr_fmt->None,E.Variable((v,loc),curr_fmt)::acc|_,Some(_,loc)->Location.raise_errorf~loc"Format is not followed by variable/expression. Missing %%?"|P.Strings,None->None,E.String(s,loc)::acc|P.DollarChar,None->None,E.String("$",loc)::acc|P.PercentChar,None->None,E.String("%",loc)::acc)(None,[])tokens