-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
#118 - Add support for `yield` statement
- Loading branch information
Showing
11 changed files
with
1,196 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--TEST-- | ||
Empty yield statement | ||
--SKIPIF-- | ||
<?php include(__DIR__ . '/../../skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
$code =<<<ZEP | ||
function test() { | ||
yield; | ||
} | ||
ZEP; | ||
|
||
$ir = zephir_parse_file($code, '(eval code)'); | ||
var_dump($ir[0]["statements"][0]); | ||
?> | ||
--EXPECT-- | ||
array(4) { | ||
["type"]=> | ||
string(5) "yield" | ||
["file"]=> | ||
string(11) "(eval code)" | ||
["line"]=> | ||
int(3) | ||
["char"]=> | ||
int(1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
--TEST-- | ||
Array yield statement | ||
--SKIPIF-- | ||
<?php include(__DIR__ . '/../../skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
$code =<<<ZEP | ||
function test() { | ||
yield ['key': 'value', 'another', 'val']; | ||
} | ||
ZEP; | ||
|
||
$ir = zephir_parse_file($code, '(eval code)'); | ||
var_dump($ir[0]["statements"][0]); | ||
?> | ||
--EXPECT-- | ||
array(5) { | ||
["type"]=> | ||
string(5) "yield" | ||
["expr"]=> | ||
array(5) { | ||
["type"]=> | ||
string(5) "array" | ||
["left"]=> | ||
array(3) { | ||
[0]=> | ||
array(5) { | ||
["key"]=> | ||
array(5) { | ||
["type"]=> | ||
string(4) "char" | ||
["value"]=> | ||
string(3) "key" | ||
["file"]=> | ||
string(11) "(eval code)" | ||
["line"]=> | ||
int(2) | ||
["char"]=> | ||
int(13) | ||
} | ||
["value"]=> | ||
array(5) { | ||
["type"]=> | ||
string(4) "char" | ||
["value"]=> | ||
string(5) "value" | ||
["file"]=> | ||
string(11) "(eval code)" | ||
["line"]=> | ||
int(2) | ||
["char"]=> | ||
int(21) | ||
} | ||
["file"]=> | ||
string(11) "(eval code)" | ||
["line"]=> | ||
int(2) | ||
["char"]=> | ||
int(21) | ||
} | ||
[1]=> | ||
array(4) { | ||
["value"]=> | ||
array(5) { | ||
["type"]=> | ||
string(4) "char" | ||
["value"]=> | ||
string(7) "another" | ||
["file"]=> | ||
string(11) "(eval code)" | ||
["line"]=> | ||
int(2) | ||
["char"]=> | ||
int(31) | ||
} | ||
["file"]=> | ||
string(11) "(eval code)" | ||
["line"]=> | ||
int(2) | ||
["char"]=> | ||
int(31) | ||
} | ||
[2]=> | ||
array(4) { | ||
["value"]=> | ||
array(5) { | ||
["type"]=> | ||
string(4) "char" | ||
["value"]=> | ||
string(3) "val" | ||
["file"]=> | ||
string(11) "(eval code)" | ||
["line"]=> | ||
int(2) | ||
["char"]=> | ||
int(37) | ||
} | ||
["file"]=> | ||
string(11) "(eval code)" | ||
["line"]=> | ||
int(2) | ||
["char"]=> | ||
int(37) | ||
} | ||
} | ||
["file"]=> | ||
string(11) "(eval code)" | ||
["line"]=> | ||
int(2) | ||
["char"]=> | ||
int(38) | ||
} | ||
["file"]=> | ||
string(11) "(eval code)" | ||
["line"]=> | ||
int(3) | ||
["char"]=> | ||
int(1) | ||
} |
Oops, something went wrong.