Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file opamParser.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108(**************************************************************************)(* *)(* Copyright 2016-2018 OCamlPro *)(* *)(* All rights reserved. This file is distributed under the terms of the *)(* GNU Lesser General Public License version 2.1, with the special *)(* exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)(** Generic glue functions *)letparse_from_stringparse_funstrfilename=letlexbuf=Lexing.from_stringstrinlexbuf.Lexing.lex_curr_p<-{lexbuf.Lexing.lex_curr_pwithLexing.pos_fname=filename};parse_funOpamLexer.tokenlexbufletparse_from_channelparse_funicfilename=letlexbuf=Lexing.from_channelicinlexbuf.Lexing.lex_curr_p<-{lexbuf.Lexing.lex_curr_pwithLexing.pos_fname=filename};parse_funOpamLexer.tokenlexbufletparse_from_fileparse_funfilename=letic=open_in_binfilenameintryletr=parse_from_channelparse_funicfilenameinclose_inic;rwithe->close_inic;raisee(** file parsers *)letmain'mainfilenamelexerlexbuf=mainlexerlexbuffilenameletstringmainstrfilename=parse_from_string(main'mainfilename)strfilenameletchannelmainicfilename=parse_from_channel(main'mainfilename)icfilenameletfilemainfilename=parse_from_file(main'mainfilename)filenamemoduleFullPos=structopenOpamParserTypes.FullPos(** raw parser entry points *)letmain=OpamBaseParser.mainletvalue=OpamBaseParser.value(** file parsers *)letstring=stringmainletchannel=channelmainletfile=filemain(** value parsers *)letvalue_from_string=parse_from_stringvalueletvalue_from_channel=parse_from_channelvalueletvalue_from_file=parse_from_filevalue(* Functions to transform simple pos to full pos *)moduleS=OpamParserTypesletto_pose=(e.pos.filename,fste.pos.start,snde.pos.start)letrecto_valuev=matchv.pelemwith|Boolb->S.Bool(to_posv,b)|Inti->S.Int(to_posv,i)|Strings->S.String(to_posv,s)|Relop(r,v,v')->S.Relop(to_posr,r.pelem,to_valuev,to_valuev')|Prefix_relop(r,v)->S.Prefix_relop(to_posr,r.pelem,to_valuev)|Logop(l,v,v')->S.Logop(to_posl,l.pelem,to_valuev,to_valuev')|Pfxop(p,v)->S.Pfxop(to_posp,p.pelem,to_valuev)|Idents->S.Ident(to_posv,s)|Listl->S.List(to_posl,List.mapto_valuel.pelem)|Groupg->S.Group(to_posg,List.mapto_valueg.pelem)|Option(v,vl)->S.Option(to_posvl,to_valuev,List.mapto_valuevl.pelem)|Env_binding(v,o,v')->S.Env_binding(to_poso,to_valuev,o.pelem,to_valuev')letrecto_sections={S.section_kind=s.section_kind.pelem;S.section_name=(matchs.section_namewith|Somen->Somen.pelem|None->None);S.section_items=List.mapto_items.section_items.pelem}andto_itemi=matchi.pelemwith|Sections->S.Section(to_poss.section_kind,to_sections)|Variable(s,v)->S.Variable(to_poss,s.pelem,to_valuev)letto_opamfileo={S.file_contents=List.mapto_itemo.file_contents;S.file_name=o.file_name}end(** raw parser entry points *)letmainflfd=FullPos.to_opamfile(OpamBaseParser.mainflfd)letvaluefl=FullPos.to_value(OpamBaseParser.valuefl)(** file parsers *)letstring=stringmainletchannel=channelmainletfile=filemain(** value parsers *)letvalue_from_string=parse_from_stringvalueletvalue_from_channel=parse_from_channelvalueletvalue_from_file=parse_from_filevalue