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=ext_fcns.tab.cc.h -p Ext_fcnsParser -o ext_fcns.tab.cc ext_fcns.y
28 /* Some addn'l includes, necessary but not included by the
34 /* prototypes for the parser callbacks.
37 #include "parse_ext_fcns.h"
39 /* Interface to ext_fcns parser */
41 void yyerror(char *s);
43 extern int flex_ext_fcns_lineno, flex_ext_fcns_ch;
46 extern ext_fcn_list *Ext_fcns;
57 ext_fcn_list *ext_fcn_list_t;
58 ext_fcn_def *ext_fcn_t;
59 ext_fcn_param_list *plist_t;
61 ext_fcn_param *param_t;
62 ext_fcn_modifier_list *modif_t;
67 %token <strval> STRING_TOKEN
68 %token <strval> INTNUM
71 %type <ext_fcn_t> fcn_def
72 %type <ext_fcn_list_t> fcn_list
73 %type <plist_t> param_commalist
74 %type <plist_t> opt_param_commalist
75 %type <tplist_t> type_param_commalist
76 %type <tplist_t> opt_type_param_commalist
78 %type <modif_t> modifier_list
82 /* literal keyword tokens */
84 %token SEMICOLON HANDLE CONST CLASS FUN PRED
85 %token EXTR UDAF STATE SFUN
90 result: fcn_list {Ext_fcns = $1;}
93 fcn_list: fcn_def {$$ = new ext_fcn_list($1);}
94 | fcn_list fcn_def {$$ = $1->append_ext_fcn_def($2);}
97 fcn_def: NAME opt_type_param_commalist FUN '[' modifier_list ']' NAME '(' opt_param_commalist ')' SEMICOLON {
98 $$=new ext_fcn_def($1,$2,$5,$7,$9); delete $5; delete $9; }
99 | NAME opt_type_param_commalist FUN NAME '(' opt_param_commalist ')' SEMICOLON {
100 $$=new ext_fcn_def($1,$2,NULL,$4,$6); delete $6; }
101 | PRED '[' modifier_list ']' NAME '[' opt_param_commalist ']' SEMICOLON {
102 $$=new ext_fcn_def($3,$5,$7); delete $3; delete $7; }
103 | PRED NAME '[' opt_param_commalist ']' SEMICOLON {
104 $$=new ext_fcn_def(NULL,$2,$4); delete $4; }
105 | NAME opt_type_param_commalist UDAF '[' modifier_list ']' NAME NAME '(' opt_param_commalist ')' SEMICOLON {
106 $$=new ext_fcn_def($1,$2,$5,$7,$8,$10); delete $5; delete $10; }
107 | NAME opt_type_param_commalist UDAF NAME NAME '(' opt_param_commalist ')' SEMICOLON {
108 $$=new ext_fcn_def($1,$2,NULL,$4,$5, $7); delete $7; }
109 | NAME opt_type_param_commalist EXTR '[' modifier_list ']' NAME NAME NAME '(' opt_param_commalist ')' SEMICOLON {
110 $$=new ext_fcn_def($1,$2,$5,$7,$8, $9, $11); delete $5; delete $11; }
111 | NAME opt_type_param_commalist EXTR NAME NAME NAME '(' opt_param_commalist ')' SEMICOLON {
112 $$=new ext_fcn_def($1,$2,NULL,$4,$5, $6, $8); delete $8; }
113 | NAME opt_type_param_commalist SFUN '[' modifier_list ']' NAME NAME '(' opt_param_commalist ')' SEMICOLON {
114 $$=ext_fcn_def::make_sfun_def($1,$2,$5,$7,$8,$10); delete $10; }
115 | NAME opt_type_param_commalist SFUN NAME NAME '(' opt_param_commalist ')' SEMICOLON {
116 $$=ext_fcn_def::make_sfun_def($1,$2,NULL,$4,$5,$7); delete $7; }
117 | NAME STATE NAME SEMICOLON {
118 $$=ext_fcn_def::make_state_def($1,$3); }
123 /* empty */ {$$ = NULL;}
124 | param_commalist {$$ = $1;}
128 NAME {$$ = new ext_fcn_modifier_list($1);}
129 | NAME NAME {$$ = new ext_fcn_modifier_list($1, $2);}
130 | modifier_list ',' NAME {$$ = $1->append($3); }
131 | modifier_list ',' NAME NAME {$$ = $1->append($3, $4); }
135 param {$$ = new ext_fcn_param_list($1);}
136 | param_commalist ',' param {$$ = $1->append($3);}
140 NAME opt_type_param_commalist HANDLE { $$ = new ext_fcn_param($1,$2,1,0,0);}
141 | NAME opt_type_param_commalist CONST { $$ = new ext_fcn_param($1,$2,0,1,0);}
142 | NAME opt_type_param_commalist CLASS { $$ = new ext_fcn_param($1,$2,0,0,1);}
143 | NAME opt_type_param_commalist HANDLE CLASS { $$ = new ext_fcn_param($1,$2,1,0,1);}
144 | NAME opt_type_param_commalist CONST CLASS { $$ = new ext_fcn_param($1,$2,0,1,1);}
145 | NAME opt_type_param_commalist
146 { $$ = new ext_fcn_param($1,$2,0,0,0);}
149 opt_type_param_commalist:
150 /* empty */ {$$ = NULL;}
151 | '(' type_param_commalist ')' {$$ = $2;}
154 type_param_commalist:
155 NAME {$$ = new param_list($1);}
156 | NAME NAME {$$ = new param_list($1,$2);}
157 | NAME STRING_TOKEN {$$ = new param_list($1,$2);}
158 | NAME INTNUM {$$ = new param_list($1,$2);}
159 | type_param_commalist ',' NAME {$$ = $1->append($3);}
160 | type_param_commalist ',' NAME NAME {$$ = $1->append($3,$4);}
161 | type_param_commalist ',' NAME STRING_TOKEN {$$ = $1->append($3,$4);}
162 | type_param_commalist ',' NAME INTNUM {$$ = $1->append($3,$4);}