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 --defines=nic.tab.cc.h -p NicParser -o nic.tab.cc nic.y
28 /* Some addn'l includes, necessary but not included by the
34 /* prototypes for the parser callbacks.
39 extern int NicParserlex();
40 void NicParsererror(char *s);
43 extern nic_property *nicp;
44 extern std::vector<std::string> nic_attr_vec;
45 extern std::vector<std::string> nic_val_vec;
46 extern std::string nic_a, nic_v;
63 /* for FTA definition. */
68 %token <strval> STRING_TOKEN
69 %token FUNC TYPES UNARY_OPS BINARY_OPS FIELDS OPTIONS
77 opts types unary_ops binary_ops fields fcns
81 OPTIONS opt_val_list ';' {nicp->opta=nic_attr_vec; nicp->optv=nic_val_vec;}
85 TYPES opt_attr_list ';' {nicp->typea=nic_attr_vec;}
89 UNARY_OPS opt_attr_list ';' {nicp->opua=nic_attr_vec;}
93 BINARY_OPS opt_attr_list ';' {nicp->opba=nic_attr_vec;}
97 FIELDS opt_attr_list ';' {nicp->fieldsa=nic_attr_vec;}
101 FUNC opt_attr_list ';' {nicp->funca=nic_attr_vec;}
106 | {nic_attr_vec.clear(); }
110 NAME {nic_attr_vec.clear(); nic_attr_vec.push_back($1); }
111 | STRING_TOKEN {nic_attr_vec.clear(); nic_attr_vec.push_back($1); }
112 | attr_list ',' NAME {nic_attr_vec.push_back($3);}
113 | attr_list ',' STRING_TOKEN {nic_attr_vec.push_back($3);}
118 | {nic_attr_vec.clear(); nic_val_vec.clear();}
122 val {nic_attr_vec.clear(); nic_attr_vec.push_back(nic_a);
123 nic_val_vec.clear(); nic_val_vec.push_back(nic_v); }
124 | val_list ',' val {nic_attr_vec.push_back(nic_a);
125 nic_val_vec.push_back(nic_v); }
129 NAME '=' STRING_TOKEN {nic_a = $1; nic_v = $3;}
130 | NAME '=' NAME {nic_a = $1; nic_v = $3;}