blob: ad07c4cff584c001dafb50df15187cc51ce41548 [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
Sapan Bhatia2ddf83a2017-06-10 04:31:40 -070019 message Person(types.Actor) {
Dusan Klinecccaa0d92014-11-09 03:21:31 +010020 required string name = 1;
21 required int32 id = 2;
22 optional string email = 3;
23
Sapan Bhatia2ddf83a2017-06-10 04:31:40 -070024 required manytoone work_location->Location/types.Company:employees = 4;
25
Dusan Klinecccaa0d92014-11-09 03:21:31 +010026 enum PhoneType {
27 MOBILE = 0;
28 HOME = 1;
29 WORK = 2;
30 }
31
32 message PhoneNumber {
33 required string number = 1;
34 optional PhoneType type = 2 [default = HOME];
35 }
36
37 repeated PhoneNumber phone = 4;
38 extensions 500 to 990;
39}
40
41message AddressBook {
42 repeated Person person = 1;
43
44 // Possible extension numbers.
45 extensions 500 to max;
46}"""
47
48parser = plyproto.ProtobufAnalyzer()
49print(parser.parse_string(test3))