Added quantiling UDAFs
[com/gs-lite.git] / src / ftacmp / res.y
1 /* ------------------------------------------------\r
2 Copyright 2014 AT&T Intellectual Property\r
3    Licensed under the Apache License, Version 2.0 (the "License");\r
4    you may not use this file except in compliance with the License.\r
5    You may obtain a copy of the License at\r
6 \r
7      http://www.apache.org/licenses/LICENSE-2.0\r
8 \r
9    Unless required by applicable law or agreed to in writing, software\r
10    distributed under the License is distributed on an "AS IS" BASIS,\r
11    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
12    See the License for the specific language governing permissions and\r
13    limitations under the License.\r
14  ------------------------------------------- */\r
15 \r
16 /*\r
17         MUST COMPILE WITH\r
18                 bison --verbose --defines=res.tab.cc.h -p ResParser  -o res.tab.cc res.y\r
19 \r
20          (or equivalent).\r
21 */\r
22 \r
23 %{\r
24 \r
25 \r
26 #include <stdio.h>\r
27 \r
28 /*              Some addn'l includes, necessary but not included by the\r
29                 bison generated code.\r
30 */\r
31 \r
32 #include <stdlib.h>\r
33 \r
34 /*              prototypes for the parser callbacks.\r
35 */\r
36 \r
37 #include "iface_q.h"\r
38 \r
39 \r
40 extern resparse_data *rpd_ptr;\r
41 extern std::vector<std::string> res_attr_vec;\r
42 extern std::vector<std::string> res_val_vec;\r
43 extern std::string res_a, res_v;\r
44 \r
45 \r
46 \r
47 #define YYDEBUG 1\r
48 \r
49 %}\r
50 \r
51 \r
52         /* symbolic tokens */\r
53 \r
54 %union {\r
55         int intval;\r
56         double floatval;\r
57         char *strval;\r
58         int subtok;\r
59 \r
60         /*                      for FTA definition.     */\r
61 \r
62 }\r
63 \r
64 %token <strval> NAME\r
65 %token <strval> STRING_TOKEN\r
66 \r
67 \r
68 \r
69 \r
70 %%\r
71 \r
72 parse_result:   resource\r
73         ;\r
74 \r
75 resource:\r
76         start_tag res_list end_tag\r
77         | start_tag end_tag\r
78         | '<' NAME opt_val_list '/' '>'\r
79                 {startElement(rpd_ptr, $2, res_attr_vec, res_val_vec);\r
80                 endElement(rpd_ptr, $2);\r
81                 }\r
82         ;\r
83 \r
84 start_tag:\r
85         '<' NAME opt_val_list '>'       {startElement(rpd_ptr, $2, res_attr_vec, res_val_vec);}\r
86         ;\r
87 \r
88 end_tag:\r
89         '<' '/' NAME '>'        {endElement(rpd_ptr, $3);}\r
90         ;\r
91 \r
92 \r
93 res_list:\r
94         resource\r
95         | res_list resource\r
96         ;\r
97 \r
98 opt_val_list:\r
99         val_list\r
100         |               {res_attr_vec.clear(); res_val_vec.clear();}\r
101         ;\r
102 \r
103 val_list:\r
104         val             {res_attr_vec.clear();  res_attr_vec.push_back(res_a);\r
105                          res_val_vec.clear(); res_val_vec.push_back(res_v); }\r
106         | val_list val {res_attr_vec.push_back(res_a);\r
107                                         res_val_vec.push_back(res_v); }\r
108         ;\r
109 \r
110 val:\r
111         NAME '=' STRING_TOKEN   {res_a = $1; res_v = $3;}\r
112         ;\r
113         \r
114 \r
115 \r
116 \r
117 \r
118 %%\r
119 \r