blob: 0128199531e8f08e0e9361b4dc2fe51954b58090 [file] [log] [blame]
Dusan Klinecccaa0d92014-11-09 03:21:31 +01001import plyproto.parser as plyproto
2
3test1 = """package tutorial;"""
4
5test2 = """package tutorial;
6
7message Person {
8 required string name = 1;
9 required int32 id = 2;
10 optional string email = 3;
11}
12
13"""
14
15test3 = """package tutorial;
16option java_outer_classname = "PushNotifications";
Dusan Klinecaa9ff472014-11-10 18:02:03 +010017option optimize_for = SPEED;
Dusan Klinecccaa0d92014-11-09 03:21:31 +010018
19 message Person {
20 required string name = 1;
21 required int32 id = 2;
22 optional string email = 3;
23
24 enum PhoneType {
25 MOBILE = 0;
26 HOME = 1;
27 WORK = 2;
28 }
29
30 message PhoneNumber {
31 required string number = 1;
32 optional PhoneType type = 2 [default = HOME];
33 }
34
35 repeated PhoneNumber phone = 4;
36 extensions 500 to 990;
37}
38
39message AddressBook {
40 repeated Person person = 1;
41
42 // Possible extension numbers.
43 extensions 500 to max;
44}"""
45
46parser = plyproto.ProtobufAnalyzer()
47print(parser.parse_string(test3))