Skip to content

Commit 5a8c158

Browse files
committed
fix backtips shell implementation + add tests
1 parent fac4993 commit 5a8c158

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

src/parser/expr.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,9 @@ module.exports = function(api, tokens, EOF) {
9696
}
9797

9898
case '`':
99-
var expr = null;
99+
// https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L1048
100100
var result = this.node('sys');
101-
if (this.next().token === tokens.T_ENCAPSED_AND_WHITESPACE) {
102-
expr = this.text();
103-
this.next().expect('`').next();
104-
} else if (this.token !== '`' ) {
105-
expr = this.read_encaps_list();
106-
}
101+
var expr = this.next().read_encapsed_string('`');
107102
return result('shell', expr);
108103

109104
case tokens.T_LIST:

src/parser/scalar.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,5 @@ module.exports = function(api, tokens, EOF) {
170170
this.next();
171171
return ['magic', '@todo:' + name];
172172
}
173-
/**
174-
* @todo
175-
*/
176-
,read_encaps_list: function() {
177-
return this.next().token;
178-
}
179173
};
180174
};

test/parser/expr.parser

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
Test expr parser
22
--PASS--
3+
class foo {
4+
function aa() {
5+
$parent_resource = " in '$this->parent->template_resource}'";
6+
}
7+
}
8+
--PASS--
39
$a = 1 + 2;
410
$a++;
511
$a--;
@@ -41,11 +47,20 @@ $b = @eval($arg);
4147
--PASS--
4248
$a = (int)$b;
4349
$a = (double)$b;
50+
$a = (unset)$b;
51+
$a = (bool)$b;
4452
$a = (string)$b;
4553
$a = (array)$b;
4654
$a = (object)$b;
4755
print 'done';
4856
exit(0);
57+
exit;
58+
--PASS--
59+
$var = new class extends foo {
60+
};
61+
list(list($a, $b), $c) = [
62+
[1, 2], 3
63+
];
4964
--PASS--
5065
echo "test: {$this->test->foo}";
5166
$var = &new foo();
@@ -58,8 +73,4 @@ $var .= $a;
5873
$var &= $a;
5974
$var |= $a;
6075
--PASS--
61-
class foo {
62-
function aa() {
63-
$parent_resource = " in '$this->parent->template_resource}'";
64-
}
65-
}
76+
$exec = `pstree -ap $process {$foo->bar}`;

0 commit comments

Comments
 (0)