Add new udafs and RMR support to gsprintconsole_ves
[com/gs-lite.git] / src / ftacmp / nic.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 --defines=nic.tab.cc.h -p NicParser  -o nic.tab.cc nic.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 "nic_def.h"
38
39 extern int NicParserlex();
40 void NicParsererror(char *s);
41
42
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;
47
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 %token FUNC TYPES UNARY_OPS BINARY_OPS FIELDS OPTIONS
70
71
72
73
74 %%
75
76 parse_result:
77         opts types unary_ops binary_ops fields fcns 
78         ;
79
80 opts:
81         OPTIONS opt_val_list ';' {nicp->opta=nic_attr_vec; nicp->optv=nic_val_vec;}
82         ;
83
84 types:
85         TYPES  opt_attr_list ';' {nicp->typea=nic_attr_vec;}
86         ;
87
88 unary_ops:
89         UNARY_OPS  opt_attr_list ';' {nicp->opua=nic_attr_vec;}
90         ;
91
92 binary_ops:
93         BINARY_OPS  opt_attr_list ';' {nicp->opba=nic_attr_vec;}
94         ;
95
96 fields:
97         FIELDS  opt_attr_list ';' {nicp->fieldsa=nic_attr_vec;}
98         ;
99
100 fcns:
101         FUNC  opt_attr_list ';' {nicp->funca=nic_attr_vec;}
102         ;
103
104 opt_attr_list:
105         attr_list
106         |               {nic_attr_vec.clear(); }
107         ;
108
109 attr_list:
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);}
114         ;
115
116 opt_val_list:
117         val_list
118         |               {nic_attr_vec.clear(); nic_val_vec.clear();}
119         ;
120
121 val_list:
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); }
126         ;
127
128 val:
129         NAME '=' STRING_TOKEN   {nic_a = $1; nic_v = $3;}
130         | NAME '=' NAME         {nic_a = $1; nic_v = $3;}
131         ;
132         
133
134
135
136
137 %%
138