Skip to content

Commit

Permalink
Merge d804784 into 6e63a00
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed Aug 27, 2019
2 parents 6e63a00 + d804784 commit 0076035
Show file tree
Hide file tree
Showing 10 changed files with 1,043 additions and 36 deletions.
9 changes: 3 additions & 6 deletions src/ast.js
Expand Up @@ -323,18 +323,15 @@ AST.prototype.resolvePrecedence = function(result, parser) {
result = buffer;
}
}
} else if (
result.kind === "silent" &&
!result.expr.parenthesizedExpression
) {
if (result.expr.kind === 'assign') return result;
} else if (result.kind === "silent" && !result.expr.parenthesizedExpression) {
if (result.expr.kind === "assign") return result;
// overall least precedence
if (result.expr.right) {
buffer = result.expr;
result.expr = buffer.left;
buffer.left = result;
this.swapLocations(buffer, buffer.left, buffer.right, parser);
result = buffer;
result = buffer;
}
}
return result;
Expand Down
14 changes: 7 additions & 7 deletions src/parser/scalar.js
Expand Up @@ -96,11 +96,11 @@ module.exports = {
value = value.substring(0, value.length - 1);
}
this.expect(this.tok.T_ENCAPSED_AND_WHITESPACE) && this.next();
this.expect(this.tok.T_END_HEREDOC) && this.next();
const raw = this.lexer._input.substring(
start,
this.lexer.yylloc.last_offset
this.lexer.yylloc.first_offset
);
this.expect(this.tok.T_END_HEREDOC) && this.next();
node = node(
value,
raw,
Expand Down Expand Up @@ -266,6 +266,7 @@ module.exports = {
* Reads an encapsed string
*/
read_encapsed_string: function(expect, isBinary = false) {
const labelStart = this.lexer.yylloc.first_offset;
let node = this.node("encapsed");
this.next();
const start = this.lexer.yylloc.prev_offset - (isBinary ? 1 : 0);
Expand All @@ -284,13 +285,12 @@ module.exports = {
while (this.token !== expect && this.token !== this.EOF) {
value.push(this.read_encapsed_string_item(true));
}

this.expect(expect) && this.next();
node = node(
value,
this.lexer._input.substring(start - 1, this.lexer.yylloc.first_offset),
type
const raw = this.lexer._input.substring(
type === "heredoc" ? labelStart : start - 1,
this.lexer.yylloc.first_offset
);
node = node(value, raw, type);

if (expect === this.tok.T_END_HEREDOC) {
node.label = this.lexer.heredoc_label;
Expand Down
13 changes: 2 additions & 11 deletions test/snapshot/__snapshots__/acid.test.js.snap
Expand Up @@ -7437,7 +7437,7 @@ BAZ",
},
},
"parenthesizedExpression": true,
"raw": "
"raw": "<<<BAZ
Hello world
BAZ
",
Expand Down Expand Up @@ -7565,15 +7565,6 @@ BAR",
"raw": "<<<'BAR'
$foo + $bar
BAR
));
eval(<<<FOO
return 'This is madness!';
FOO
);
}
__halt_compiler();
THE END ...
",
"value": " $foo + $bar",
},
Expand Down Expand Up @@ -7671,7 +7662,7 @@ FOO",
"offset": 3127,
},
},
"raw": "
"raw": "<<<FOO
return 'This is madness!';
FOO
",
Expand Down

0 comments on commit 0076035

Please sign in to comment.