123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354(**************************************************************************)(* *)(* OCaml *)(* *)(* Jeremie Dimino, Jane Street Europe *)(* *)(* Copyright 2015 Institut National de Recherche en Informatique et *)(* en Automatique. *)(* *)(* 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. *)(* *)(**************************************************************************)openAsttypesopenParsetreetypeerror=|Multiple_attributesofstring|No_payload_expectedofstringexceptionErrorofLocation.t*errorletget_no_payload_attributealt_namesattrs=matchList.filter(funa->List.mema.attr_name.txtalt_names)attrswith|[]->None|[{attr_name=name;attr_payload=PStr[];attr_loc=_}]->Somename|[{attr_name=name;_}]->raise(Error(name.loc,No_payload_expectedname.txt))|_::{attr_name=name;_}::_->raise(Error(name.loc,Multiple_attributesname.txt))lethas_no_payload_attributealt_namesattrs=matchget_no_payload_attributealt_namesattrswith|None->false|Some_->trueopenFormatletreport_errorppf=function|Multiple_attributesname->fprintfppf"Too many `%s' attributes"name|No_payload_expectedname->fprintfppf"Attribute `%s' does not accept a payload"namelet()=Location.register_error_of_exn(function|Error(loc,err)->Some(Location.error_of_printer~locreport_errorerr)|_->None)