Skip to content

Commit b2db582

Browse files
committed
Define extended PIG IDL
1 parent fa0f3dc commit b2db582

File tree

2 files changed

+534
-0
lines changed

2 files changed

+534
-0
lines changed

docs/IDL_other.adoc

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
= PIG — Interface Definition Language
2+
:toc:
3+
:toc-title: Page Contents
4+
:sectlinks:
5+
6+
IMPORTANT: This specifically does not use an Ion DSL.
7+
8+
This document defines an interface definition language for an Ion serialization.
9+
10+
== Notation
11+
12+
This document uses the xref:https://github.com/antlr/antlr4/blob/master/doc/grammars.md[ANTLR grammar notation] to define the IDL.
13+
14+
== Interface Definition Language
15+
16+
=== Document
17+
18+
[source,antlr]
19+
----
20+
document : include* definition*;
21+
22+
include: 'include' string;
23+
24+
definition
25+
: product
26+
| sum
27+
| enum
28+
| fixed
29+
| unit
30+
;
31+
----
32+
33+
=== References and Identifiers
34+
35+
[source,antlr]
36+
----
37+
type
38+
: primitive
39+
| container
40+
| path
41+
;
42+
43+
path
44+
: name ('.' name)*
45+
;
46+
47+
name: [a-z_]+;
48+
----
49+
50+
=== Primitive Types
51+
52+
[source,antlr]
53+
----
54+
primitive
55+
: 'bool'
56+
| 'int32' // 32-bit signed integer
57+
| 'int64' // 64-bit signed integer
58+
| 'float32' // IEEE 754 (32 bit)
59+
| 'float64' // IEEE 754 (64 bit)
60+
| 'decimal' // Decimal-encoded real numbers
61+
| 'string' // Unicode character sequence
62+
| 'bytes' // Array of unsigned bytes
63+
| 'ion' // Raw Ion value
64+
;
65+
----
66+
67+
=== Container Types
68+
69+
[source,antlr]
70+
----
71+
container
72+
: list
73+
| map
74+
| set
75+
;
76+
----
77+
78+
==== List
79+
80+
[source,antlr]
81+
----
82+
list : 'list' '<' type '>';
83+
----
84+
85+
==== Map
86+
87+
[source,antlr]
88+
----
89+
map : 'map' '<' key=type ',' value=type '>';
90+
----
91+
92+
==== Set
93+
94+
[source,antlr]
95+
----
96+
set : 'set' '<' type '>';
97+
----
98+
99+
=== User-Defined Types
100+
101+
==== Product
102+
103+
[source,antlr]
104+
----
105+
product : 'product' '{' operand+ definition* '}';
106+
107+
operand: name ':' type;
108+
----
109+
110+
.Example
111+
[source]
112+
----
113+
product node {
114+
a_map: map<string, string>; // builtin map type
115+
b_map: list<entry>; // alternative
116+
117+
product entry {
118+
key: string;
119+
value: string;
120+
}
121+
}
122+
----
123+
124+
==== Sum
125+
126+
[source,antlr]
127+
----
128+
sum : 'sum' name '{' variant+ '}';
129+
130+
variant : sum | product;
131+
----
132+
133+
.Example
134+
[source]
135+
----
136+
sum node {
137+
138+
product inner {
139+
left: node;
140+
right: node;
141+
}
142+
143+
product leaf {
144+
value: string;
145+
}
146+
}
147+
----
148+
149+
==== Enum
150+
151+
[source]
152+
----
153+
enum : 'enum' name '{' enumerator+ '}'
154+
155+
enumerator : [A-Z]+
156+
----
157+
158+
.Example
159+
[source]
160+
----
161+
enum my_enum { A, B, C }
162+
----
163+
164+
==== Fixed
165+
166+
Define a type with a fixed size in bytes.
167+
168+
[source,antlr]
169+
----
170+
fixed : 'fixed' name '(' integer ')';
171+
----
172+
173+
.Example
174+
[source]
175+
----
176+
fixed uuid(16)
177+
----
178+
179+
==== Unit
180+
181+
Define a type which is represented by only its name.
182+
183+
[source,antlr]
184+
----
185+
unit : 'unit' name
186+
----

0 commit comments

Comments
 (0)