@@ -126,10 +126,72 @@ module.exports = {
126
126
/**
127
127
* Reads isset variables
128
128
*/
129
- read_isset_variables : function ( ) {
129
+ read_isset_variables : function ( ) {
130
130
return this . read_function_list ( this . read_isset_variable , "," ) ;
131
131
} ,
132
132
133
+ /*
134
+ * Reads internal PHP functions
135
+ */
136
+ read_internal_functions_in_yacc : function ( ) {
137
+ let result = null ;
138
+ switch ( this . token ) {
139
+ case this . tok . T_ISSET :
140
+ {
141
+ result = this . node ( "isset" ) ;
142
+ if ( this . next ( ) . expect ( "(" ) ) {
143
+ this . next ( ) ;
144
+ }
145
+ const variables = this . read_isset_variables ( ) ;
146
+ if ( this . expect ( ")" ) ) {
147
+ this . next ( ) ;
148
+ }
149
+ result = result ( variables ) ;
150
+ }
151
+ break ;
152
+ case this . tok . T_EMPTY :
153
+ {
154
+ result = this . node ( "empty" ) ;
155
+ if ( this . next ( ) . expect ( "(" ) ) {
156
+ this . next ( ) ;
157
+ }
158
+ const expression = this . read_expr ( ) ;
159
+ if ( this . expect ( ")" ) ) {
160
+ this . next ( ) ;
161
+ }
162
+ result = result ( expression ) ;
163
+ }
164
+ break ;
165
+ case this . tok . T_INCLUDE :
166
+ result = this . node ( "include" ) ( false , false , this . next ( ) . read_expr ( ) ) ;
167
+ break ;
168
+ case this . tok . T_INCLUDE_ONCE :
169
+ result = this . node ( "include" ) ( true , false , this . next ( ) . read_expr ( ) ) ;
170
+ break ;
171
+ case this . tok . T_EVAL :
172
+ {
173
+ result = this . node ( "eval" ) ;
174
+ if ( this . next ( ) . expect ( "(" ) ) {
175
+ this . next ( ) ;
176
+ }
177
+ const expr = this . read_expr ( ) ;
178
+ if ( this . expect ( ")" ) ) {
179
+ this . next ( ) ;
180
+ }
181
+ result = result ( expr ) ;
182
+ }
183
+ break ;
184
+ case this . tok . T_REQUIRE :
185
+ result = this . node ( "include" ) ( false , true , this . next ( ) . read_expr ( ) ) ;
186
+ break ;
187
+ case this . tok . T_REQUIRE_ONCE :
188
+ result = this . node ( "include" ) ( true , true , this . next ( ) . read_expr ( ) ) ;
189
+ break ;
190
+ }
191
+
192
+ return result ;
193
+ } ,
194
+
133
195
/**
134
196
* ```ebnf
135
197
* Reads an expression
@@ -224,51 +286,14 @@ module.exports = {
224
286
case this . tok . T_NEW :
225
287
return this . read_new_expr ( ) ;
226
288
227
- case this . tok . T_ISSET : {
228
- result = this . node ( "isset" ) ;
229
- if ( this . next ( ) . expect ( "(" ) ) {
230
- this . next ( ) ;
231
- }
232
- const variables = this . read_isset_variables ( ) ;
233
- if ( this . expect ( ")" ) ) {
234
- this . next ( ) ;
235
- }
236
- return result ( variables ) ;
237
- }
238
- case this . tok . T_EMPTY : {
239
- result = this . node ( "empty" ) ;
240
- if ( this . next ( ) . expect ( "(" ) ) {
241
- this . next ( ) ;
242
- }
243
- const expression = this . read_expr ( ) ;
244
- if ( this . expect ( ")" ) ) {
245
- this . next ( ) ;
246
- }
247
- return result ( expression ) ;
248
- }
289
+ case this . tok . T_ISSET :
290
+ case this . tok . T_EMPTY :
249
291
case this . tok . T_INCLUDE :
250
- return this . node ( "include" ) ( false , false , this . next ( ) . read_expr ( ) ) ;
251
-
252
292
case this . tok . T_INCLUDE_ONCE :
253
- return this . node ( "include" ) ( true , false , this . next ( ) . read_expr ( ) ) ;
254
-
293
+ case this . tok . T_EVAL :
255
294
case this . tok . T_REQUIRE :
256
- return this . node ( "include" ) ( false , true , this . next ( ) . read_expr ( ) ) ;
257
-
258
295
case this . tok . T_REQUIRE_ONCE :
259
- return this . node ( "include" ) ( true , true , this . next ( ) . read_expr ( ) ) ;
260
-
261
- case this . tok . T_EVAL :
262
- result = this . node ( "eval" ) ;
263
- if ( this . next ( ) . expect ( "(" ) ) {
264
- this . next ( ) ;
265
- }
266
- expr = this . read_expr ( ) ;
267
- if ( this . expect ( ")" ) ) {
268
- this . next ( ) ;
269
- }
270
- return result ( expr ) ;
271
-
296
+ return this . read_internal_functions_in_yacc ( ) ;
272
297
case this . tok . T_INT_CAST :
273
298
return this . read_expr_cast ( "int" ) ;
274
299
0 commit comments