package ocaml-protoc

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Ocaml_protoc_compiler_lib.Pb_parsing_parse_treeSource

Protobuf parse tree

Sourcetype message_field_label = [
  1. | `Optional
  2. | `Required
  3. | `Repeated
  4. | `Nolabel
]

A field property defining its occurence

Sourcetype oneof_field_label = unit

Oneof field fields label

Oneof fields have no label, they are simply choices for the oneof fiel they belong to.

Sourcetype 'a field = {
  1. field_name : string;
  2. field_number : int;
  3. field_label : 'a;
  4. field_type : Pb_field_type.unresolved_t;
  5. 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.

Sourcetype message_field = message_field_label field
Sourcetype oneof_field = oneof_field_label field
Sourcetype map_field = {
  1. map_name : string;
  2. map_number : int;
  3. map_key_type : Pb_field_type.map_key_type;
  4. map_value_type : Pb_field_type.unresolved_t;
  5. map_options : Pb_option.set;
}
Sourcetype oneof = {
  1. oneof_name : string;
  2. oneof_fields : oneof_field list;
}

oneof entity

Sourcetype enum_value = {
  1. enum_value_name : string;
  2. enum_value_int : int;
}
Sourcetype enum_body_content =
  1. | Enum_value of enum_value
  2. | Enum_option of Pb_option.t
Sourcetype enum = {
  1. enum_id : int;
  2. enum_name : string;
  3. enum_body : enum_body_content list;
}
Sourcetype extension_range_to =
  1. | To_max
  2. | To_number of int
Sourcetype extension_range_from = int
Sourcetype extension_range =
  1. | Extension_single_number of int
  2. | Extension_range of extension_range_from * extension_range_to
Sourcetype message_body_content =
  1. | Message_field of message_field
  2. | Message_map_field of map_field
  3. | Message_oneof_field of oneof
  4. | Message_sub of message
  5. | Message_enum of enum
  6. | Message_extension of extension_range list
  7. | Message_reserved of extension_range list
  8. | Message_option of Pb_option.t

Body content defines all the possible consituant of a message.

Sourceand message = {
  1. id : int;
  2. message_name : string;
  3. message_body : message_body_content list;
}

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.

Sourcetype rpc = {
  1. rpc_name : string;
  2. rpc_options : Pb_option.set;
  3. rpc_req_stream : bool;
  4. rpc_req : Pb_field_type.unresolved_t;
  5. rpc_res_stream : bool;
  6. rpc_res : Pb_field_type.unresolved_t;
}
Sourcetype service_body_content =
  1. | Service_rpc of rpc
  2. | Service_option of Pb_option.t
Sourcetype service = {
  1. service_name : string;
  2. service_body : service_body_content list;
}
Sourcetype extend = {
  1. id : int;
  2. extend_name : string;
  3. extend_body : message_field list;
}
Sourcetype import = {
  1. file_name : string;
  2. public : bool;
}
Sourcetype proto = {
  1. proto_file_name : string option;
  2. syntax : string option;
  3. imports : import list;
  4. file_options : Pb_option.set;
  5. package : string option;
  6. messages : message list;
  7. services : service list;
  8. enums : enum list;
  9. extends : extend list;
}

Definition of a protobuffer message file.

OCaml

Innovation. Community. Security.