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
7 http://www.apache.org/licenses/LICENSE-2.0
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 ------------------------------------------- */
18 bison --verbose -d -p xmlParser -o xml.tab.cc xml.y
28 /* Some addn'l includes, necessary but not included by the
34 /* prototypes for the parser callbacks.
40 extern xml_t *xml_result;
42 extern int xmlParserdebug;
43 extern void xmlParsererror(char *s);
44 extern int xmlParserlex();
59 struct name_val_pair_t *nvpt;
60 struct name_val_list_t *nvpl;
62 struct xml_list_t *xlist_t;
67 %token <strval> STRING_TOKEN
71 %type <nvpl> opt_val_list
72 %type <strval> end_tag
73 %type <tg_t> start_tag
74 %type <xlist_t> xml_list
80 parse_result: resource {xml_result = $1;}
84 start_tag xml_list end_tag {$$ = new xml_t($1,$2,$3);}
85 | start_tag end_tag {$$=new xml_t($1,$2);}
86 | '<' NAME opt_val_list '/' '>' {$$=new xml_t($2,$3);}
90 '<' NAME opt_val_list '>' {$$ = new tag_t($2, $3);}
94 '<' '/' NAME '>' {$$=$3;}
99 resource {$$=new xml_list_t($1);}
100 | xml_list resource {$$=$1->append($2);}
105 | {$$=new name_val_list_t();}
109 val {$$ = new name_val_list_t($1);}
110 | val_list val {$$ = $1->append($2);}
114 NAME '=' STRING_TOKEN {$$ = new name_val_pair_t($1,$3);}