123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166(*
The MIT License (MIT)
Copyright (c) 2016 Maxime Ransan <maxime.ransan@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*)(** Protobuf parse tree *)typemessage_field_label=[`Optional|`Required|`Repeated|`Nolabel(* proto3 field which replaces required and optional *)](** A field property defining its occurence
*)typeoneof_field_label=unit(** Oneof field fields label
Oneof fields have no label, they are simply choices for the
oneof fiel they belong to. *)type'afield={field_name:string;field_number:int;field_label:'a;field_type:Pb_field_type.unresolved_t;field_options:Pb_option.set;}(** message field.
Note this field is parametrized with the label type
so that it can be used both by normal field and one of
field since the only difference between the 2 is
the label.
*)typemessage_field=message_field_labelfieldtypeoneof_field=oneof_field_labelfieldtypemap_field={map_name:string;map_number:int;map_key_type:Pb_field_type.map_key_type;map_value_type:Pb_field_type.unresolved_t;map_options:Pb_option.set;}typeoneof={oneof_name:string;oneof_fields:oneof_fieldlist;}(** oneof entity *)typeenum_value={enum_value_name:string;enum_value_int:int;}typeenum_body_content=|Enum_valueofenum_value|Enum_optionofPb_option.ttypeenum={enum_id:int;enum_name:string;enum_body:enum_body_contentlist;}typeextension_range_to=|To_max|To_numberofinttypeextension_range_from=inttypeextension_range=|Extension_single_numberofint|Extension_rangeofextension_range_from*extension_range_to(** Body content defines all the possible consituant
of a message.
*)typemessage_body_content=|Message_fieldofmessage_field|Message_map_fieldofmap_field|Message_oneof_fieldofoneof|Message_subofmessage|Message_enumofenum|Message_extensionofextension_rangelist|Message_reservedofextension_rangelist|Message_optionofPb_option.tandmessage={id:int;message_name:string;message_body:message_body_contentlist;}(** Message entity.
Note the ID is simply for uniquely (and easily) identifying a type. It is
expected to be generated by a parser. The later compilation
functions expects this id to be unique.
*)typerpc={rpc_name:string;rpc_options:Pb_option.set;rpc_req_stream:bool;rpc_req:Pb_field_type.unresolved_t;rpc_res_stream:bool;rpc_res:Pb_field_type.unresolved_t;}typeservice_body_content=|Service_rpcofrpc|Service_optionofPb_option.ttypeservice={service_name:string;service_body:service_body_contentlist;}typeextend={id:int;extend_name:string;extend_body:message_fieldlist;}typeimport={file_name:string;public:bool;}typeproto={proto_file_name:stringoption;syntax:stringoption;imports:importlist;file_options:Pb_option.set;package:stringoption;messages:messagelist;services:servicelist;enums:enumlist;extends:extendlist;}(** Definition of a protobuffer message file.
*)