Skip to content

Commit c4ca4c5

Browse files
committed
fix glayzzle#129 - add shortForm over <?= tags
1 parent 50929dd commit c4ca4c5

File tree

6 files changed

+19
-10
lines changed

6 files changed

+19
-10
lines changed

dist/php-parser.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,10 +1182,12 @@ var KIND = "echo";
11821182
/**
11831183
* Defines system based call
11841184
* @constructor Echo
1185+
* @property {boolean} shortForm
11851186
* @extends {Sys}
11861187
*/
1187-
var Echo = Sys.extends(function Echo(args, docs, location) {
1188+
var Echo = Sys.extends(function Echo(args, shortForm, docs, location) {
11881189
Sys.apply(this, [KIND, args, docs, location]);
1190+
this.shortForm = shortForm;
11891191
});
11901192

11911193
module.exports = Echo;
@@ -7242,9 +7244,11 @@ module.exports = {
72427244
case this.tok.T_ECHO:
72437245
{
72447246
result = this.node("echo");
7247+
var text = this.text();
7248+
var shortForm = text === '<?=' || text === '<%=';
72457249
var args = this.next().read_list(this.read_expr, ",");
72467250
this.expectEndOfStatement();
7247-
return result(args);
7251+
return result(args, shortForm);
72487252
}
72497253

72507254
case this.tok.T_OPEN_TAG_WITH_ECHO:

dist/php-parser.min.js

Lines changed: 5 additions & 5 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/ast/echo.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ const KIND = "echo";
1010
/**
1111
* Defines system based call
1212
* @constructor Echo
13+
* @property {boolean} shortForm
1314
* @extends {Sys}
1415
*/
15-
const Echo = Sys.extends(function Echo(args, docs, location) {
16+
const Echo = Sys.extends(function Echo(args, shortForm, docs, location) {
1617
Sys.apply(this, [KIND, args, docs, location]);
18+
this.shortForm = shortForm;
1719
});
1820

1921
module.exports = Echo;

src/parser/statement.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,11 @@ module.exports = {
268268

269269
case this.tok.T_ECHO: {
270270
result = this.node("echo");
271+
const text = this.text();
272+
const shortForm = (text === '<?=' || text === '<%=');
271273
const args = this.next().read_list(this.read_expr, ",");
272274
this.expectEndOfStatement();
273-
return result(args);
275+
return result(args, shortForm);
274276
}
275277

276278
case this.tok.T_OPEN_TAG_WITH_ECHO: {

test/lexerTests.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ describe("Test lexer", function() {
1818
});
1919
it("parse short echo", function() {
2020
ast.children[1].kind.should.be.exactly("echo");
21+
ast.children[1].shortForm.should.be.exactly(true);
2122
ast.children[1].arguments[0].kind.should.be.exactly("variable");
2223
ast.children[1].arguments[0].name.should.be.exactly("a");
2324
});

0 commit comments

Comments
 (0)