Added quantiling UDAFs
[com/gs-lite.git] / src / ftacmp / xml.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 -d -p xmlParser  -o xml.tab.cc xml.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 "xml_t.h"\r
38 \r
39 \r
40 extern std::vector<std::string> xml_attr_vec;\r
41 extern std::vector<std::string> xml_val_vec;\r
42 extern std::string xml_a, xml_v;\r
43 extern xml_t *xml_leaves;\r
44 \r
45 extern int xmlParserdebug;\r
46 extern void xmlParsererror(char *s);\r
47 extern int xmlParserlex();\r
48 \r
49 \r
50 #define YYDEBUG 1\r
51 \r
52 %}\r
53 \r
54 \r
55         /* symbolic tokens */\r
56 \r
57 %union {\r
58         int intval;\r
59         double floatval;\r
60         char *strval;\r
61         int subtok;\r
62 \r
63         /*                      for FTA definition.     */\r
64 \r
65 }\r
66 \r
67 %token <strval> NAME\r
68 %token <strval> STRING_TOKEN\r
69 \r
70 \r
71 \r
72 \r
73 %%\r
74 \r
75 parse_result:   resource\r
76         ;\r
77 \r
78 resource:\r
79         start_tag xml_list end_tag\r
80         | start_tag end_tag\r
81         | '<' NAME opt_val_list '/' '>'\r
82                 {xml_leaves->add_leaf(new xml_leaf_t($2, xml_attr_vec, xml_val_vec));\r
83                 }\r
84         ;\r
85 \r
86 start_tag:\r
87         '<' NAME opt_val_list '>'       \r
88         ;\r
89 \r
90 end_tag:\r
91         '<' '/' NAME '>'        \r
92         ;\r
93 \r
94 \r
95 xml_list:\r
96         resource\r
97         | xml_list resource\r
98         ;\r
99 \r
100 opt_val_list:\r
101         val_list\r
102         |               {xml_attr_vec.clear(); xml_val_vec.clear();}\r
103         ;\r
104 \r
105 val_list:\r
106         val             {xml_attr_vec.clear();  xml_attr_vec.push_back(xml_a);\r
107                          xml_val_vec.clear(); xml_val_vec.push_back(xml_v); }\r
108         | val_list val {xml_attr_vec.push_back(xml_a);\r
109                                         xml_val_vec.push_back(xml_v); }\r
110         ;\r
111 \r
112 val:\r
113         NAME '=' STRING_TOKEN   {xml_a = $1; xml_v = $3;}\r
114         ;\r
115         \r
116 \r
117 \r
118 \r
119 \r
120 %%\r
121 \r
122 \r