Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ lexer.prototype.next = function () {

// extends the lexer with states
[
require("./lexer/attribute.js"),
require("./lexer/comments.js"),
require("./lexer/initial.js"),
require("./lexer/numbers.js"),
Expand Down
41 changes: 41 additions & 0 deletions src/lexer/attribute.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright (C) 2018 Glayzzle (BSD3 License)
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
* @url http://glayzzle.com
*/
"use strict";

module.exports = {
matchST_ATTRIBUTE: function () {
const ch = this.input();
// console.log("Char:", ch);
if (this.is_LABEL_START()) {
this.consume_LABEL();
return this.tok.T_STRING;
}

if (ch === "]") {
this.popState();
return "]";
} else if (ch === "(") {
return this.consume_TOKEN();
// return "(";
} else if (ch === ":") {
return this.consume_TOKEN();
} else if (ch === ")") {
return this.consume_TOKEN();
} else if (ch === ",") {
return ch;
} else if (ch === '"') {
return this.ST_DOUBLE_QUOTES();
} else if (ch === "'") {
return this.T_CONSTANT_ENCAPSED_STRING();
} else if (this.is_NUM()) {
return this.consume_NUM();
} else if (this.is_TABSPACE()) {
return this.consume_TABSPACE();
}

throw new Error("what now?");
},
};
5 changes: 5 additions & 0 deletions src/lexer/scripting.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ module.exports = {
case "\r\n":
return this.T_WHITESPACE();
case "#":
if (this._input[this.offset] === "[") {
this.input();
this.begin("ST_ATTRIBUTE");
return this.tok.T_ATTRIBUTE;
}
return this.T_COMMENT();
case "/":
if (this._input[this.offset] === "/") {
Expand Down
2 changes: 2 additions & 0 deletions src/tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ module.exports = {
235: "T_FN",
236: "T_NULLSAFE_OBJECT_OPERATOR",
237: "T_MATCH",
238: "T_ATTRIBUTE",
},
names: {
T_HALT_COMPILER: 101,
Expand Down Expand Up @@ -287,5 +288,6 @@ module.exports = {
T_FN: 235,
T_NULLSAFE_OBJECT_OPERATOR: 236,
T_MATCH: 237,
T_ATTRIBUTE: 238,
},
};