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