12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061openStdunetypet=Aofstring[@@unboxed]letequal(Aa)(Ab)=String.equalabletis_valid_dune=letrecloopsilen=i=len||matchString.unsafe_getsiwith|'%'->after_percents(i+1)len|'"'|'('|')'|';'|'\000'..'\032'|'\127'..'\255'->false|_->loops(i+1)lenandafter_percentsilen=i=len||matchString.unsafe_getsiwith|'%'->after_percents(i+1)len|'"'|'('|')'|';'|'\000'..'\032'|'\127'..'\255'|'{'->false|_->loops(i+1)leninfuns->letlen=String.lengthsinlen>0&&loops0lenletis_valid_jbuildstr=letlen=String.lengthstrinlen>0&&letrecloopix=matchstr.[ix]with|'"'|'('|')'|';'->true|'|'->ix>0&&letnext=ix-1instr.[next]='#'||loopnext|'#'->ix>0&&letnext=ix-1instr.[next]='|'||loopnext|' '|'\t'|'\n'|'\012'|'\r'->true|_->ix>0&&loop(ix-1)innot(loop(len-1))letof_strings=Asletto_string(As)=sletis_valid(At)=function|Syntax.Jbuild->is_valid_jbuildt|Dune->is_valid_dunetletprint((Aatom)ast)syntax=ifis_validtsyntaxthenatomelsematchsyntaxwith|Jbuild->Exn.code_error"atom cannot be printed in jbuild syntax"["atom",Sexp.Atomatom]|Dune->Exn.code_error"atom cannot be printed in dune syntax"["atom",Sexp.Atomatom]letof_inti=of_string(string_of_inti)letof_floatx=of_string(string_of_floatx)letof_boolx=of_string(string_of_boolx)letof_digestd=of_string(Digest.to_stringd)letof_int64i=of_string(Int64.to_stringi)