Piqi Self-definition
This page contains Piqi self-definition represented as a set of Piqi files included by each other starting from the top piqi.piqi.
File names are clickable. When clicked, contents become visible in a tabbed view. Tabbed view displays type definitions represented in various formats:
- Source — Source file.
- Piqi.Proto — Protocol Buffers data definitions converted from Piqi using
piqi to-protocommand. - Proto.Piqi — Piqi type specification converted from Protocol Buffers
.protofile viapiqi of-protocommand. - Piqi-light — Piqi type specification represented in Piqi-light syntax.
- Expanded Piqi — Piqi file where all
includeandextenddirectives have been applied usingpiqi expand, which produces plain type specifications without external includes and extensions. - Expanded Piqi-light — The same as the previous one but represented in Piqi-light syntax.
(These files can be also found in the Piqi source distribution.)
Piqi self-definition
% The current Piqi self-specification
%
% This file contains defintion of the Piqi self-specification
%
% Copyright 2009, 2010, 2011, 2012, 2013 Anton Lavrik
% aliases for built-in types; these definitions are automatically included in
% each Piqi module except modules named "piqi"
.alias [ .name bool .piqi-type.bool ]
.alias [ .name string .piqi-type.string ]
.alias [ .name binary .piqi-type.binary ]
.alias [ .name piqi-any .piqi-type.any ]
.alias [ .name int .piqi-type.int ]
.alias [ .name uint .piqi-type.int ]
.alias [ .name int32 .piqi-type.int ]
.alias [ .name uint32 .piqi-type.int ]
.alias [ .name int64 .piqi-type.int ]
.alias [ .name uint64 .piqi-type.int ]
.alias [ .name float64 .piqi-type.float ]
.alias [ .name float32 .piqi-type.float ]
% Fixed versions of int32/64 and uint32/64. "Fixed" here means that they are
% represented on the wire using exactly 4 and 8 bytes respectively.
.alias [
.name int32-fixed
.type int32
.piqi-type.int
]
.alias [
.name uint32-fixed
.type uint32
.piqi-type.int
]
.alias [
.name int64-fixed
.type int64
.piqi-type.int
]
.alias [
.name uint64-fixed
.type uint64
.piqi-type.int
]
.alias [
.name float
.type float64
.piqi-type.float
]
%
% end of built-in types
%
.alias [
.name word
.type string
.piq-format.word % print it as word instead of a quoted string literal
]
.alias [
.name name
.type word
]
.variant [
% user-defined types
.name typedef
.option [ .type record ]
.option [ .type variant ]
.option [ .type enum ]
.option [ .type alias ]
.option [
.type list
]
.protobuf-name "piqi_typedef"
]
.enum [
% built-in Piqi types
.name piqi-type
% prefix all options in order to prevent clash with keywords of the Protobuf
% target languages
.protobuf-prefix "piqi_type_"
.option [ .name int ]
.option [ .name float ]
.option [ .name bool ]
.option [ .name string ]
.option [ .name binary ]
.option [ .name any ]
]
.alias [
.name type
.type name
]
.record [
.name record
.field [ .type name ]
.field [
.type field
.repeated
]
]
.record [
.name field
.field [
.type name
.optional
]
.field [
.type type
.optional
]
.field [
.name mode
.type field-mode
.optional
.default.required
]
.field [
.name default
.type piqi-any
.optional
]
.field [
% experimental: indication that the field has been deprecated; which
% means that it may not be supported any more and use of such field is
% discouraged
.name deprecated
.optional
]
]
.enum [
.name field-mode
.option [ .name required ]
.option [ .name optional ]
.option [ .name repeated ]
]
.record [
.name variant
.field [ .type name ]
.field [
.type option
.repeated % > 1
]
]
.record [
.name option
% NOTE: either name or type have to be present
.field [
.type name
.optional
]
.field [
.type type
.optional
]
.field [
% experimental: indication that the option has been deprecated; which
% means that it may not be supported any more and use of such field is
% discouraged
.name deprecated
.optional
]
]
.record [
.name enum
.field [ .type name ]
% note that enum options shouldn't specify type and must specify name
.field [
.type option
.repeated % > 1
]
.protobuf-name "piqi_enum"
]
.record [
.name alias
.field [ .type name ]
% either type or piqi-type fields must be present; we don't use variant here
% in order to simplify external representation which is going to be flat in
% such case, as opposed to nested if we used variant
.field [
.type type
.optional
]
.field [
.type piqi-type
.optional
]
]
.record [
.name list
.field [ .type name ]
.field [ .type type ]
]
.record [
.name piqi
.field [
.name module
.type word
.optional
]
.field [ .type typedef .repeated ]
.field [ .type import .repeated ]
.field [ .type function .repeated ]
.field [
.name custom-field
.type word
.repeated
]
]
.record [
% import <module> as <name>
.name import
.field [
.name module
.type word
]
.field [
.type name
.optional
]
]
% representation of the built-in "piqi-any" type
.record [
.name any
.field [
% type could be optional or not fully resolved at all times
.name type
.type string
.optional
]
.field [
% arbitrary values corresponding to the type serialized in Protocol
% Buffers format; when one of "type" or "protobuf" field is present, the
% other must be present as well
.name protobuf
.type binary
.optional
]
.field [
% arbitrary JSON value serialized in as utf-8 string; when "type" field
% is present, the JSON value must correspond to this type
.name json
.type string
.optional
]
.field [
% arbitrary XML value serialized in as utf-8 string; when "type" field
% is present, the JSON value must correspond to this type
.name xml
.type string
.optional
]
]
.record [
.name function
.field [ .type name ]
.field [
.name input
.type type
.optional
]
.field [
.name output
.type type
.optional
]
.field [
.name error
.type type
.optional
]
]
.record [
% Standard portable representation of several piqi modules bundeled
% together. This data structure is used by "piqi compile", "piqi server" and
% other parts.
%
% The fact it is called piqi-list while being a record could be somewhat
% confusing. However, doing it this way allows to get nicer JSON and XML
% "visual" representation. It is still Protobuf-binary-compatible with
% .list [ .type piqi ] definition.
.name piqi-list
.field [
% imported modules come before the module they were imported from
.type piqi
.repeated
.code 1
]
]
%
% standard extensions natively supported by Piqi
%
.include [ .module piqi.piq ]
.include [ .module piqi.protobuf ]
.include [ .module piqi.json ]
.include [ .module piqi.getopt ]
.include [ .module piqi.piqic ]
include piqi.piq
include piqi.protobuf
include piqi.json
include piqi.getopt
include piqi.piqic
type bool = .bool
type string = .string
type binary = .binary
type piqi-any = .piqi-any
type int = .int
type uint = .int
type int32 = .int
type uint32 = .int
type int64 = .int
type uint64 = .int
type float64 = .float
type float32 = .float
type int32-fixed = int32()
type uint32-fixed = uint32()
type int64-fixed = int64()
type uint64-fixed = uint64()
type float = float64()
type word = string()
type name = word()
type typedef =
| record()
| variant()
| enum()
| alias()
| list()
type piqi-type =
| int
| float
| bool
| string
| binary
| any
type type = name()
type record =
{
- name()
* field()
}
type field =
{
? name()
? type()
? mode :: field-mode() = .required
? default :: piqi-any()
? deprecated
}
type field-mode =
| required
| optional
| repeated
type variant =
{
- name()
* option()
}
type option =
{
? name()
? type()
? deprecated
}
type enum =
{
- name()
* option()
}
type alias =
{
- name()
? type()
? piqi-type()
}
type list =
{
- name()
- type()
}
type piqi =
{
? module :: word()
* typedef()
* import()
* function()
* custom-field :: word()
}
type import =
{
- module :: word()
? name()
}
type any =
{
? type :: string()
? protobuf :: binary()
? json :: string()
? xml :: string()
}
type function =
{
- name()
? input :: type()
? output :: type()
? error :: type()
}
type piqi-list =
{
* piqi()
}
.alias [
.name bool
.piqi-type.bool
]
.alias [
.name string
.piqi-type.string
]
.alias [
.name binary
.piqi-type.binary
]
.alias [
.name piqi-any
.piqi-type.any
]
.alias [
.name int
.piqi-type.int
.protobuf-type "sint32"
.protobuf-wire-type.zigzag-varint
]
.alias [
.name uint
.piqi-type.int
.protobuf-type "uint32"
.protobuf-wire-type.varint
]
.alias [
.name int32
.piqi-type.int
.protobuf-type "sint32"
.protobuf-wire-type.zigzag-varint
]
.alias [
.name uint32
.piqi-type.int
.protobuf-type "uint32"
.protobuf-wire-type.varint
]
.alias [
.name int64
.piqi-type.int
.protobuf-type "sint64"
.protobuf-wire-type.zigzag-varint
]
.alias [
.name uint64
.piqi-type.int
.protobuf-type "uint64"
.protobuf-wire-type.varint
]
.alias [
.name float64
.piqi-type.float
.protobuf-type "double"
.protobuf-wire-type.fixed64
]
.alias [
.name float32
.piqi-type.float
.protobuf-type "float"
.protobuf-wire-type.fixed32
]
.alias [
.name int32-fixed
.type int32
.piqi-type.int
.protobuf-type "sfixed32"
.protobuf-wire-type.signed-fixed32
]
.alias [
.name uint32-fixed
.type uint32
.piqi-type.int
.protobuf-type "fixed32"
.protobuf-wire-type.fixed32
]
.alias [
.name int64-fixed
.type int64
.piqi-type.int
.protobuf-type "sfixed64"
.protobuf-wire-type.signed-fixed64
]
.alias [
.name uint64-fixed
.type uint64
.piqi-type.int
.protobuf-type "fixed64"
.protobuf-wire-type.fixed64
]
.alias [
.name float
.type float64
.piqi-type.float
]
.alias [
.name word
.type string
.piq-format.word
]
.alias [
.name name
.type word
]
.variant [
.name typedef
.option [ .type record ]
.option [ .type variant ]
.option [ .type enum ]
.option [ .type alias ]
.option [ .type list ]
.protobuf-name "piqi_typedef"
]
.enum [
.name piqi-type
.option [ .name int ]
.option [ .name float ]
.option [ .name bool ]
.option [ .name string ]
.option [ .name binary ]
.option [ .name any ]
.protobuf-prefix "piqi_type_"
]
.alias [
.name type
.type name
]
.record [
.name record
.field [ .type name ]
.field [
.type field
.repeated
]
.field [
.name piq-positional
.type bool
.optional
]
.field [
.name protobuf-name
.type string
.optional
]
.field [
.name protobuf-custom
.type string
.repeated
]
.field [
.name json-name
.type string
.optional
]
]
.record [
.name field
.field [
.type name
.optional
]
.field [
.type type
.optional
]
.field [
.name mode
.type field-mode
.optional
.default.required
]
.field [
.name default
.type piqi-any
.optional
]
.field [
.name deprecated
.optional
]
.field [
.type piq-format
.optional
]
.field [
.name piq-positional
.type bool
.optional
]
.field [
.name piq-alias
.type name
.optional
]
.field [
.name protobuf-name
.type string
.optional
]
.field [
.name code
.type int32
.optional
]
.field [
.name protobuf-packed
.optional
]
.field [
.name json-name
.type string
.optional
]
.field [
.name json-omit-missing
.type bool
.optional
]
.field [
.name getopt-letter
.type word
.optional
]
.field [
.name getopt-doc
.type string
.optional
]
]
.enum [
.name field-mode
.option [ .name required ]
.option [ .name optional ]
.option [ .name repeated ]
]
.record [
.name variant
.field [ .type name ]
.field [
.type option
.repeated
]
.field [
.name protobuf-name
.type string
.optional
]
.field [
.name protobuf-custom
.type string
.repeated
]
.field [
.name json-name
.type string
.optional
]
]
.record [
.name option
.field [
.type name
.optional
]
.field [
.type type
.optional
]
.field [
.name deprecated
.optional
]
.field [
.type piq-format
.optional
]
.field [
.name piq-alias
.type name
.optional
]
.field [
.name protobuf-name
.type string
.optional
]
.field [
.name code
.type int32
.optional
]
.field [
.name json-name
.type string
.optional
]
.field [
.name getopt-letter
.type word
.optional
]
.field [
.name getopt-doc
.type string
.optional
]
]
.record [
.name enum
.field [ .type name ]
.field [
.type option
.repeated
]
.field [
.name protobuf-name
.type string
.optional
]
.field [
.name protobuf-custom
.type string
.repeated
]
.field [
.name protobuf-prefix
.type string
.optional
]
.field [
.name json-name
.type string
.optional
]
.protobuf-name "piqi_enum"
]
.record [
.name alias
.field [ .type name ]
.field [
.type type
.optional
]
.field [
.type piqi-type
.optional
]
.field [
.type piq-format
.optional
]
.field [
.name protobuf-name
.type string
.optional
]
.field [
.name protobuf-type
.type string
.optional
]
.field [
.type protobuf-wire-type
.optional
]
.field [
.name json-name
.type string
.optional
]
]
.record [
.name list
.field [ .type name ]
.field [ .type type ]
.field [
.type piq-format
.optional
]
.field [
.name protobuf-name
.type string
.optional
]
.field [
.name protobuf-custom
.type string
.repeated
]
.field [
.name protobuf-packed
.optional
]
.field [
.name json-name
.type string
.optional
]
]
.record [
.name piqi
.field [
.name module
.type word
.optional
]
.field [
.type typedef
.repeated
]
.field [
.type import
.repeated
]
.field [
.type function
.repeated
]
.field [
.name custom-field
.type word
.repeated
]
.field [
.name protobuf-custom
.type string
.repeated
]
.field [
.name protobuf-package
.type string
.optional
]
.field [
.name file
.type string
.optional
]
]
.record [
.name import
.field [
.name module
.type word
]
.field [
.type name
.optional
]
]
.record [
.name any
.field [
.name type
.type string
.optional
]
.field [
.name protobuf
.type binary
.optional
]
.field [
.name json
.type string
.optional
]
.field [
.name xml
.type string
.optional
]
]
.record [
.name function
.field [ .type name ]
.field [
.name input
.type type
.optional
]
.field [
.name output
.type type
.optional
]
.field [
.name error
.type type
.optional
]
]
.record [
.name piqi-list
.field [
.type piqi
.repeated
.code 1
]
]
.variant [
.name piq-format
.option [ .name word ]
.option [ .name text ]
]
.alias [
.name protobuf-int32
.type int32
.piqi-type.int
.protobuf-type "int32"
.protobuf-wire-type.signed-varint
]
.alias [
.name protobuf-int64
.type int64
.piqi-type.int
.protobuf-type "int64"
.protobuf-wire-type.signed-varint
]
.enum [
.name protobuf-wire-type
.option [ .name varint ]
.option [ .name zigzag-varint ]
.option [ .name fixed32 ]
.option [ .name fixed64 ]
.option [ .name signed-varint ]
.option [ .name signed-fixed32 ]
.option [ .name signed-fixed64 ]
.option [ .name block ]
]
type bool = .bool
type string = .string
type binary = .binary
type piqi-any = .piqi-any
type int = .int
type uint = .int
type int32 = .int
type uint32 = .int
type int64 = .int
type uint64 = .int
type float64 = .float
type float32 = .float
type int32-fixed = int32()
type uint32-fixed = uint32()
type int64-fixed = int64()
type uint64-fixed = uint64()
type float = float64()
type word = string()
type name = word()
type typedef =
| record()
| variant()
| enum()
| alias()
| list()
type piqi-type =
| int
| float
| bool
| string
| binary
| any
type type = name()
type record =
{
- name()
* field()
? piq-positional :: bool()
? protobuf-name :: string()
* protobuf-custom :: string()
? json-name :: string()
}
type field =
{
? name()
? type()
? mode :: field-mode() = .required
? default :: piqi-any()
? deprecated
? piq-format()
? piq-positional :: bool()
? piq-alias :: name()
? protobuf-name :: string()
? code :: int32()
? protobuf-packed
? json-name :: string()
? json-omit-missing :: bool()
? getopt-letter :: word()
? getopt-doc :: string()
}
type field-mode =
| required
| optional
| repeated
type variant =
{
- name()
* option()
? protobuf-name :: string()
* protobuf-custom :: string()
? json-name :: string()
}
type option =
{
? name()
? type()
? deprecated
? piq-format()
? piq-alias :: name()
? protobuf-name :: string()
? code :: int32()
? json-name :: string()
? getopt-letter :: word()
? getopt-doc :: string()
}
type enum =
{
- name()
* option()
? protobuf-name :: string()
* protobuf-custom :: string()
? protobuf-prefix :: string()
? json-name :: string()
}
type alias =
{
- name()
? type()
? piqi-type()
? piq-format()
? protobuf-name :: string()
? protobuf-type :: string()
? protobuf-wire-type()
? json-name :: string()
}
type list =
{
- name()
- type()
? piq-format()
? protobuf-name :: string()
* protobuf-custom :: string()
? protobuf-packed
? json-name :: string()
}
type piqi =
{
? module :: word()
* typedef()
* import()
* function()
* custom-field :: word()
* protobuf-custom :: string()
? protobuf-package :: string()
? file :: string()
}
type import =
{
- module :: word()
? name()
}
type any =
{
? type :: string()
? protobuf :: binary()
? json :: string()
? xml :: string()
}
type function =
{
- name()
? input :: type()
? output :: type()
? error :: type()
}
type piqi-list =
{
* piqi()
}
type piq-format =
| word
| text
type protobuf-int32 = int32()
type protobuf-int64 = int64()
type protobuf-wire-type =
| varint
| zigzag-varint
| fixed32
| fixed64
| signed-varint
| signed-fixed32
| signed-fixed64
| block
package piqi_org.piqi;
message piqi_typedef {
optional record record = 502036113;
optional variant variant = 484589701;
optional piqi_enum piqi_enum = 51800833;
optional alias alias = 26300816;
optional list list = 129178718;
}
enum piqi_type {
piqi_type_int = 5246191;
piqi_type_float = 43435420;
piqi_type_bool = 18580522;
piqi_type_string = 288368849;
piqi_type_binary = 218872833;
piqi_type_any = 4848364;
}
message record {
required string name = 150958667;
repeated field field = 9671866;
optional bool piq_positional = 197354217;
optional string protobuf_name = 90072013;
repeated string protobuf_custom = 112352691;
optional string json_name = 515275216;
}
message field {
optional string name = 150958667;
optional string type = 218690234;
optional field_mode mode = 140563299 [default = required];
optional any default = 465819841;
optional bool deprecated = 69402483;
optional piq_format piq_format = 296833484;
optional bool piq_positional = 197354217;
optional string piq_alias = 434682011;
optional string protobuf_name = 90072013;
optional sint32 code = 29667629;
optional bool protobuf_packed = 179842426;
optional string json_name = 515275216;
optional bool json_omit_missing = 201807079;
optional string getopt_letter = 215188758;
optional string getopt_doc = 442330184;
}
enum field_mode {
required = 308449631;
optional = 510570400;
repeated = 274054266;
}
message variant {
required string name = 150958667;
repeated option option = 192598901;
optional string protobuf_name = 90072013;
repeated string protobuf_custom = 112352691;
optional string json_name = 515275216;
}
message option {
optional string name = 150958667;
optional string type = 218690234;
optional bool deprecated = 69402483;
optional piq_format piq_format = 296833484;
optional string piq_alias = 434682011;
optional string protobuf_name = 90072013;
optional sint32 code = 29667629;
optional string json_name = 515275216;
optional string getopt_letter = 215188758;
optional string getopt_doc = 442330184;
}
message piqi_enum {
required string name = 150958667;
repeated option option = 192598901;
optional string protobuf_name = 90072013;
repeated string protobuf_custom = 112352691;
optional string protobuf_prefix = 366391188;
optional string json_name = 515275216;
}
message alias {
required string name = 150958667;
optional string type = 218690234;
optional piqi_type piqi_type = 198318774;
optional piq_format piq_format = 296833484;
optional string protobuf_name = 90072013;
optional string protobuf_type = 157803580;
optional protobuf_wire_type protobuf_wire_type = 198202944;
optional string json_name = 515275216;
}
message list {
required string name = 150958667;
required string type = 218690234;
optional piq_format piq_format = 296833484;
optional string protobuf_name = 90072013;
repeated string protobuf_custom = 112352691;
optional bool protobuf_packed = 179842426;
optional string json_name = 515275216;
}
message piqi {
optional string module = 13841580;
repeated piqi_typedef piqi_typedef = 416823115;
repeated import import = 142778725;
repeated function function = 340962072;
repeated string custom_field = 162247646;
repeated string protobuf_custom = 112352691;
optional string protobuf_package = 376215364;
optional string file = 62639740;
}
message import {
required string module = 13841580;
optional string name = 150958667;
}
message any {
optional string type = 218690234;
optional bytes protobuf = 6461771;
optional string json = 107495976;
optional string xml = 5991895;
}
message function {
required string name = 150958667;
optional string input = 505267210;
optional string output = 209784577;
optional string error = 321506248;
}
message piqi_list {
repeated piqi piqi = 1;
}
message piq_format {
optional bool word = 251462090;
optional bool text = 217697453;
}
enum protobuf_wire_type {
varint = 329594984;
zigzag_varint = 99211597;
fixed32 = 136997651;
fixed64 = 136998322;
signed_varint = 441915897;
signed_fixed32 = 488499298;
signed_fixed64 = 488499969;
block = 352089421;
}
{
"piqi_type": "piqi",
"module": "piqi",
"typedef": [
{ "alias": { "name": "bool", "piqi_type": "bool" } },
{ "alias": { "name": "string", "piqi_type": "string" } },
{ "alias": { "name": "binary", "piqi_type": "binary" } },
{ "alias": { "name": "piqi-any", "piqi_type": "any" } },
{
"alias": {
"name": "int",
"piqi_type": "int",
"protobuf_type": "sint32",
"protobuf_wire_type": "zigzag_varint"
}
},
{
"alias": {
"name": "uint",
"piqi_type": "int",
"protobuf_type": "uint32",
"protobuf_wire_type": "varint"
}
},
{
"alias": {
"name": "int32",
"piqi_type": "int",
"protobuf_type": "sint32",
"protobuf_wire_type": "zigzag_varint"
}
},
{
"alias": {
"name": "uint32",
"piqi_type": "int",
"protobuf_type": "uint32",
"protobuf_wire_type": "varint"
}
},
{
"alias": {
"name": "int64",
"piqi_type": "int",
"protobuf_type": "sint64",
"protobuf_wire_type": "zigzag_varint"
}
},
{
"alias": {
"name": "uint64",
"piqi_type": "int",
"protobuf_type": "uint64",
"protobuf_wire_type": "varint"
}
},
{
"alias": {
"name": "float64",
"piqi_type": "float",
"protobuf_type": "double",
"protobuf_wire_type": "fixed64"
}
},
{
"alias": {
"name": "float32",
"piqi_type": "float",
"protobuf_type": "float",
"protobuf_wire_type": "fixed32"
}
},
{
"alias": {
"name": "int32-fixed",
"type": "int32",
"piqi_type": "int",
"protobuf_type": "sfixed32",
"protobuf_wire_type": "signed_fixed32"
}
},
{
"alias": {
"name": "uint32-fixed",
"type": "uint32",
"piqi_type": "int",
"protobuf_type": "fixed32",
"protobuf_wire_type": "fixed32"
}
},
{
"alias": {
"name": "int64-fixed",
"type": "int64",
"piqi_type": "int",
"protobuf_type": "sfixed64",
"protobuf_wire_type": "signed_fixed64"
}
},
{
"alias": {
"name": "uint64-fixed",
"type": "uint64",
"piqi_type": "int",
"protobuf_type": "fixed64",
"protobuf_wire_type": "fixed64"
}
},
{ "alias": { "name": "float", "type": "float64", "piqi_type": "float" } },
{
"alias": {
"name": "word",
"type": "string",
"piq_format": { "word": true }
}
},
{ "alias": { "name": "name", "type": "word" } },
{
"variant": {
"name": "typedef",
"option": [
{ "type": "record", "code": 502036113 },
{ "type": "variant", "code": 484589701 },
{ "type": "enum", "code": 51800833 },
{ "type": "alias", "code": 26300816 },
{ "type": "list", "code": 129178718 }
],
"protobuf_name": "piqi_typedef"
}
},
{
"enum": {
"name": "piqi-type",
"option": [
{ "name": "int", "code": 5246191 },
{ "name": "float", "code": 43435420 },
{ "name": "bool", "code": 18580522 },
{ "name": "string", "code": 288368849 },
{ "name": "binary", "code": 218872833 },
{ "name": "any", "code": 4848364 }
],
"protobuf_prefix": "piqi_type_"
}
},
{ "alias": { "name": "type", "type": "name" } },
{
"record": {
"name": "record",
"field": [
{ "type": "name", "mode": "required", "code": 150958667 },
{ "type": "field", "mode": "repeated", "code": 9671866 },
{
"name": "piq-positional",
"type": "bool",
"mode": "optional",
"code": 197354217
},
{
"name": "protobuf-name",
"type": "string",
"mode": "optional",
"code": 90072013
},
{
"name": "protobuf-custom",
"type": "string",
"mode": "repeated",
"code": 112352691
},
{
"name": "json-name",
"type": "string",
"mode": "optional",
"code": 515275216
}
]
}
},
{
"record": {
"name": "field",
"field": [
{ "type": "name", "mode": "optional", "code": 150958667 },
{ "type": "type", "mode": "optional", "code": 218690234 },
{
"name": "mode",
"type": "field-mode",
"mode": "optional",
"default": "required",
"code": 140563299
},
{
"name": "default",
"type": "piqi-any",
"mode": "optional",
"code": 465819841
},
{ "name": "deprecated", "mode": "optional", "code": 69402483 },
{ "type": "piq-format", "mode": "optional", "code": 296833484 },
{
"name": "piq-positional",
"type": "bool",
"mode": "optional",
"code": 197354217
},
{
"name": "piq-alias",
"type": "name",
"mode": "optional",
"code": 434682011
},
{
"name": "protobuf-name",
"type": "string",
"mode": "optional",
"code": 90072013
},
{
"name": "code",
"type": "int32",
"mode": "optional",
"code": 29667629
},
{
"name": "protobuf-packed",
"mode": "optional",
"code": 179842426
},
{
"name": "json-name",
"type": "string",
"mode": "optional",
"code": 515275216
},
{
"name": "json-omit-missing",
"type": "bool",
"mode": "optional",
"code": 201807079
},
{
"name": "getopt-letter",
"type": "word",
"mode": "optional",
"code": 215188758
},
{
"name": "getopt-doc",
"type": "string",
"mode": "optional",
"code": 442330184
}
]
}
},
{
"enum": {
"name": "field-mode",
"option": [
{ "name": "required", "code": 308449631 },
{ "name": "optional", "code": 510570400 },
{ "name": "repeated", "code": 274054266 }
]
}
},
{
"record": {
"name": "variant",
"field": [
{ "type": "name", "mode": "required", "code": 150958667 },
{ "type": "option", "mode": "repeated", "code": 192598901 },
{
"name": "protobuf-name",
"type": "string",
"mode": "optional",
"code": 90072013
},
{
"name": "protobuf-custom",
"type": "string",
"mode": "repeated",
"code": 112352691
},
{
"name": "json-name",
"type": "string",
"mode": "optional",
"code": 515275216
}
]
}
},
{
"record": {
"name": "option",
"field": [
{ "type": "name", "mode": "optional", "code": 150958667 },
{ "type": "type", "mode": "optional", "code": 218690234 },
{ "name": "deprecated", "mode": "optional", "code": 69402483 },
{ "type": "piq-format", "mode": "optional", "code": 296833484 },
{
"name": "piq-alias",
"type": "name",
"mode": "optional",
"code": 434682011
},
{
"name": "protobuf-name",
"type": "string",
"mode": "optional",
"code": 90072013
},
{
"name": "code",
"type": "int32",
"mode": "optional",
"code": 29667629
},
{
"name": "json-name",
"type": "string",
"mode": "optional",
"code": 515275216
},
{
"name": "getopt-letter",
"type": "word",
"mode": "optional",
"code": 215188758
},
{
"name": "getopt-doc",
"type": "string",
"mode": "optional",
"code": 442330184
}
]
}
},
{
"record": {
"name": "enum",
"field": [
{ "type": "name", "mode": "required", "code": 150958667 },
{ "type": "option", "mode": "repeated", "code": 192598901 },
{
"name": "protobuf-name",
"type": "string",
"mode": "optional",
"code": 90072013
},
{
"name": "protobuf-custom",
"type": "string",
"mode": "repeated",
"code": 112352691
},
{
"name": "protobuf-prefix",
"type": "string",
"mode": "optional",
"code": 366391188
},
{
"name": "json-name",
"type": "string",
"mode": "optional",
"code": 515275216
}
],
"protobuf_name": "piqi_enum"
}
},
{
"record": {
"name": "alias",
"field": [
{ "type": "name", "mode": "required", "code": 150958667 },
{ "type": "type", "mode": "optional", "code": 218690234 },
{ "type": "piqi-type", "mode": "optional", "code": 198318774 },
{ "type": "piq-format", "mode": "optional", "code": 296833484 },
{
"name": "protobuf-name",
"type": "string",
"mode": "optional",
"code": 90072013
},
{
"name": "protobuf-type",
"type": "string",
"mode": "optional",
"code": 157803580
},
{
"type": "protobuf-wire-type",
"mode": "optional",
"code": 198202944
},
{
"name": "json-name",
"type": "string",
"mode": "optional",
"code": 515275216
}
]
}
},
{
"record": {
"name": "list",
"field": [
{ "type": "name", "mode": "required", "code": 150958667 },
{ "type": "type", "mode": "required", "code": 218690234 },
{ "type": "piq-format", "mode": "optional", "code": 296833484 },
{
"name": "protobuf-name",
"type": "string",
"mode": "optional",
"code": 90072013
},
{
"name": "protobuf-custom",
"type": "string",
"mode": "repeated",
"code": 112352691
},
{
"name": "protobuf-packed",
"mode": "optional",
"code": 179842426
},
{
"name": "json-name",
"type": "string",
"mode": "optional",
"code": 515275216
}
]
}
},
{
"record": {
"name": "piqi",
"field": [
{
"name": "module",
"type": "word",
"mode": "optional",
"code": 13841580
},
{ "type": "typedef", "mode": "repeated", "code": 416823115 },
{ "type": "import", "mode": "repeated", "code": 142778725 },
{ "type": "function", "mode": "repeated", "code": 340962072 },
{
"name": "custom-field",
"type": "word",
"mode": "repeated",
"code": 162247646
},
{
"name": "protobuf-custom",
"type": "string",
"mode": "repeated",
"code": 112352691
},
{
"name": "protobuf-package",
"type": "string",
"mode": "optional",
"code": 376215364
},
{
"name": "file",
"type": "string",
"mode": "optional",
"code": 62639740
}
]
}
},
{
"record": {
"name": "import",
"field": [
{
"name": "module",
"type": "word",
"mode": "required",
"code": 13841580
},
{ "type": "name", "mode": "optional", "code": 150958667 }
]
}
},
{
"record": {
"name": "any",
"field": [
{
"name": "type",
"type": "string",
"mode": "optional",
"code": 218690234
},
{
"name": "protobuf",
"type": "binary",
"mode": "optional",
"code": 6461771
},
{
"name": "json",
"type": "string",
"mode": "optional",
"code": 107495976
},
{
"name": "xml",
"type": "string",
"mode": "optional",
"code": 5991895
}
]
}
},
{
"record": {
"name": "function",
"field": [
{ "type": "name", "mode": "required", "code": 150958667 },
{
"name": "input",
"type": "type",
"mode": "optional",
"code": 505267210
},
{
"name": "output",
"type": "type",
"mode": "optional",
"code": 209784577
},
{
"name": "error",
"type": "type",
"mode": "optional",
"code": 321506248
}
]
}
},
{
"record": {
"name": "piqi-list",
"field": [ { "type": "piqi", "mode": "repeated", "code": 1 } ]
}
},
{
"variant": {
"name": "piq-format",
"option": [
{ "name": "word", "code": 251462090 },
{ "name": "text", "code": 217697453 }
]
}
},
{
"alias": {
"name": "protobuf-int32",
"type": "int32",
"piqi_type": "int",
"protobuf_type": "int32",
"protobuf_wire_type": "signed_varint"
}
},
{
"alias": {
"name": "protobuf-int64",
"type": "int64",
"piqi_type": "int",
"protobuf_type": "int64",
"protobuf_wire_type": "signed_varint"
}
},
{
"enum": {
"name": "protobuf-wire-type",
"option": [
{ "name": "varint", "code": 329594984 },
{ "name": "zigzag-varint", "code": 99211597 },
{ "name": "fixed32", "code": 136997651 },
{ "name": "fixed64", "code": 136998322 },
{ "name": "signed-varint", "code": 441915897 },
{ "name": "signed-fixed32", "code": 488499298 },
{ "name": "signed-fixed64", "code": 488499969 },
{ "name": "block", "code": 352089421 }
]
}
}
]
}
<?xml version="1.0" encoding="UTF-8"?>
<value>
<module>piqi</module>
<typedef>
<alias>
<name>bool</name>
<piqi-type>bool</piqi-type>
</alias>
</typedef>
<typedef>
<alias>
<name>string</name>
<piqi-type>string</piqi-type>
</alias>
</typedef>
<typedef>
<alias>
<name>binary</name>
<piqi-type>binary</piqi-type>
</alias>
</typedef>
<typedef>
<alias>
<name>piqi-any</name>
<piqi-type>any</piqi-type>
</alias>
</typedef>
<typedef>
<alias>
<name>int</name>
<piqi-type>int</piqi-type>
<protobuf-type>sint32</protobuf-type>
<protobuf-wire-type>zigzag-varint</protobuf-wire-type>
</alias>
</typedef>
<typedef>
<alias>
<name>uint</name>
<piqi-type>int</piqi-type>
<protobuf-type>uint32</protobuf-type>
<protobuf-wire-type>varint</protobuf-wire-type>
</alias>
</typedef>
<typedef>
<alias>
<name>int32</name>
<piqi-type>int</piqi-type>
<protobuf-type>sint32</protobuf-type>
<protobuf-wire-type>zigzag-varint</protobuf-wire-type>
</alias>
</typedef>
<typedef>
<alias>
<name>uint32</name>
<piqi-type>int</piqi-type>
<protobuf-type>uint32</protobuf-type>
<protobuf-wire-type>varint</protobuf-wire-type>
</alias>
</typedef>
<typedef>
<alias>
<name>int64</name>
<piqi-type>int</piqi-type>
<protobuf-type>sint64</protobuf-type>
<protobuf-wire-type>zigzag-varint</protobuf-wire-type>
</alias>
</typedef>
<typedef>
<alias>
<name>uint64</name>
<piqi-type>int</piqi-type>
<protobuf-type>uint64</protobuf-type>
<protobuf-wire-type>varint</protobuf-wire-type>
</alias>
</typedef>
<typedef>
<alias>
<name>float64</name>
<piqi-type>float</piqi-type>
<protobuf-type>double</protobuf-type>
<protobuf-wire-type>fixed64</protobuf-wire-type>
</alias>
</typedef>
<typedef>
<alias>
<name>float32</name>
<piqi-type>float</piqi-type>
<protobuf-type>float</protobuf-type>
<protobuf-wire-type>fixed32</protobuf-wire-type>
</alias>
</typedef>
<typedef>
<alias>
<name>int32-fixed</name>
<type>int32</type>
<piqi-type>int</piqi-type>
<protobuf-type>sfixed32</protobuf-type>
<protobuf-wire-type>signed-fixed32</protobuf-wire-type>
</alias>
</typedef>
<typedef>
<alias>
<name>uint32-fixed</name>
<type>uint32</type>
<piqi-type>int</piqi-type>
<protobuf-type>fixed32</protobuf-type>
<protobuf-wire-type>fixed32</protobuf-wire-type>
</alias>
</typedef>
<typedef>
<alias>
<name>int64-fixed</name>
<type>int64</type>
<piqi-type>int</piqi-type>
<protobuf-type>sfixed64</protobuf-type>
<protobuf-wire-type>signed-fixed64</protobuf-wire-type>
</alias>
</typedef>
<typedef>
<alias>
<name>uint64-fixed</name>
<type>uint64</type>
<piqi-type>int</piqi-type>
<protobuf-type>fixed64</protobuf-type>
<protobuf-wire-type>fixed64</protobuf-wire-type>
</alias>
</typedef>
<typedef>
<alias>
<name>float</name>
<type>float64</type>
<piqi-type>float</piqi-type>
</alias>
</typedef>
<typedef>
<alias>
<name>word</name>
<type>string</type>
<piq-format>
<word/>
</piq-format>
</alias>
</typedef>
<typedef>
<alias>
<name>name</name>
<type>word</type>
</alias>
</typedef>
<typedef>
<variant>
<name>typedef</name>
<option>
<type>record</type>
<code>502036113</code>
</option>
<option>
<type>variant</type>
<code>484589701</code>
</option>
<option>
<type>enum</type>
<code>51800833</code>
</option>
<option>
<type>alias</type>
<code>26300816</code>
</option>
<option>
<type>list</type>
<code>129178718</code>
</option>
<protobuf-name>piqi_typedef</protobuf-name>
</variant>
</typedef>
<typedef>
<enum>
<name>piqi-type</name>
<option>
<name>int</name>
<code>5246191</code>
</option>
<option>
<name>float</name>
<code>43435420</code>
</option>
<option>
<name>bool</name>
<code>18580522</code>
</option>
<option>
<name>string</name>
<code>288368849</code>
</option>
<option>
<name>binary</name>
<code>218872833</code>
</option>
<option>
<name>any</name>
<code>4848364</code>
</option>
<protobuf-prefix>piqi_type_</protobuf-prefix>
</enum>
</typedef>
<typedef>
<alias>
<name>type</name>
<type>name</type>
</alias>
</typedef>
<typedef>
<record>
<name>record</name>
<field>
<type>name</type>
<mode>required</mode>
<code>150958667</code>
</field>
<field>
<type>field</type>
<mode>repeated</mode>
<code>9671866</code>
</field>
<field>
<name>piq-positional</name>
<type>bool</type>
<mode>optional</mode>
<code>197354217</code>
</field>
<field>
<name>protobuf-name</name>
<type>string</type>
<mode>optional</mode>
<code>90072013</code>
</field>
<field>
<name>protobuf-custom</name>
<type>string</type>
<mode>repeated</mode>
<code>112352691</code>
</field>
<field>
<name>json-name</name>
<type>string</type>
<mode>optional</mode>
<code>515275216</code>
</field>
</record>
</typedef>
<typedef>
<record>
<name>field</name>
<field>
<type>name</type>
<mode>optional</mode>
<code>150958667</code>
</field>
<field>
<type>type</type>
<mode>optional</mode>
<code>218690234</code>
</field>
<field>
<name>mode</name>
<type>field-mode</type>
<mode>optional</mode>
<default>required</default>
<code>140563299</code>
</field>
<field>
<name>default</name>
<type>piqi-any</type>
<mode>optional</mode>
<code>465819841</code>
</field>
<field>
<name>deprecated</name>
<mode>optional</mode>
<code>69402483</code>
</field>
<field>
<type>piq-format</type>
<mode>optional</mode>
<code>296833484</code>
</field>
<field>
<name>piq-positional</name>
<type>bool</type>
<mode>optional</mode>
<code>197354217</code>
</field>
<field>
<name>piq-alias</name>
<type>name</type>
<mode>optional</mode>
<code>434682011</code>
</field>
<field>
<name>protobuf-name</name>
<type>string</type>
<mode>optional</mode>
<code>90072013</code>
</field>
<field>
<name>code</name>
<type>int32</type>
<mode>optional</mode>
<code>29667629</code>
</field>
<field>
<name>protobuf-packed</name>
<mode>optional</mode>
<code>179842426</code>
</field>
<field>
<name>json-name</name>
<type>string</type>
<mode>optional</mode>
<code>515275216</code>
</field>
<field>
<name>json-omit-missing</name>
<type>bool</type>
<mode>optional</mode>
<code>201807079</code>
</field>
<field>
<name>getopt-letter</name>
<type>word</type>
<mode>optional</mode>
<code>215188758</code>
</field>
<field>
<name>getopt-doc</name>
<type>string</type>
<mode>optional</mode>
<code>442330184</code>
</field>
</record>
</typedef>
<typedef>
<enum>
<name>field-mode</name>
<option>
<name>required</name>
<code>308449631</code>
</option>
<option>
<name>optional</name>
<code>510570400</code>
</option>
<option>
<name>repeated</name>
<code>274054266</code>
</option>
</enum>
</typedef>
<typedef>
<record>
<name>variant</name>
<field>
<type>name</type>
<mode>required</mode>
<code>150958667</code>
</field>
<field>
<type>option</type>
<mode>repeated</mode>
<code>192598901</code>
</field>
<field>
<name>protobuf-name</name>
<type>string</type>
<mode>optional</mode>
<code>90072013</code>
</field>
<field>
<name>protobuf-custom</name>
<type>string</type>
<mode>repeated</mode>
<code>112352691</code>
</field>
<field>
<name>json-name</name>
<type>string</type>
<mode>optional</mode>
<code>515275216</code>
</field>
</record>
</typedef>
<typedef>
<record>
<name>option</name>
<field>
<type>name</type>
<mode>optional</mode>
<code>150958667</code>
</field>
<field>
<type>type</type>
<mode>optional</mode>
<code>218690234</code>
</field>
<field>
<name>deprecated</name>
<mode>optional</mode>
<code>69402483</code>
</field>
<field>
<type>piq-format</type>
<mode>optional</mode>
<code>296833484</code>
</field>
<field>
<name>piq-alias</name>
<type>name</type>
<mode>optional</mode>
<code>434682011</code>
</field>
<field>
<name>protobuf-name</name>
<type>string</type>
<mode>optional</mode>
<code>90072013</code>
</field>
<field>
<name>code</name>
<type>int32</type>
<mode>optional</mode>
<code>29667629</code>
</field>
<field>
<name>json-name</name>
<type>string</type>
<mode>optional</mode>
<code>515275216</code>
</field>
<field>
<name>getopt-letter</name>
<type>word</type>
<mode>optional</mode>
<code>215188758</code>
</field>
<field>
<name>getopt-doc</name>
<type>string</type>
<mode>optional</mode>
<code>442330184</code>
</field>
</record>
</typedef>
<typedef>
<record>
<name>enum</name>
<field>
<type>name</type>
<mode>required</mode>
<code>150958667</code>
</field>
<field>
<type>option</type>
<mode>repeated</mode>
<code>192598901</code>
</field>
<field>
<name>protobuf-name</name>
<type>string</type>
<mode>optional</mode>
<code>90072013</code>
</field>
<field>
<name>protobuf-custom</name>
<type>string</type>
<mode>repeated</mode>
<code>112352691</code>
</field>
<field>
<name>protobuf-prefix</name>
<type>string</type>
<mode>optional</mode>
<code>366391188</code>
</field>
<field>
<name>json-name</name>
<type>string</type>
<mode>optional</mode>
<code>515275216</code>
</field>
<protobuf-name>piqi_enum</protobuf-name>
</record>
</typedef>
<typedef>
<record>
<name>alias</name>
<field>
<type>name</type>
<mode>required</mode>
<code>150958667</code>
</field>
<field>
<type>type</type>
<mode>optional</mode>
<code>218690234</code>
</field>
<field>
<type>piqi-type</type>
<mode>optional</mode>
<code>198318774</code>
</field>
<field>
<type>piq-format</type>
<mode>optional</mode>
<code>296833484</code>
</field>
<field>
<name>protobuf-name</name>
<type>string</type>
<mode>optional</mode>
<code>90072013</code>
</field>
<field>
<name>protobuf-type</name>
<type>string</type>
<mode>optional</mode>
<code>157803580</code>
</field>
<field>
<type>protobuf-wire-type</type>
<mode>optional</mode>
<code>198202944</code>
</field>
<field>
<name>json-name</name>
<type>string</type>
<mode>optional</mode>
<code>515275216</code>
</field>
</record>
</typedef>
<typedef>
<record>
<name>list</name>
<field>
<type>name</type>
<mode>required</mode>
<code>150958667</code>
</field>
<field>
<type>type</type>
<mode>required</mode>
<code>218690234</code>
</field>
<field>
<type>piq-format</type>
<mode>optional</mode>
<code>296833484</code>
</field>
<field>
<name>protobuf-name</name>
<type>string</type>
<mode>optional</mode>
<code>90072013</code>
</field>
<field>
<name>protobuf-custom</name>
<type>string</type>
<mode>repeated</mode>
<code>112352691</code>
</field>
<field>
<name>protobuf-packed</name>
<mode>optional</mode>
<code>179842426</code>
</field>
<field>
<name>json-name</name>
<type>string</type>
<mode>optional</mode>
<code>515275216</code>
</field>
</record>
</typedef>
<typedef>
<record>
<name>piqi</name>
<field>
<name>module</name>
<type>word</type>
<mode>optional</mode>
<code>13841580</code>
</field>
<field>
<type>typedef</type>
<mode>repeated</mode>
<code>416823115</code>
</field>
<field>
<type>import</type>
<mode>repeated</mode>
<code>142778725</code>
</field>
<field>
<type>function</type>
<mode>repeated</mode>
<code>340962072</code>
</field>
<field>
<name>custom-field</name>
<type>word</type>
<mode>repeated</mode>
<code>162247646</code>
</field>
<field>
<name>protobuf-custom</name>
<type>string</type>
<mode>repeated</mode>
<code>112352691</code>
</field>
<field>
<name>protobuf-package</name>
<type>string</type>
<mode>optional</mode>
<code>376215364</code>
</field>
<field>
<name>file</name>
<type>string</type>
<mode>optional</mode>
<code>62639740</code>
</field>
</record>
</typedef>
<typedef>
<record>
<name>import</name>
<field>
<name>module</name>
<type>word</type>
<mode>required</mode>
<code>13841580</code>
</field>
<field>
<type>name</type>
<mode>optional</mode>
<code>150958667</code>
</field>
</record>
</typedef>
<typedef>
<record>
<name>any</name>
<field>
<name>type</name>
<type>string</type>
<mode>optional</mode>
<code>218690234</code>
</field>
<field>
<name>protobuf</name>
<type>binary</type>
<mode>optional</mode>
<code>6461771</code>
</field>
<field>
<name>json</name>
<type>string</type>
<mode>optional</mode>
<code>107495976</code>
</field>
<field>
<name>xml</name>
<type>string</type>
<mode>optional</mode>
<code>5991895</code>
</field>
</record>
</typedef>
<typedef>
<record>
<name>function</name>
<field>
<type>name</type>
<mode>required</mode>
<code>150958667</code>
</field>
<field>
<name>input</name>
<type>type</type>
<mode>optional</mode>
<code>505267210</code>
</field>
<field>
<name>output</name>
<type>type</type>
<mode>optional</mode>
<code>209784577</code>
</field>
<field>
<name>error</name>
<type>type</type>
<mode>optional</mode>
<code>321506248</code>
</field>
</record>
</typedef>
<typedef>
<record>
<name>piqi-list</name>
<field>
<type>piqi</type>
<mode>repeated</mode>
<code>1</code>
</field>
</record>
</typedef>
<typedef>
<variant>
<name>piq-format</name>
<option>
<name>word</name>
<code>251462090</code>
</option>
<option>
<name>text</name>
<code>217697453</code>
</option>
</variant>
</typedef>
<typedef>
<alias>
<name>protobuf-int32</name>
<type>int32</type>
<piqi-type>int</piqi-type>
<protobuf-type>int32</protobuf-type>
<protobuf-wire-type>signed-varint</protobuf-wire-type>
</alias>
</typedef>
<typedef>
<alias>
<name>protobuf-int64</name>
<type>int64</type>
<piqi-type>int</piqi-type>
<protobuf-type>int64</protobuf-type>
<protobuf-wire-type>signed-varint</protobuf-wire-type>
</alias>
</typedef>
<typedef>
<enum>
<name>protobuf-wire-type</name>
<option>
<name>varint</name>
<code>329594984</code>
</option>
<option>
<name>zigzag-varint</name>
<code>99211597</code>
</option>
<option>
<name>fixed32</name>
<code>136997651</code>
</option>
<option>
<name>fixed64</name>
<code>136998322</code>
</option>
<option>
<name>signed-varint</name>
<code>441915897</code>
</option>
<option>
<name>signed-fixed32</name>
<code>488499298</code>
</option>
<option>
<name>signed-fixed64</name>
<code>488499969</code>
</option>
<option>
<name>block</name>
<code>352089421</code>
</option>
</enum>
</typedef>
</value>
Parts of the Piqi self-definition
% Piq-specific extensions for Piqi self-spec
%
% This file defines some extensions to the base Piqi specification enabling
% properties specific to the Piq data representation format
%
% Copyright 2009, 2010, 2011, 2012, 2013 Anton Lavrik
.include [ .module piqi ]
.extend [
(.typedef alias list field option)
.with.field [
.type piq-format
.optional
]
]
.extend [
(.typedef field record)
.with.field [
% allows to control explicitly whether to accept a field if it is specified
% without a label (arguments without a label are called "positional")
%
% the default behavior is to allow fields of primitive types to be
% positional but require labels for records and lists
%
% fields inherit record-level setting when present, unless overridden by
% per-field settings
.name piq-positional
.type bool
.optional
]
]
.extend [
(.typedef field option)
.with.field [
% this allows to specify an alternative name a field or an option; used
% only when parsing Piq; Field names specified via .name or derived from
% .type take precedence over names defined using .piq-alias
%
% the ability to use an alternative name is useful when Piq is used as
% as a syntax notation for DSLs
.name piq-alias
.type name
.optional
]
]
% Piq-specific alternative representation format of Piqi types
.variant [
.name piq-format
% representation of string values
.option [
% NOTE: if a string value can not be represented as single unquoted
% word, it will be pepresented as string liternal
.name word
]
.option [
.name text
]
]
include piqi
type piq-format =
| word
| text
extend alias list field option
? piq-format()
extend field record
? piq-positional :: bool()
extend field option
? piq-alias :: name()
% JSON-specific extensions for Piqi self-spec
%
% This file defines some extensions to base Piqi specification enabling fields
% specific to JSON
%
% Copyright 2009, 2010, 2011, 2012, 2013 Anton Lavrik
.include [ .module piqi ]
.extend [
(.typedef record field variant option enum alias list)
.with.field [
.name json-name
.type string
.optional
]
]
.extend [
.typedef field
.with.field [
% whether to omit missing fields from JSON output that would otherwise
% be represented as JSON NULL for missing optional and [] for missing
% repeated fields; if not specified, the default behavior is determined
% by the json_omit_missing_fields run-time setting which is, in turn,
% set to true by default
.name json-omit-missing
.type bool
.optional
]
]
include piqi
extend record field variant option enum alias list
? json-name :: string()
extend field
? json-omit-missing :: bool()
% Google Protocol Buffers extension for Piqi self-spec
%
% This file defines two kinds of extensions to the base Piqi self-specification:
%
% - properties related to Protocol Buffer's .proto files that are used by
% "piqi to-proto" command
%
% - properties related to binary binary Google Protocol Buffers format also
% known as wire format
%
%
% The document describing Protocol Buffers binary "wire" format:
%
% https://developers.google.com/protocol-buffers/docs/encoding
%
%
% Copyright 2009, 2010, 2011, 2012, 2013 Anton Lavrik
.protobuf-package "piqi_org.piqi"
.include [ .module piqi ]
%
% mapping between Piqi primitive and Protobuf types
%
.extend [
.typedef int
.with.protobuf-type "sint32"
.with.protobuf-wire-type.zigzag-varint
]
.extend [
.typedef uint
.with.protobuf-type "uint32"
.with.protobuf-wire-type.varint
]
.extend [
.typedef int32
.with.protobuf-type "sint32"
.with.protobuf-wire-type.zigzag-varint
]
.extend [
.typedef uint32
.with.protobuf-type "uint32"
.with.protobuf-wire-type.varint
]
.extend [
.typedef int64
.with.protobuf-type "sint64"
.with.protobuf-wire-type.zigzag-varint
]
.extend [
.typedef uint64
.with.protobuf-type "uint64"
.with.protobuf-wire-type.varint
]
.extend [
.typedef int32-fixed
.with.protobuf-type "sfixed32"
.with.protobuf-wire-type.signed-fixed32
]
.extend [
.typedef uint32-fixed
.with.protobuf-type "fixed32"
.with.protobuf-wire-type.fixed32
]
.extend [
.typedef int64-fixed
.with.protobuf-type "sfixed64"
.with.protobuf-wire-type.signed-fixed64
]
.extend [
.typedef uint64-fixed
.with.protobuf-type "fixed64"
.with.protobuf-wire-type.fixed64
]
.extend [
.typedef float64
.with.protobuf-type "double"
.with.protobuf-wire-type.fixed64
]
.extend [
.typedef float32
.with.protobuf-type "float"
.with.protobuf-wire-type.fixed32
]
% These two types are specific to Protocol Buffers. They have the same
% on-the-wire representation as uint32/64. The difference is that they allow
% negative integers (which representation is very inefficient requiring many
% bytes for small absolue values).
.alias [
.name protobuf-int32
.type int32
.piqi-type.int
.protobuf-type "int32"
.protobuf-wire-type.signed-varint
]
.alias [
.name protobuf-int64
.type int64
.piqi-type.int
.protobuf-type "int64"
.protobuf-wire-type.signed-varint
]
%
% properties specific to .piqi to .proto conversion
%
.extend [
(.typedef record field variant option enum alias list)
.with.field [
.name protobuf-name
.type string
.optional
]
]
.extend [
(.typedef piqi record variant list enum)
.with.field [
% arbitrary string that will be included in .proto message and enum
% definitions as a result of .piqi -> .proto conversion
.name protobuf-custom
.type string
.repeated
]
]
.extend [
.typedef piqi
.with.field [
.name protobuf-package
.type string
.optional
]
]
.extend [
.typedef alias
.with.field [
.name protobuf-type
.type string
.optional
]
]
.extend [
.typedef enum
.with.field [
% prefix each enum option's name with the specified string; it helps to
% deal with the fact that enum doesn't form a C++ namespace meaning that
% enum constants are defined directly in the outer namespace; it was
% announced that this problem will be fixed in protobuf-2.5
.name protobuf-prefix
.type string
.optional
]
]
%
% definitions and extensions related to how data is represented on the wire
%
.enum [
.name protobuf-wire-type
.option [ varint ]
.option [ zigzag-varint ]
.option [ fixed32 ]
.option [ fixed64 ]
.option [ signed-varint ]
.option [ signed-fixed32 ]
.option [ signed-fixed64 ]
.option [ block ]
]
.extend [
.typedef alias
.with.field [
.type protobuf-wire-type
.optional
]
]
.extend [
(.typedef field option)
.with.field [
% for fields and variant options: unique integer field id
% from (1 -- (2^29-1)) range used for identifying individual fields and
% options encoded in wire format
%
% for enum options: non-unique integer constant from a full int32 range
.name code
.type int32
.optional
]
]
.extend [
(.typedef field list)
% indication that Protobuf "packed" format is used for repeated fields or
% list elements
.with.field [
.name protobuf-packed
.optional
]
]
include piqi
type protobuf-int32 = int32()
type protobuf-int64 = int64()
type protobuf-wire-type =
| varint
| zigzag-varint
| fixed32
| fixed64
| signed-varint
| signed-fixed32
| signed-fixed64
| block
extend record field variant option enum alias list
? protobuf-name :: string()
extend piqi record variant list enum
* protobuf-custom :: string()
extend piqi
? protobuf-package :: string()
extend alias
? protobuf-type :: string()
extend enum
? protobuf-prefix :: string()
extend alias
? protobuf-wire-type()
extend field option
? code :: int32()
extend field list
? protobuf-packed
% Piqi extensions for getopt
%
% This file defines extensions to the base Piqi self-specification for
% command-line arguement parsing.
%
%
% Copyright 2009, 2010, 2011, 2012, 2013 Anton Lavrik
.include [ .module piqi ]
% a single-letter getopt option or flag
.extend [
(.typedef field option)
.with.field [
.name getopt-letter
.type word
.optional
]
.with.field [
.name getopt-doc
.type string
.optional
]
]
include piqi
extend field option
? getopt-letter :: word()
? getopt-doc :: string()
The Piqi language
% Piqi language specification
%
% This file contains specificaiton for the Piqi language which is an extension
% of Piqi-spec (piqi.piqi).
%
% Basically, Piqi-lang = Piqi-spec + includes, extensions and typedefs embeeded
% in function parameters.
%
% Copyright 2009, 2010, 2011, 2012, 2013 Anton Lavrik
.include [ .module piqi ]
% The Piqi language, in addition to the Piqi-spec, has includes and extensions
.extend [
.typedef piqi
.with.field [ .type include .repeated ]
.with.field [ .type extend .repeated ]
]
.record [
.name include
.field [
.name module
.type word
]
]
.extend [
(.field function.input function.output function.error)
.override
.with.type function-param
]
.extend [
(.field record.name variant.name enum.name list.name alias.name)
.override
.with (.mode.optional)
]
.variant [
.name function-param
.option [ .type name ]
.option [
.type record
]
.option [
.type variant
]
.option [
.type enum
]
.option [
.type list
]
.option [
% note: although anonymous alias doesn't make a lot of sense, we need it
% for completeness; there's only one use case: when somebody wants to
% define additional properties inside such alias (e.g. piq-format)
.type alias
]
]
.record [
.name extend
.field [
.name what
.type extend-target
.repeated % several typedefs can be specified as an extension
]
.field [
% whether specified extensions override existing elements
.name override
.optional
]
.field [
.name with
.type piqi-any % an actual extension object
.repeated
]
.field [
% this way of specifying extensions will be deprecated soon
.type piqi-any % an actual extension object
.repeated
.deprecated
]
]
.variant [
.name extend-target
.option [ .name typedef .type name ]
.option [
% previous name for "typedef"; kept for backwards compatibility; will be
% fully deprecated in future Piqi versions; NOTE: typedef takes
% precedence over it
.type name
.deprecated
]
.option [ .name field .type name ]
.option [ .name option .type name ]
.option [ .name import .type name ]
.option [ .name function .type name ]
]
%
% renamed and deprecated Protobuf fields
%
.extend [
(.typedef piqi record variant list enum)
.with.field [
% same as protobuf-custom in Piqi-0.5.*
.name proto-custom
.type string
.repeated
.deprecated
]
]
.extend [
(.typedef record field variant option enum alias list)
.with.field [
% same as protobuf-name in Piqi-0.5.*
.name proto-name
.type string
.optional
.deprecated
]
]
.extend [
.typedef piqi
.with.field [
% same as protobuf-package in Piqi-0.5.*
.name proto-package
.type string
.optional
.deprecated
]
]
.extend [
(.typedef field list)
.with.field [
% same as protobuf-packed in Piqi-0.5.*
.name wire-packed
.optional
.deprecated
]
]
include piqi
type include =
{
- module :: word()
}
type function-param =
| name()
| record()
| variant()
| enum()
| list()
| alias()
type extend =
{
* what :: extend-target()
? override
* with :: piqi-any()
* piqi-any()
}
type extend-target =
| typedef :: name()
| name()
| field :: name()
| option :: name()
| import :: name()
| function :: name()
extend piqi
* include()
* extend()
extend piqi record variant list enum
* proto-custom :: string()
extend record field variant option enum alias list
? proto-name :: string()
extend piqi
? proto-package :: string()
extend field list
? wire-packed
