Skip to content

Commit a8f10d8

Browse files
committed
fix glayzzle#144 - add missing first char
1 parent ca9f957 commit a8f10d8

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

dist/php-parser.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! php-parser - BSD3 License - 2018-03-27 */
1+
/*! php-parser - BSD3 License - 2018-04-02 */
22

33
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
44
/*!
@@ -6942,7 +6942,7 @@ module.exports = {
69426942
this.expect("]") && this.next();
69436943
name = node(name, offset);
69446944
} else {
6945-
name = varName;
6945+
name = this.node("constref")(varName);
69466946
}
69476947
} else {
69486948
name = this.read_expr();
@@ -6953,6 +6953,9 @@ module.exports = {
69536953
// expression
69546954
// https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L1246
69556955
result = this.next().read_variable(false, false, false);
6956+
if (result.kind === "variable") {
6957+
result.curly = true;
6958+
}
69566959
this.expect("}") && this.next();
69576960
} else if (this.token === this.tok.T_VARIABLE) {
69586961
// plain variable
@@ -7011,7 +7014,7 @@ module.exports = {
70117014
}
70127015

70137016
this.expect(expect) && this.next();
7014-
node = node(value, this.lexer._input.substring(start, this.lexer.yylloc.first_offset), type);
7017+
node = node(value, this.lexer._input.substring(start - 1, this.lexer.yylloc.first_offset), type);
70157018

70167019
if (expect === this.tok.T_END_HEREDOC) {
70177020
node.label = this.lexer.heredoc_label;

dist/php-parser.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/php-parser.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/parser/scalar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ module.exports = {
273273
this.expect(expect) && this.next();
274274
node = node(
275275
value,
276-
this.lexer._input.substring(start, this.lexer.yylloc.first_offset),
276+
this.lexer._input.substring(start - 1, this.lexer.yylloc.first_offset),
277277
type
278278
);
279279

test/stringTests.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
var parser = require("../src/index");
22

33
describe("Test strings", function() {
4+
it("fix #144", function() {
5+
let ast = parser.parseEval('"encapsed \\\" {$var}";');
6+
ast.children[0].kind.should.be.exactly("encapsed");
7+
ast.children[0].raw.should.be.exactly("\"encapsed \\\" {$var}\"");
8+
});
49
it("fix #101", function() {
510
let ast = parser.parseEval('"encapsed {$var}";');
611
ast.children[0].value[1].kind.should.be.exactly("variable");

0 commit comments

Comments
 (0)