@@ -212,6 +212,8 @@ var Position = require('./ast/position');
212
212
* - [Variable](#variable)
213
213
* - [Variadic](#variadic)
214
214
* - [ConstRef](#constref)
215
+ * - [Yield](#yield)
216
+ * - [YieldFrom](#yieldfrom)
215
217
* - [Lookup](#lookup)
216
218
* - [PropertyLookup](#propertylookup)
217
219
* - [StaticLookup](#staticlookup)
@@ -444,7 +446,9 @@ AST.prototype.prepare = function(kind, parser) {
444
446
require ( './ast/useitem' ) ,
445
447
require ( './ast/variable' ) ,
446
448
require ( './ast/variadic' ) ,
447
- require ( './ast/while' )
449
+ require ( './ast/while' ) ,
450
+ require ( './ast/yield' ) ,
451
+ require ( './ast/yieldfrom' )
448
452
] . forEach ( function ( ctor ) {
449
453
var kind = ctor . prototype . constructor . name . toLowerCase ( ) ;
450
454
if ( kind [ 0 ] === '_' ) kind = kind . substring ( 1 ) ;
@@ -453,7 +457,7 @@ AST.prototype.prepare = function(kind, parser) {
453
457
454
458
module . exports = AST ;
455
459
456
- } , { "./ast/array" :3 , "./ast/assign" :4 , "./ast/bin" :5 , "./ast/block" :6 , "./ast/bool" :7 , "./ast/boolean" :8 , "./ast/break" :9 , "./ast/call" :10 , "./ast/case" :11 , "./ast/cast" :12 , "./ast/catch" :13 , "./ast/class" :14 , "./ast/classconstant" :15 , "./ast/clone" :16 , "./ast/closure" :17 , "./ast/coalesce" :18 , "./ast/constant" :19 , "./ast/constref" :20 , "./ast/continue" :21 , "./ast/declare" :23 , "./ast/do" :24 , "./ast/doc" :25 , "./ast/echo" :26 , "./ast/empty" :27 , "./ast/encapsed" :28 , "./ast/entry" :29 , "./ast/error" :30 , "./ast/eval" :31 , "./ast/exit" :32 , "./ast/expression" :33 , "./ast/for" :34 , "./ast/foreach" :35 , "./ast/function" :36 , "./ast/global" :37 , "./ast/goto" :38 , "./ast/halt" :39 , "./ast/identifier" :40 , "./ast/if" :41 , "./ast/include" :42 , "./ast/inline" :43 , "./ast/interface" :44 , "./ast/isset" :45 , "./ast/label" :46 , "./ast/list" :47 , "./ast/literal" :48 , "./ast/location" :49 , "./ast/magic" :51 , "./ast/method" :52 , "./ast/namespace" :53 , "./ast/new" :54 , "./ast/node" :55 , "./ast/nowdoc" :56 , "./ast/number" :57 , "./ast/offsetlookup" :58 , "./ast/parameter" :60 , "./ast/parenthesis" :61 , "./ast/position" :62 , "./ast/post" :63 , "./ast/pre" :64 , "./ast/print" :65 , "./ast/program" :66 , "./ast/property" :67 , "./ast/propertylookup" :68 , "./ast/retif" :69 , "./ast/return" :70 , "./ast/shell" :71 , "./ast/silent" :72 , "./ast/static" :74 , "./ast/staticlookup" :75 , "./ast/string" :76 , "./ast/switch" :77 , "./ast/throw" :79 , "./ast/trait" :80 , "./ast/traitalias" :81 , "./ast/traitprecedence" :82 , "./ast/traituse" :83 , "./ast/try" :84 , "./ast/unary" :85 , "./ast/unset" :86 , "./ast/usegroup" :87 , "./ast/useitem" :88 , "./ast/variable" :89 , "./ast/variadic" :90 , "./ast/while" :91 } ] , 3 :[ function ( require , module , exports ) {
460
+ } , { "./ast/array" :3 , "./ast/assign" :4 , "./ast/bin" :5 , "./ast/block" :6 , "./ast/bool" :7 , "./ast/boolean" :8 , "./ast/break" :9 , "./ast/call" :10 , "./ast/case" :11 , "./ast/cast" :12 , "./ast/catch" :13 , "./ast/class" :14 , "./ast/classconstant" :15 , "./ast/clone" :16 , "./ast/closure" :17 , "./ast/coalesce" :18 , "./ast/constant" :19 , "./ast/constref" :20 , "./ast/continue" :21 , "./ast/declare" :23 , "./ast/do" :24 , "./ast/doc" :25 , "./ast/echo" :26 , "./ast/empty" :27 , "./ast/encapsed" :28 , "./ast/entry" :29 , "./ast/error" :30 , "./ast/eval" :31 , "./ast/exit" :32 , "./ast/expression" :33 , "./ast/for" :34 , "./ast/foreach" :35 , "./ast/function" :36 , "./ast/global" :37 , "./ast/goto" :38 , "./ast/halt" :39 , "./ast/identifier" :40 , "./ast/if" :41 , "./ast/include" :42 , "./ast/inline" :43 , "./ast/interface" :44 , "./ast/isset" :45 , "./ast/label" :46 , "./ast/list" :47 , "./ast/literal" :48 , "./ast/location" :49 , "./ast/magic" :51 , "./ast/method" :52 , "./ast/namespace" :53 , "./ast/new" :54 , "./ast/node" :55 , "./ast/nowdoc" :56 , "./ast/number" :57 , "./ast/offsetlookup" :58 , "./ast/parameter" :60 , "./ast/parenthesis" :61 , "./ast/position" :62 , "./ast/post" :63 , "./ast/pre" :64 , "./ast/print" :65 , "./ast/program" :66 , "./ast/property" :67 , "./ast/propertylookup" :68 , "./ast/retif" :69 , "./ast/return" :70 , "./ast/shell" :71 , "./ast/silent" :72 , "./ast/static" :74 , "./ast/staticlookup" :75 , "./ast/string" :76 , "./ast/switch" :77 , "./ast/throw" :79 , "./ast/trait" :80 , "./ast/traitalias" :81 , "./ast/traitprecedence" :82 , "./ast/traituse" :83 , "./ast/try" :84 , "./ast/unary" :85 , "./ast/unset" :86 , "./ast/usegroup" :87 , "./ast/useitem" :88 , "./ast/variable" :89 , "./ast/variadic" :90 , "./ast/while" :91 , "./ast/yield" :92 , "./ast/yieldfrom" :93 } ] , 3 :[ function ( require , module , exports ) {
457
461
/*!
458
462
* Copyright (C) 2017 Glayzzle (BSD3 License)
459
463
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -2879,6 +2883,58 @@ module.exports = While;
2879
2883
* @url http://glayzzle.com
2880
2884
*/
2881
2885
"use strict" ;
2886
+
2887
+ var Expression = require ( './expression' ) ;
2888
+ var KIND = 'yield' ;
2889
+
2890
+ /**
2891
+ * Defines a yield generator statement
2892
+ * @constructor Yield
2893
+ * @extends {Expression }
2894
+ * @property {Expression|Null } value
2895
+ * @property {Expression|Null } key
2896
+ * @see http://php.net/manual/en/language.generators.syntax.php
2897
+ */
2898
+ var Yield = Expression . extends ( function Yield ( value , key , location ) {
2899
+ Expression . apply ( this , [ KIND , location ] ) ;
2900
+ this . value = value ;
2901
+ this . key = key ;
2902
+ } ) ;
2903
+
2904
+ module . exports = Yield ;
2905
+
2906
+ } , { "./expression" :33 } ] , 93 :[ function ( require , module , exports ) {
2907
+ /*!
2908
+ * Copyright (C) 2017 Glayzzle (BSD3 License)
2909
+ * @authors https://github.com/glayzzle/php-parser/graphs/contributors
2910
+ * @url http://glayzzle.com
2911
+ */
2912
+ "use strict" ;
2913
+
2914
+ var Expression = require ( './expression' ) ;
2915
+ var KIND = 'yieldfrom' ;
2916
+
2917
+ /**
2918
+ * Defines a yield from generator statement
2919
+ * @constructor YieldFrom
2920
+ * @extends {Expression }
2921
+ * @property {Expression } value
2922
+ * @see http://php.net/manual/en/language.generators.syntax.php
2923
+ */
2924
+ var YieldFrom = Expression . extends ( function YieldFrom ( value , location ) {
2925
+ Expression . apply ( this , [ KIND , location ] ) ;
2926
+ this . value = value ;
2927
+ } ) ;
2928
+
2929
+ module . exports = YieldFrom ;
2930
+
2931
+ } , { "./expression" :33 } ] , 94 :[ function ( require , module , exports ) {
2932
+ /*!
2933
+ * Copyright (C) 2017 Glayzzle (BSD3 License)
2934
+ * @authors https://github.com/glayzzle/php-parser/graphs/contributors
2935
+ * @url http://glayzzle.com
2936
+ */
2937
+ "use strict" ;
2882
2938
/**
2883
2939
* This is the php lexer. It will tokenize the string for helping the
2884
2940
* parser to build the AST from its grammar.
@@ -3312,7 +3368,7 @@ lexer.prototype.next = function () {
3312
3368
3313
3369
module . exports = lexer ;
3314
3370
3315
- } , { "./lexer/comments.js" :93 , "./lexer/initial.js" :94 , "./lexer/numbers.js" :95 , "./lexer/property.js" :96 , "./lexer/scripting.js" :97 , "./lexer/strings.js" :98 , "./lexer/tokens.js" :99 , "./lexer/utils.js" :100 } ] , 93 :[ function ( require , module , exports ) {
3371
+ } , { "./lexer/comments.js" :95 , "./lexer/initial.js" :96 , "./lexer/numbers.js" :97 , "./lexer/property.js" :98 , "./lexer/scripting.js" :99 , "./lexer/strings.js" :100 , "./lexer/tokens.js" :101 , "./lexer/utils.js" :102 } ] , 95 :[ function ( require , module , exports ) {
3316
3372
/*!
3317
3373
* Copyright (C) 2017 Glayzzle (BSD3 License)
3318
3374
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -3369,7 +3425,7 @@ module.exports = {
3369
3425
}
3370
3426
} ;
3371
3427
3372
- } , { } ] , 94 :[ function ( require , module , exports ) {
3428
+ } , { } ] , 96 :[ function ( require , module , exports ) {
3373
3429
/*!
3374
3430
* Copyright (C) 2017 Glayzzle (BSD3 License)
3375
3431
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -3429,7 +3485,7 @@ module.exports = {
3429
3485
}
3430
3486
} ;
3431
3487
3432
- } , { } ] , 95 :[ function ( require , module , exports ) {
3488
+ } , { } ] , 97 :[ function ( require , module , exports ) {
3433
3489
( function ( process ) {
3434
3490
/*!
3435
3491
* Copyright (C) 2017 Glayzzle (BSD3 License)
@@ -3558,7 +3614,7 @@ module.exports = {
3558
3614
} ;
3559
3615
3560
3616
} ) . call ( this , require ( '_process' ) )
3561
- } , { "_process" :1 } ] , 96 :[ function ( require , module , exports ) {
3617
+ } , { "_process" :1 } ] , 98 :[ function ( require , module , exports ) {
3562
3618
/*!
3563
3619
* Copyright (C) 2017 Glayzzle (BSD3 License)
3564
3620
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -3632,7 +3688,7 @@ module.exports = {
3632
3688
}
3633
3689
} ;
3634
3690
3635
- } , { } ] , 97 :[ function ( require , module , exports ) {
3691
+ } , { } ] , 99 :[ function ( require , module , exports ) {
3636
3692
/*!
3637
3693
* Copyright (C) 2017 Glayzzle (BSD3 License)
3638
3694
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -3734,7 +3790,7 @@ module.exports = {
3734
3790
}
3735
3791
} ;
3736
3792
3737
- } , { } ] , 98 :[ function ( require , module , exports ) {
3793
+ } , { } ] , 100 :[ function ( require , module , exports ) {
3738
3794
/*!
3739
3795
* Copyright (C) 2017 Glayzzle (BSD3 License)
3740
3796
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -4150,7 +4206,7 @@ module.exports = {
4150
4206
}
4151
4207
} ;
4152
4208
4153
- } , { } ] , 99 :[ function ( require , module , exports ) {
4209
+ } , { } ] , 101 :[ function ( require , module , exports ) {
4154
4210
/*!
4155
4211
* Copyright (C) 2017 Glayzzle (BSD3 License)
4156
4212
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -4421,7 +4477,7 @@ module.exports = {
4421
4477
}
4422
4478
} ;
4423
4479
4424
- } , { } ] , 100 :[ function ( require , module , exports ) {
4480
+ } , { } ] , 102 :[ function ( require , module , exports ) {
4425
4481
/*!
4426
4482
* Copyright (C) 2017 Glayzzle (BSD3 License)
4427
4483
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -4509,7 +4565,7 @@ module.exports = {
4509
4565
}
4510
4566
} ;
4511
4567
4512
- } , { } ] , 101 :[ function ( require , module , exports ) {
4568
+ } , { } ] , 103 :[ function ( require , module , exports ) {
4513
4569
/*!
4514
4570
* Copyright (C) 2017 Glayzzle (BSD3 License)
4515
4571
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -4913,7 +4969,7 @@ parser.prototype.read_token = function() {
4913
4969
4914
4970
module . exports = parser ;
4915
4971
4916
- } , { "./parser/array.js" :102 , "./parser/class.js" :103 , "./parser/comment.js" :104 , "./parser/expr.js" :105 , "./parser/function.js" :106 , "./parser/if.js" :107 , "./parser/loops.js" :108 , "./parser/main.js" :109 , "./parser/namespace.js" :110 , "./parser/scalar.js" :111 , "./parser/statement.js" :112 , "./parser/switch.js" :113 , "./parser/try.js" :114 , "./parser/utils.js" :115 , "./parser/variable.js" :116 } ] , 102 :[ function ( require , module , exports ) {
4972
+ } , { "./parser/array.js" :104 , "./parser/class.js" :105 , "./parser/comment.js" :106 , "./parser/expr.js" :107 , "./parser/function.js" :108 , "./parser/if.js" :109 , "./parser/loops.js" :110 , "./parser/main.js" :111 , "./parser/namespace.js" :112 , "./parser/scalar.js" :113 , "./parser/statement.js" :114 , "./parser/switch.js" :115 , "./parser/try.js" :116 , "./parser/utils.js" :117 , "./parser/variable.js" :118 } ] , 104 :[ function ( require , module , exports ) {
4917
4973
/*!
4918
4974
* Copyright (C) 2017 Glayzzle (BSD3 License)
4919
4975
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -5004,7 +5060,7 @@ module.exports = {
5004
5060
}
5005
5061
} ;
5006
5062
5007
- } , { } ] , 103 :[ function ( require , module , exports ) {
5063
+ } , { } ] , 105 :[ function ( require , module , exports ) {
5008
5064
/*!
5009
5065
* Copyright (C) 2017 Glayzzle (BSD3 License)
5010
5066
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -5449,7 +5505,7 @@ module.exports = {
5449
5505
}
5450
5506
} ;
5451
5507
5452
- } , { } ] , 104 :[ function ( require , module , exports ) {
5508
+ } , { } ] , 106 :[ function ( require , module , exports ) {
5453
5509
/*!
5454
5510
* Copyright (C) 2017 Glayzzle (BSD3 License)
5455
5511
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -5496,7 +5552,7 @@ module.exports = {
5496
5552
}
5497
5553
} ;
5498
5554
5499
- } , { } ] , 105 :[ function ( require , module , exports ) {
5555
+ } , { } ] , 107 :[ function ( require , module , exports ) {
5500
5556
/*!
5501
5557
* Copyright (C) 2017 Glayzzle (BSD3 License)
5502
5558
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -5814,20 +5870,23 @@ module.exports = {
5814
5870
5815
5871
// T_YIELD (expr (T_DOUBLE_ARROW expr)?)?
5816
5872
case this . tok . T_YIELD :
5817
- var result = [ 'yield' , null , null ] ;
5873
+ var result = this . node ( 'yield' ) , value = null , key = null ;
5818
5874
if ( this . next ( ) . is ( 'EXPR' ) ) {
5819
5875
// reads the yield return value
5820
- result [ 1 ] = this . read_expr ( ) ;
5876
+ value = this . read_expr ( ) ;
5821
5877
if ( this . token === this . tok . T_DOUBLE_ARROW ) {
5822
5878
// reads the yield returned key
5823
- result [ 2 ] = this . next ( ) . read_expr ( ) ;
5879
+ key = value ;
5880
+ value = this . next ( ) . read_expr ( ) ;
5824
5881
}
5825
5882
}
5826
- return result ;
5883
+ return result ( value , key ) ;
5827
5884
5828
5885
// T_YIELD_FROM expr
5829
5886
case this . tok . T_YIELD_FROM :
5830
- return [ 'yieldfrom' , this . next ( ) . read_expr ( ) ] ;
5887
+ var result = this . node ( 'yieldfrom' ) ;
5888
+ var expr = this . next ( ) . read_expr ( ) ;
5889
+ return result ( expr ) ;
5831
5890
5832
5891
case this . tok . T_FUNCTION :
5833
5892
// @fixme later - removed static lambda function declarations (colides with static keyword usage)
@@ -6012,7 +6071,7 @@ module.exports = {
6012
6071
}
6013
6072
} ;
6014
6073
6015
- } , { } ] , 106 :[ function ( require , module , exports ) {
6074
+ } , { } ] , 108 :[ function ( require , module , exports ) {
6016
6075
/*!
6017
6076
* Copyright (C) 2017 Glayzzle (BSD3 License)
6018
6077
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -6248,7 +6307,7 @@ module.exports = {
6248
6307
}
6249
6308
} ;
6250
6309
6251
- } , { } ] , 107 :[ function ( require , module , exports ) {
6310
+ } , { } ] , 109 :[ function ( require , module , exports ) {
6252
6311
/*!
6253
6312
* Copyright (C) 2017 Glayzzle (BSD3 License)
6254
6313
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -6348,7 +6407,7 @@ module.exports = {
6348
6407
}
6349
6408
} ;
6350
6409
6351
- } , { } ] , 108 :[ function ( require , module , exports ) {
6410
+ } , { } ] , 110 :[ function ( require , module , exports ) {
6352
6411
/*!
6353
6412
* Copyright (C) 2017 Glayzzle (BSD3 License)
6354
6413
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -6508,7 +6567,7 @@ module.exports = {
6508
6567
}
6509
6568
} ;
6510
6569
6511
- } , { } ] , 109 :[ function ( require , module , exports ) {
6570
+ } , { } ] , 111 :[ function ( require , module , exports ) {
6512
6571
/*!
6513
6572
* Copyright (C) 2017 Glayzzle (BSD3 License)
6514
6573
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -6530,7 +6589,7 @@ module.exports = {
6530
6589
}
6531
6590
} ;
6532
6591
6533
- } , { } ] , 110 :[ function ( require , module , exports ) {
6592
+ } , { } ] , 112 :[ function ( require , module , exports ) {
6534
6593
/*!
6535
6594
* Copyright (C) 2017 Glayzzle (BSD3 License)
6536
6595
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -6700,7 +6759,7 @@ module.exports = {
6700
6759
}
6701
6760
} ;
6702
6761
6703
- } , { } ] , 111 :[ function ( require , module , exports ) {
6762
+ } , { } ] , 113 :[ function ( require , module , exports ) {
6704
6763
/*!
6705
6764
* Copyright (C) 2017 Glayzzle (BSD3 License)
6706
6765
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -6995,7 +7054,7 @@ module.exports = {
6995
7054
}
6996
7055
} ;
6997
7056
6998
- } , { } ] , 112 :[ function ( require , module , exports ) {
7057
+ } , { } ] , 114 :[ function ( require , module , exports ) {
6999
7058
/*!
7000
7059
* Copyright (C) 2017 Glayzzle (BSD3 License)
7001
7060
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -7359,7 +7418,7 @@ module.exports = {
7359
7418
}
7360
7419
} ;
7361
7420
7362
- } , { } ] , 113 :[ function ( require , module , exports ) {
7421
+ } , { } ] , 115 :[ function ( require , module , exports ) {
7363
7422
/*!
7364
7423
* Copyright (C) 2017 Glayzzle (BSD3 License)
7365
7424
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -7455,7 +7514,7 @@ module.exports = {
7455
7514
}
7456
7515
} ;
7457
7516
7458
- } , { } ] , 114 :[ function ( require , module , exports ) {
7517
+ } , { } ] , 116 :[ function ( require , module , exports ) {
7459
7518
/*!
7460
7519
* Copyright (C) 2017 Glayzzle (BSD3 License)
7461
7520
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -7501,7 +7560,7 @@ module.exports = {
7501
7560
}
7502
7561
} ;
7503
7562
7504
- } , { } ] , 115 :[ function ( require , module , exports ) {
7563
+ } , { } ] , 117 :[ function ( require , module , exports ) {
7505
7564
/*!
7506
7565
* Defines a list of helper functions for parsing
7507
7566
* Copyright (C) 2017 Glayzzle (BSD3 License)
@@ -7623,7 +7682,7 @@ module.exports = {
7623
7682
7624
7683
} ;
7625
7684
7626
- } , { } ] , 116 :[ function ( require , module , exports ) {
7685
+ } , { } ] , 118 :[ function ( require , module , exports ) {
7627
7686
/*!
7628
7687
* Copyright (C) 2017 Glayzzle (BSD3 License)
7629
7688
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -7918,7 +7977,7 @@ module.exports = {
7918
7977
}
7919
7978
} ;
7920
7979
7921
- } , { } ] , 117 :[ function ( require , module , exports ) {
7980
+ } , { } ] , 119 :[ function ( require , module , exports ) {
7922
7981
/*!
7923
7982
* Copyright (C) 2017 Glayzzle (BSD3 License)
7924
7983
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
@@ -8388,4 +8447,4 @@ engine.prototype.tokenGetAll = function(buffer) {
8388
8447
// exports the function
8389
8448
module . exports = engine ;
8390
8449
8391
- } , { "./ast" :2 , "./lexer" :92 , "./parser" :101 , "./tokens" :117 } ] } , { } , [ ] ) ;
8450
+ } , { "./ast" :2 , "./lexer" :94 , "./parser" :103 , "./tokens" :119 } ] } , { } , [ ] ) ;
0 commit comments