Fix bin/publish: copy docs.dist from project root

Fix bin/publish: use correct .env path for rspade_system
Fix bin/publish script: prevent grep exit code 1 from terminating script

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-10-21 02:08:33 +00:00
commit f6fac6c4bc
79758 changed files with 10547827 additions and 0 deletions

85
node_modules/php-parser/src/lexer/attribute.js generated vendored Executable file
View File

@@ -0,0 +1,85 @@
/**
* Copyright (C) 2018 Glayzzle (BSD3 License)
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
* @url http://glayzzle.com
*/
"use strict";
module.exports = {
attributeIndex: 0,
attributeListDepth: {},
matchST_ATTRIBUTE() {
let ch = this.input();
if (this.is_WHITESPACE()) {
do {
ch = this.input();
} while (this.is_WHITESPACE());
this.unput(1);
return null;
}
switch (ch) {
case "]":
if (this.attributeListDepth[this.attributeIndex] === 0) {
delete this.attributeListDepth[this.attributeIndex];
this.attributeIndex--;
this.popState();
} else {
/* istanbul ignore next */
this.attributeListDepth[this.attributeIndex]--;
}
return "]";
case "(":
case ")":
case ":":
case "=":
case "|":
case "&":
case "^":
case "-":
case "+":
case "*":
case "%":
case "~":
case "<":
case ">":
case "!":
case ".":
return this.consume_TOKEN();
case "[":
this.attributeListDepth[this.attributeIndex]++;
return "[";
case ",":
return ",";
case '"':
return this.ST_DOUBLE_QUOTES();
case "'":
return this.T_CONSTANT_ENCAPSED_STRING();
case "/":
if (this._input[this.offset] === "/") {
return this.T_COMMENT();
} else if (this._input[this.offset] === "*") {
this.input();
return this.T_DOC_COMMENT();
} else {
return this.consume_TOKEN();
}
}
if (this.is_LABEL_START() || ch === "\\") {
while (this.offset < this.size) {
const ch = this.input();
if (!(this.is_LABEL() || ch === "\\")) {
if (ch) this.unput(1);
break;
}
}
return this.T_STRING();
} else if (this.is_NUM()) {
return this.consume_NUM();
}
/* istanbul ignore next */
throw new Error(
`Bad terminal sequence "${ch}" at line ${this.yylineno} (offset ${this.offset})`,
);
},
};

63
node_modules/php-parser/src/lexer/comments.js generated vendored Executable file
View File

@@ -0,0 +1,63 @@
/**
* Copyright (C) 2018 Glayzzle (BSD3 License)
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
* @url http://glayzzle.com
*/
"use strict";
module.exports = {
/*
* Reads a single line comment
*/
T_COMMENT() {
while (this.offset < this.size) {
const ch = this.input();
if (ch === "\n" || ch === "\r") {
return this.tok.T_COMMENT;
} else if (
ch === "?" &&
!this.aspTagMode &&
this._input[this.offset] === ">"
) {
this.unput(1);
return this.tok.T_COMMENT;
} else if (
ch === "%" &&
this.aspTagMode &&
this._input[this.offset] === ">"
) {
this.unput(1);
return this.tok.T_COMMENT;
}
}
return this.tok.T_COMMENT;
},
/*
* Behaviour : https://github.com/php/php-src/blob/master/Zend/zend_language_scanner.l#L1927
*/
T_DOC_COMMENT() {
let ch = this.input();
let token = this.tok.T_COMMENT;
if (ch === "*") {
// started with '/*' , check is next is '*'
ch = this.input();
if (this.is_WHITESPACE()) {
// check if next is WHITESPACE
token = this.tok.T_DOC_COMMENT;
}
if (ch === "/") {
return token;
} else {
this.unput(1); // reset
}
}
while (this.offset < this.size) {
ch = this.input();
if (ch === "*" && this._input[this.offset] === "/") {
this.input();
break;
}
}
return token;
},
};

64
node_modules/php-parser/src/lexer/initial.js generated vendored Executable file
View File

@@ -0,0 +1,64 @@
/**
* Copyright (C) 2018 Glayzzle (BSD3 License)
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
* @url http://glayzzle.com
*/
"use strict";
module.exports = {
nextINITIAL() {
if (
this.conditionStack.length > 1 &&
this.conditionStack[this.conditionStack.length - 1] === "INITIAL"
) {
// Return to HEREDOC/ST_DOUBLE_QUOTES mode
this.popState();
} else {
this.begin("ST_IN_SCRIPTING");
}
return this;
},
matchINITIAL() {
while (this.offset < this.size) {
let ch = this.input();
if (ch == "<") {
ch = this.ahead(1);
if (ch == "?") {
if (this.tryMatch("?=")) {
this.unput(1)
.appendToken(this.tok.T_OPEN_TAG_WITH_ECHO, 3)
.nextINITIAL();
break;
} else if (this.tryMatchCaseless("?php")) {
ch = this._input[this.offset + 4];
if (ch === " " || ch === "\t" || ch === "\n" || ch === "\r") {
this.unput(1).appendToken(this.tok.T_OPEN_TAG, 6).nextINITIAL();
break;
}
}
if (this.short_tags) {
this.unput(1).appendToken(this.tok.T_OPEN_TAG, 2).nextINITIAL();
break;
}
} else if (this.asp_tags && ch == "%") {
if (this.tryMatch("%=")) {
this.aspTagMode = true;
this.unput(1)
.appendToken(this.tok.T_OPEN_TAG_WITH_ECHO, 3)
.nextINITIAL();
break;
} else {
this.aspTagMode = true;
this.unput(1).appendToken(this.tok.T_OPEN_TAG, 2).nextINITIAL();
break;
}
}
}
}
if (this.yytext.length > 0) {
return this.tok.T_INLINE_HTML;
} else {
return false;
}
},
};

171
node_modules/php-parser/src/lexer/numbers.js generated vendored Executable file
View File

@@ -0,0 +1,171 @@
/**
* Copyright (C) 2018 Glayzzle (BSD3 License)
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
* @url http://glayzzle.com
*/
"use strict";
/* istanbul ignore else */
let MAX_LENGTH_OF_LONG = 10;
let long_min_digits = "2147483648";
if (process.arch == "x64") {
MAX_LENGTH_OF_LONG = 19;
long_min_digits = "9223372036854775808";
}
module.exports = {
consume_NUM() {
let ch = this.yytext[0];
let hasPoint = ch === ".";
if (ch === "0") {
ch = this.input();
// check if hexa
if (ch === "x" || ch === "X") {
ch = this.input();
if (ch !== "_" && this.is_HEX()) {
return this.consume_HNUM();
} else {
this.unput(ch ? 2 : 1);
}
// check binary notation
} else if (ch === "b" || ch === "B") {
ch = this.input();
if ((ch !== "_" && ch === "0") || ch === "1") {
return this.consume_BNUM();
} else {
this.unput(ch ? 2 : 1);
}
} else if (ch === "o" || ch === "O") {
ch = this.input();
if (ch !== "_" && this.is_OCTAL()) {
return this.consume_ONUM();
} else {
this.unput(ch ? 2 : 1);
}
} else if (!this.is_NUM()) {
if (ch) this.unput(1);
}
}
while (this.offset < this.size) {
const prev = ch;
ch = this.input();
if (ch === "_") {
if (prev === "_") {
// restriction : next to underscore / 1__1;
this.unput(2); // keep 1
break;
}
if (prev === ".") {
// next to decimal point "1._0"
this.unput(1); // keep 1.
break;
}
if (prev === "e" || prev === "E") {
// next to e "1e_10"
this.unput(2); // keep 1
break;
}
} else if (ch === ".") {
if (hasPoint) {
// no multiple points "1.0.5"
this.unput(1); // keep 1.0
break;
}
if (prev === "_") {
// next to decimal point "1_.0"
this.unput(2); // keep 1
break;
}
hasPoint = true;
continue;
} else if (ch === "e" || ch === "E") {
if (prev === "_") {
// next to e "1_e10"
this.unput(1);
break;
}
let undo = 2;
ch = this.input();
if (ch === "+" || ch === "-") {
// 1e-5
undo = 3;
ch = this.input();
}
if (this.is_NUM_START()) {
this.consume_LNUM();
return this.tok.T_DNUMBER;
}
this.unput(ch ? undo : undo - 1); // keep only 1
break;
}
if (!this.is_NUM()) {
// example : 10.0a
if (ch) this.unput(1); // keep 10.0
break;
}
}
if (hasPoint) {
return this.tok.T_DNUMBER;
} else if (this.yytext.length < MAX_LENGTH_OF_LONG - 1) {
return this.tok.T_LNUMBER;
} else {
if (
this.yytext.length < MAX_LENGTH_OF_LONG ||
(this.yytext.length == MAX_LENGTH_OF_LONG &&
this.yytext < long_min_digits)
) {
return this.tok.T_LNUMBER;
}
return this.tok.T_DNUMBER;
}
},
// read hexa
consume_HNUM() {
while (this.offset < this.size) {
const ch = this.input();
if (!this.is_HEX()) {
if (ch) this.unput(1);
break;
}
}
return this.tok.T_LNUMBER;
},
// read a generic number
consume_LNUM() {
while (this.offset < this.size) {
const ch = this.input();
if (!this.is_NUM()) {
if (ch) this.unput(1);
break;
}
}
return this.tok.T_LNUMBER;
},
// read binary
consume_BNUM() {
let ch;
while (this.offset < this.size) {
ch = this.input();
if (ch !== "0" && ch !== "1" && ch !== "_") {
if (ch) this.unput(1);
break;
}
}
return this.tok.T_LNUMBER;
},
// read an octal number
consume_ONUM() {
while (this.offset < this.size) {
const ch = this.input();
if (!this.is_OCTAL()) {
if (ch) this.unput(1);
break;
}
}
return this.tok.T_LNUMBER;
},
};

96
node_modules/php-parser/src/lexer/property.js generated vendored Executable file
View File

@@ -0,0 +1,96 @@
/**
* Copyright (C) 2018 Glayzzle (BSD3 License)
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
* @url http://glayzzle.com
*/
"use strict";
module.exports = {
matchST_LOOKING_FOR_PROPERTY() {
let ch = this.input();
if (ch === "-") {
ch = this.input();
if (ch === ">") {
// https://github.com/php/php-src/blob/master/Zend/zend_language_scanner.l#L1296
return this.tok.T_OBJECT_OPERATOR;
}
if (ch) this.unput(1);
} else if (this.is_WHITESPACE()) {
return this.tok.T_WHITESPACE;
} else if (this.is_LABEL_START()) {
// https://github.com/php/php-src/blob/master/Zend/zend_language_scanner.l#L1300
this.consume_LABEL();
this.popState();
return this.tok.T_STRING;
}
// https://github.com/php/php-src/blob/master/Zend/zend_language_scanner.l#L1306
this.popState();
if (ch) this.unput(1);
return false;
},
matchST_LOOKING_FOR_VARNAME() {
let ch = this.input();
// SHIFT STATE
this.popState();
this.begin("ST_IN_SCRIPTING");
if (this.is_LABEL_START()) {
this.consume_LABEL();
ch = this.input();
if (ch === "[" || ch === "}") {
this.unput(1);
return this.tok.T_STRING_VARNAME;
} else {
// any char (that's started with a label sequence)
this.unput(this.yytext.length);
}
} else {
// any char (thats not a label start sequence)
if (ch) this.unput(1);
}
// stops looking for a varname and starts the scripting mode
return false;
},
matchST_VAR_OFFSET() {
const ch = this.input();
if (this.is_NUM_START()) {
this.consume_NUM();
return this.tok.T_NUM_STRING;
} else if (ch === "]") {
this.popState();
return "]";
} else if (ch === "$") {
this.input();
if (this.is_LABEL_START()) {
this.consume_LABEL();
return this.tok.T_VARIABLE;
} else {
/* istanbul ignore next */
throw new Error("Unexpected terminal");
}
} else if (this.is_LABEL_START()) {
this.consume_LABEL();
return this.tok.T_STRING;
} else if (
this.is_WHITESPACE() ||
ch === "\\" ||
ch === "'" ||
ch === "#"
) {
return this.tok.T_ENCAPSED_AND_WHITESPACE;
} else if (
ch === "[" ||
ch === "{" ||
ch === "}" ||
ch === '"' ||
ch === "`" ||
this.is_TOKEN()
) {
return ch;
} else {
/* istanbul ignore next */
throw new Error("Unexpected terminal");
}
},
};

114
node_modules/php-parser/src/lexer/scripting.js generated vendored Executable file
View File

@@ -0,0 +1,114 @@
/**
* Copyright (C) 2018 Glayzzle (BSD3 License)
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
* @url http://glayzzle.com
*/
"use strict";
module.exports = {
matchST_IN_SCRIPTING() {
let ch = this.input();
switch (ch) {
case " ":
case "\t":
case "\n":
case "\r":
case "\r\n":
return this.T_WHITESPACE();
case "#":
if (this.version >= 800 && this._input[this.offset] === "[") {
this.input();
this.attributeListDepth[++this.attributeIndex] = 0;
this.begin("ST_ATTRIBUTE");
return this.tok.T_ATTRIBUTE;
}
return this.T_COMMENT();
case "/":
if (this._input[this.offset] === "/") {
return this.T_COMMENT();
} else if (this._input[this.offset] === "*") {
this.input();
return this.T_DOC_COMMENT();
}
return this.consume_TOKEN();
case "'":
return this.T_CONSTANT_ENCAPSED_STRING();
case '"':
return this.ST_DOUBLE_QUOTES();
case "`":
this.begin("ST_BACKQUOTE");
return "`";
case "?":
if (!this.aspTagMode && this.tryMatch(">")) {
this.input();
const nextCH = this._input[this.offset];
if (nextCH === "\n" || nextCH === "\r") this.input();
if (this.conditionStack.length > 1) {
this.begin("INITIAL");
}
return this.tok.T_CLOSE_TAG;
}
return this.consume_TOKEN();
case "%":
if (this.aspTagMode && this._input[this.offset] === ">") {
this.input(); // consume the '>'
ch = this._input[this.offset]; // read next
if (ch === "\n" || ch === "\r") {
this.input(); // consume the newline
}
this.aspTagMode = false;
if (this.conditionStack.length > 1) {
this.begin("INITIAL");
}
return this.tok.T_CLOSE_TAG;
}
return this.consume_TOKEN();
case "{":
this.begin("ST_IN_SCRIPTING");
return "{";
case "}":
if (this.conditionStack.length > 2) {
// Return to HEREDOC/ST_DOUBLE_QUOTES mode
this.popState();
}
return "}";
default:
if (ch === ".") {
ch = this.input();
if (this.is_NUM_START()) {
return this.consume_NUM();
} else {
if (ch) this.unput(1);
}
}
if (this.is_NUM_START()) {
return this.consume_NUM();
} else if (this.is_LABEL_START()) {
return this.consume_LABEL().T_STRING();
} else if (this.is_TOKEN()) {
return this.consume_TOKEN();
}
}
throw new Error(
'Bad terminal sequence "' +
ch +
'" at line ' +
this.yylineno +
" (offset " +
this.offset +
")",
);
},
T_WHITESPACE() {
while (this.offset < this.size) {
const ch = this.input();
if (ch === " " || ch === "\t" || ch === "\n" || ch === "\r") {
continue;
}
if (ch) this.unput(1);
break;
}
return this.tok.T_WHITESPACE;
},
};

524
node_modules/php-parser/src/lexer/strings.js generated vendored Executable file
View File

@@ -0,0 +1,524 @@
/**
* Copyright (C) 2018 Glayzzle (BSD3 License)
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
* @url http://glayzzle.com
*/
"use strict";
const newline = ["\n", "\r"];
const valid_after_heredoc = ["\n", "\r", ";"];
const valid_after_heredoc_73 = valid_after_heredoc.concat([
"\t",
" ",
",",
"]",
")",
"/",
"=",
"!",
".",
]);
module.exports = {
T_CONSTANT_ENCAPSED_STRING() {
let ch;
while (this.offset < this.size) {
ch = this.input();
if (ch == "\\") {
this.input();
} else if (ch == "'") {
break;
}
}
return this.tok.T_CONSTANT_ENCAPSED_STRING;
},
// check if matching a HEREDOC state
is_HEREDOC() {
const revert = this.offset;
if (
this._input[this.offset - 1] === "<" &&
this._input[this.offset] === "<" &&
this._input[this.offset + 1] === "<"
) {
this.offset += 3;
// optional tabs / spaces
if (this.is_TABSPACE()) {
while (this.offset < this.size) {
this.offset++;
if (!this.is_TABSPACE()) {
break;
}
}
}
// optional quotes
let tChar = this._input[this.offset - 1];
if (tChar === "'" || tChar === '"') {
this.offset++;
} else {
tChar = null;
}
// required label
if (this.is_LABEL_START()) {
let yyoffset = this.offset - 1;
while (this.offset < this.size) {
this.offset++;
if (!this.is_LABEL()) {
break;
}
}
const yylabel = this._input.substring(yyoffset, this.offset - 1);
if (!tChar || tChar === this._input[this.offset - 1]) {
// required ending quote
if (tChar) this.offset++;
// require newline
if (newline.includes(this._input[this.offset - 1])) {
// go go go
this.heredoc_label.label = yylabel;
this.heredoc_label.length = yylabel.length;
this.heredoc_label.finished = false;
yyoffset = this.offset - revert;
this.offset = revert;
this.consume(yyoffset);
if (tChar === "'") {
this.begin("ST_NOWDOC");
} else {
this.begin("ST_HEREDOC");
}
// prematch to get the indentation information from end of doc
this.prematch_ENDOFDOC();
return this.tok.T_START_HEREDOC;
}
}
}
}
this.offset = revert;
return false;
},
ST_DOUBLE_QUOTES() {
let ch;
while (this.offset < this.size) {
ch = this.input();
if (ch == "\\") {
this.input();
} else if (ch == '"') {
break;
} else if (ch == "$") {
ch = this.input();
if (ch == "{" || this.is_LABEL_START()) {
this.unput(2);
break;
}
if (ch) this.unput(1);
} else if (ch == "{") {
ch = this.input();
if (ch == "$") {
this.unput(2);
break;
}
if (ch) this.unput(1);
}
}
if (ch == '"') {
return this.tok.T_CONSTANT_ENCAPSED_STRING;
} else {
let prefix = 1;
if (this.yytext[0] === "b" || this.yytext[0] === "B") {
prefix = 2;
}
if (this.yytext.length > 2) {
this.appendToken(
this.tok.T_ENCAPSED_AND_WHITESPACE,
this.yytext.length - prefix,
);
}
this.unput(this.yytext.length - prefix);
this.begin("ST_DOUBLE_QUOTES");
return this.yytext;
}
},
// check if its a DOC end sequence
isDOC_MATCH(offset, consumeLeadingSpaces) {
// @fixme : check if out of text limits
// consumeLeadingSpaces is false happen DOC prematch END HEREDOC stage.
// Ensure current state is really after a new line break, not after a such as ${variables}
const prev_ch = this._input[offset - 2];
if (!newline.includes(prev_ch)) {
return false;
}
// skip leading spaces or tabs
let indentation_uses_spaces = false;
let indentation_uses_tabs = false;
// reset heredoc_label structure
let indentation = 0;
let leading_ch = this._input[offset - 1];
if (this.version >= 703) {
while (leading_ch === "\t" || leading_ch === " ") {
if (leading_ch === " ") {
indentation_uses_spaces = true;
} else if (leading_ch === "\t") {
indentation_uses_tabs = true;
}
leading_ch = this._input[offset + indentation];
indentation++;
}
// Move offset to skip leading whitespace
offset = offset + indentation;
// return out if there was only whitespace on this line
if (newline.includes(this._input[offset - 1])) {
return false;
}
}
if (
this._input.substring(
offset - 1,
offset - 1 + this.heredoc_label.length,
) === this.heredoc_label.label
) {
const ch = this._input[offset - 1 + this.heredoc_label.length];
if (
(this.version >= 703
? valid_after_heredoc_73
: valid_after_heredoc
).includes(ch)
) {
if (consumeLeadingSpaces) {
this.consume(indentation);
// https://wiki.php.net/rfc/flexible_heredoc_nowdoc_syntaxes
if (indentation_uses_spaces && indentation_uses_tabs) {
throw new Error(
"Parse error: mixing spaces and tabs in ending marker at line " +
this.yylineno +
" (offset " +
this.offset +
")",
);
}
} else {
// Called in prematch_ENDOFDOC
this.heredoc_label.indentation = indentation;
this.heredoc_label.indentation_uses_spaces = indentation_uses_spaces;
this.heredoc_label.first_encaps_node = true;
}
return true;
}
}
return false;
},
/*
* Prematch the end of HEREDOC/NOWDOC end tag to preset the
* context of this.heredoc_label
*/
prematch_ENDOFDOC() {
// reset heredoc
this.heredoc_label.indentation_uses_spaces = false;
this.heredoc_label.indentation = 0;
this.heredoc_label.first_encaps_node = true;
let offset = this.offset + 1;
while (offset < this._input.length) {
// if match heredoc_label structrue will be set
if (this.isDOC_MATCH(offset, false)) {
return;
}
if (!newline.includes(this._input[offset - 1])) {
// skip one line
while (
!newline.includes(this._input[offset++]) &&
offset < this._input.length
) {
// skip
}
}
offset++;
}
},
matchST_NOWDOC() {
// edge case : empty now doc
if (this.isDOC_MATCH(this.offset, true)) {
// @fixme : never reached (may be caused by quotes)
this.consume(this.heredoc_label.length);
this.popState();
return this.tok.T_END_HEREDOC;
}
// SCANNING CONTENTS
let ch = this._input[this.offset - 1];
while (this.offset < this.size) {
if (newline.includes(ch)) {
ch = this.input();
if (this.isDOC_MATCH(this.offset, true)) {
this.unput(1).popState();
this.appendToken(this.tok.T_END_HEREDOC, this.heredoc_label.length);
return this.tok.T_ENCAPSED_AND_WHITESPACE;
}
} else {
ch = this.input();
}
}
// too bad ! reached end of document (will get a parse error)
return this.tok.T_ENCAPSED_AND_WHITESPACE;
},
matchST_HEREDOC() {
// edge case : empty here doc
let ch = this.input();
if (this.isDOC_MATCH(this.offset, true)) {
this.consume(this.heredoc_label.length - 1);
this.popState();
return this.tok.T_END_HEREDOC;
}
// SCANNING CONTENTS
while (this.offset < this.size) {
if (ch === "\\") {
ch = this.input(); // ignore next
if (!newline.includes(ch)) {
ch = this.input();
}
}
if (newline.includes(ch)) {
ch = this.input();
if (this.isDOC_MATCH(this.offset, true)) {
this.unput(1).popState();
this.appendToken(this.tok.T_END_HEREDOC, this.heredoc_label.length);
return this.tok.T_ENCAPSED_AND_WHITESPACE;
}
} else if (ch === "$") {
ch = this.input();
if (ch === "{") {
// start of ${
this.begin("ST_LOOKING_FOR_VARNAME");
if (this.yytext.length > 2) {
this.appendToken(this.tok.T_DOLLAR_OPEN_CURLY_BRACES, 2);
this.unput(2);
return this.tok.T_ENCAPSED_AND_WHITESPACE;
} else {
return this.tok.T_DOLLAR_OPEN_CURLY_BRACES;
}
} else if (this.is_LABEL_START()) {
// start of $var...
const yyoffset = this.offset;
const next = this.consume_VARIABLE();
if (this.yytext.length > this.offset - yyoffset + 2) {
this.appendToken(next, this.offset - yyoffset + 2);
this.unput(this.offset - yyoffset + 2);
return this.tok.T_ENCAPSED_AND_WHITESPACE;
} else {
return next;
}
//console.log(this.yytext);
}
} else if (ch === "{") {
ch = this.input();
if (ch === "$") {
// start of {$...
this.begin("ST_IN_SCRIPTING");
if (this.yytext.length > 2) {
this.appendToken(this.tok.T_CURLY_OPEN, 1);
this.unput(2);
return this.tok.T_ENCAPSED_AND_WHITESPACE;
} else {
this.unput(1);
return this.tok.T_CURLY_OPEN;
}
}
} else {
ch = this.input();
}
}
// too bad ! reached end of document (will get a parse error)
return this.tok.T_ENCAPSED_AND_WHITESPACE;
},
consume_VARIABLE() {
this.consume_LABEL();
const ch = this.input();
if (ch == "[") {
this.unput(1);
this.begin("ST_VAR_OFFSET");
return this.tok.T_VARIABLE;
} else if (ch === "-") {
if (this.input() === ">") {
this.input();
if (this.is_LABEL_START()) {
this.begin("ST_LOOKING_FOR_PROPERTY");
}
this.unput(3);
return this.tok.T_VARIABLE;
} else {
this.unput(2);
}
} else {
if (ch) this.unput(1);
}
return this.tok.T_VARIABLE;
},
// HANDLES BACKQUOTES
matchST_BACKQUOTE() {
let ch = this.input();
if (ch === "$") {
ch = this.input();
if (ch === "{") {
this.begin("ST_LOOKING_FOR_VARNAME");
return this.tok.T_DOLLAR_OPEN_CURLY_BRACES;
} else if (this.is_LABEL_START()) {
const tok = this.consume_VARIABLE();
return tok;
}
} else if (ch === "{") {
if (this._input[this.offset] === "$") {
this.begin("ST_IN_SCRIPTING");
return this.tok.T_CURLY_OPEN;
}
} else if (ch === "`") {
this.popState();
return "`";
}
// any char
while (this.offset < this.size) {
if (ch === "\\") {
this.input();
} else if (ch === "`") {
this.unput(1);
this.popState();
this.appendToken("`", 1);
break;
} else if (ch === "$") {
ch = this.input();
if (ch === "{") {
this.begin("ST_LOOKING_FOR_VARNAME");
if (this.yytext.length > 2) {
this.appendToken(this.tok.T_DOLLAR_OPEN_CURLY_BRACES, 2);
this.unput(2);
return this.tok.T_ENCAPSED_AND_WHITESPACE;
} else {
return this.tok.T_DOLLAR_OPEN_CURLY_BRACES;
}
} else if (this.is_LABEL_START()) {
// start of $var...
const yyoffset = this.offset;
const next = this.consume_VARIABLE();
if (this.yytext.length > this.offset - yyoffset + 2) {
this.appendToken(next, this.offset - yyoffset + 2);
this.unput(this.offset - yyoffset + 2);
return this.tok.T_ENCAPSED_AND_WHITESPACE;
} else {
return next;
}
}
continue;
} else if (ch === "{") {
ch = this.input();
if (ch === "$") {
// start of {$...
this.begin("ST_IN_SCRIPTING");
if (this.yytext.length > 2) {
this.appendToken(this.tok.T_CURLY_OPEN, 1);
this.unput(2);
return this.tok.T_ENCAPSED_AND_WHITESPACE;
} else {
this.unput(1);
return this.tok.T_CURLY_OPEN;
}
}
continue;
}
ch = this.input();
}
return this.tok.T_ENCAPSED_AND_WHITESPACE;
},
matchST_DOUBLE_QUOTES() {
let ch = this.input();
if (ch === "$") {
ch = this.input();
if (ch === "{") {
this.begin("ST_LOOKING_FOR_VARNAME");
return this.tok.T_DOLLAR_OPEN_CURLY_BRACES;
} else if (this.is_LABEL_START()) {
const tok = this.consume_VARIABLE();
return tok;
}
} else if (ch === "{") {
if (this._input[this.offset] === "$") {
this.begin("ST_IN_SCRIPTING");
return this.tok.T_CURLY_OPEN;
}
} else if (ch === '"') {
this.popState();
return '"';
}
// any char
while (this.offset < this.size) {
if (ch === "\\") {
this.input();
} else if (ch === '"') {
this.unput(1);
this.popState();
this.appendToken('"', 1);
break;
} else if (ch === "$") {
ch = this.input();
if (ch === "{") {
this.begin("ST_LOOKING_FOR_VARNAME");
if (this.yytext.length > 2) {
this.appendToken(this.tok.T_DOLLAR_OPEN_CURLY_BRACES, 2);
this.unput(2);
return this.tok.T_ENCAPSED_AND_WHITESPACE;
} else {
return this.tok.T_DOLLAR_OPEN_CURLY_BRACES;
}
} else if (this.is_LABEL_START()) {
// start of $var...
const yyoffset = this.offset;
const next = this.consume_VARIABLE();
if (this.yytext.length > this.offset - yyoffset + 2) {
this.appendToken(next, this.offset - yyoffset + 2);
this.unput(this.offset - yyoffset + 2);
return this.tok.T_ENCAPSED_AND_WHITESPACE;
} else {
return next;
}
}
if (ch) this.unput(1);
} else if (ch === "{") {
ch = this.input();
if (ch === "$") {
// start of {$...
this.begin("ST_IN_SCRIPTING");
if (this.yytext.length > 2) {
this.appendToken(this.tok.T_CURLY_OPEN, 1);
this.unput(2);
return this.tok.T_ENCAPSED_AND_WHITESPACE;
} else {
// @fixme : yytext = '"{$' (this.yytext.length > 3)
this.unput(1);
return this.tok.T_CURLY_OPEN;
}
}
if (ch) this.unput(1);
}
ch = this.input();
}
return this.tok.T_ENCAPSED_AND_WHITESPACE;
},
};

356
node_modules/php-parser/src/lexer/tokens.js generated vendored Executable file
View File

@@ -0,0 +1,356 @@
/**
* Copyright (C) 2018 Glayzzle (BSD3 License)
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
* @url http://glayzzle.com
*/
"use strict";
module.exports = {
T_STRING() {
const token = this.yytext.toLowerCase();
let id = this.keywords[token];
if (typeof id !== "number") {
if (token === "yield") {
if (this.version >= 700 && this.tryMatch(" from")) {
this.consume(5);
id = this.tok.T_YIELD_FROM;
} else {
id = this.tok.T_YIELD;
}
} else {
id = this.tok.T_STRING;
if (token === "b" || token === "B") {
const ch = this.input();
if (ch === '"') {
return this.ST_DOUBLE_QUOTES();
} else if (ch === "'") {
return this.T_CONSTANT_ENCAPSED_STRING();
} else if (ch) {
this.unput(1);
}
}
}
}
// https://github.com/php/php-src/blob/master/Zend/zend_language_scanner.l#L1546
if (id === this.tok.T_ENUM) {
if (this.version < 801) {
return this.tok.T_STRING;
}
const initial = this.offset;
let ch = this.input();
while (ch == " ") {
ch = this.input();
}
let isEnum = false;
if (this.is_LABEL_START()) {
while (this.is_LABEL()) {
ch += this.input();
}
const label = ch.slice(0, -1).toLowerCase();
isEnum = label !== "extends" && label !== "implements";
}
this.unput(this.offset - initial);
return isEnum ? this.tok.T_ENUM : this.tok.T_STRING;
}
if (this.offset < this.size && id !== this.tok.T_YIELD_FROM) {
// If immediately followed by a backslash, this is a T_NAME_RELATIVE or T_NAME_QUALIFIED.
let ch = this.input();
if (ch === "\\") {
id =
token === "namespace"
? this.tok.T_NAME_RELATIVE
: this.tok.T_NAME_QUALIFIED;
do {
if (this._input[this.offset] === "{") {
// e.g. when using group use statements, the last '\\' is followed by a '{'
this.input();
break;
}
this.consume_LABEL();
ch = this.input();
} while (ch === "\\");
}
if (ch) {
this.unput(1);
}
}
return id;
},
// reads a custom token
consume_TOKEN() {
const ch = this._input[this.offset - 1];
const fn = this.tokenTerminals[ch];
if (fn) {
return fn.apply(this, []);
} else {
return this.yytext;
}
},
// list of special char tokens
tokenTerminals: {
$() {
this.offset++;
if (this.is_LABEL_START()) {
this.offset--;
this.consume_LABEL();
return this.tok.T_VARIABLE;
} else {
this.offset--;
return "$";
}
},
"-"() {
const nchar = this._input[this.offset];
if (nchar === ">") {
this.begin("ST_LOOKING_FOR_PROPERTY").input();
return this.tok.T_OBJECT_OPERATOR;
} else if (nchar === "-") {
this.input();
return this.tok.T_DEC;
} else if (nchar === "=") {
this.input();
return this.tok.T_MINUS_EQUAL;
}
return "-";
},
"\\"() {
if (this.offset < this.size) {
this.input();
if (this.is_LABEL_START()) {
let ch;
do {
if (this._input[this.offset] === "{") {
// e.g. when using group use statements, the last '\\' is followed by a '{'
this.input();
break;
}
this.consume_LABEL();
ch = this.input();
} while (ch === "\\");
this.unput(1);
return this.tok.T_NAME_FULLY_QUALIFIED;
} else {
this.unput(1);
}
}
return this.tok.T_NS_SEPARATOR;
},
"/"() {
if (this._input[this.offset] === "=") {
this.input();
return this.tok.T_DIV_EQUAL;
}
return "/";
},
":"() {
if (this._input[this.offset] === ":") {
this.input();
return this.tok.T_DOUBLE_COLON;
} else {
return ":";
}
},
"("() {
const initial = this.offset;
this.input();
if (this.is_TABSPACE()) {
this.consume_TABSPACE().input();
}
if (this.is_LABEL_START()) {
const yylen = this.yytext.length;
this.consume_LABEL();
const castToken = this.yytext.substring(yylen - 1).toLowerCase();
const castId = this.castKeywords[castToken];
if (typeof castId === "number") {
this.input();
if (this.is_TABSPACE()) {
this.consume_TABSPACE().input();
}
if (this._input[this.offset - 1] === ")") {
return castId;
}
}
}
// revert the check
this.unput(this.offset - initial);
return "(";
},
"="() {
const nchar = this._input[this.offset];
if (nchar === ">") {
this.input();
return this.tok.T_DOUBLE_ARROW;
} else if (nchar === "=") {
if (this._input[this.offset + 1] === "=") {
this.consume(2);
return this.tok.T_IS_IDENTICAL;
} else {
this.input();
return this.tok.T_IS_EQUAL;
}
}
return "=";
},
"+"() {
const nchar = this._input[this.offset];
if (nchar === "+") {
this.input();
return this.tok.T_INC;
} else if (nchar === "=") {
this.input();
return this.tok.T_PLUS_EQUAL;
}
return "+";
},
"!"() {
if (this._input[this.offset] === "=") {
if (this._input[this.offset + 1] === "=") {
this.consume(2);
return this.tok.T_IS_NOT_IDENTICAL;
} else {
this.input();
return this.tok.T_IS_NOT_EQUAL;
}
}
return "!";
},
"?"() {
if (this.version >= 700 && this._input[this.offset] === "?") {
if (this.version >= 704 && this._input[this.offset + 1] === "=") {
this.consume(2);
return this.tok.T_COALESCE_EQUAL;
} else {
this.input();
return this.tok.T_COALESCE;
}
}
if (
this.version >= 800 &&
this._input[this.offset] === "-" &&
this._input[this.offset + 1] === ">"
) {
this.consume(1);
this.begin("ST_LOOKING_FOR_PROPERTY").input();
return this.tok.T_NULLSAFE_OBJECT_OPERATOR;
}
return "?";
},
"<"() {
let nchar = this._input[this.offset];
if (nchar === "<") {
nchar = this._input[this.offset + 1];
if (nchar === "=") {
this.consume(2);
return this.tok.T_SL_EQUAL;
} else if (nchar === "<") {
if (this.is_HEREDOC()) {
return this.tok.T_START_HEREDOC;
}
}
this.input();
return this.tok.T_SL;
} else if (nchar === "=") {
this.input();
if (this.version >= 700 && this._input[this.offset] === ">") {
this.input();
return this.tok.T_SPACESHIP;
} else {
return this.tok.T_IS_SMALLER_OR_EQUAL;
}
} else if (nchar === ">") {
this.input();
return this.tok.T_IS_NOT_EQUAL;
}
return "<";
},
">"() {
let nchar = this._input[this.offset];
if (nchar === "=") {
this.input();
return this.tok.T_IS_GREATER_OR_EQUAL;
} else if (nchar === ">") {
nchar = this._input[this.offset + 1];
if (nchar === "=") {
this.consume(2);
return this.tok.T_SR_EQUAL;
} else {
this.input();
return this.tok.T_SR;
}
}
return ">";
},
"*"() {
const nchar = this._input[this.offset];
if (nchar === "=") {
this.input();
return this.tok.T_MUL_EQUAL;
} else if (nchar === "*") {
this.input();
if (this._input[this.offset] === "=") {
this.input();
return this.tok.T_POW_EQUAL;
} else {
return this.tok.T_POW;
}
}
return "*";
},
"."() {
const nchar = this._input[this.offset];
if (nchar === "=") {
this.input();
return this.tok.T_CONCAT_EQUAL;
} else if (nchar === "." && this._input[this.offset + 1] === ".") {
this.consume(2);
return this.tok.T_ELLIPSIS;
}
return ".";
},
"%"() {
if (this._input[this.offset] === "=") {
this.input();
return this.tok.T_MOD_EQUAL;
}
return "%";
},
"&"() {
const nchar = this._input[this.offset];
if (nchar === "=") {
this.input();
return this.tok.T_AND_EQUAL;
} else if (nchar === "&") {
this.input();
return this.tok.T_BOOLEAN_AND;
}
return "&";
},
"|"() {
const nchar = this._input[this.offset];
if (nchar === "=") {
this.input();
return this.tok.T_OR_EQUAL;
} else if (nchar === "|") {
this.input();
return this.tok.T_BOOLEAN_OR;
}
return "|";
},
"^"() {
if (this._input[this.offset] === "=") {
this.input();
return this.tok.T_XOR_EQUAL;
}
return "^";
},
},
};

112
node_modules/php-parser/src/lexer/utils.js generated vendored Executable file
View File

@@ -0,0 +1,112 @@
/**
* Copyright (C) 2018 Glayzzle (BSD3 License)
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
* @url http://glayzzle.com
*/
"use strict";
const tokens = ";:,.\\[]()|^&+-/*=%!~$<>?@";
module.exports = {
// check if the char can be a numeric
is_NUM() {
const ch = this._input.charCodeAt(this.offset - 1);
return (ch > 47 && ch < 58) || ch === 95;
},
// check if the char can be a numeric
is_NUM_START() {
const ch = this._input.charCodeAt(this.offset - 1);
return ch > 47 && ch < 58;
},
// check if current char can be a label
is_LABEL() {
const ch = this._input.charCodeAt(this.offset - 1);
return (
(ch > 96 && ch < 123) ||
(ch > 64 && ch < 91) ||
ch === 95 ||
(ch > 47 && ch < 58) ||
ch > 126
);
},
// check if current char can be a label
is_LABEL_START() {
const ch = this._input.charCodeAt(this.offset - 1);
// A - Z
if (ch > 64 && ch < 91) return true;
// a - z
if (ch > 96 && ch < 123) return true;
// _ (95)
if (ch === 95) return true;
// utf8 / extended
if (ch > 126) return true;
// else
return false;
},
// reads each char of the label
consume_LABEL() {
while (this.offset < this.size) {
const ch = this.input();
if (!this.is_LABEL()) {
if (ch) this.unput(1);
break;
}
}
return this;
},
// check if current char is a token char
is_TOKEN() {
const ch = this._input[this.offset - 1];
return tokens.indexOf(ch) !== -1;
},
// check if current char is a whitespace
is_WHITESPACE() {
const ch = this._input[this.offset - 1];
return ch === " " || ch === "\t" || ch === "\n" || ch === "\r";
},
// check if current char is a whitespace (without newlines)
is_TABSPACE() {
const ch = this._input[this.offset - 1];
return ch === " " || ch === "\t";
},
// consume all whitespaces (excluding newlines)
consume_TABSPACE() {
while (this.offset < this.size) {
const ch = this.input();
if (!this.is_TABSPACE()) {
if (ch) this.unput(1);
break;
}
}
return this;
},
// check if current char can be a hexadecimal number
is_HEX() {
const ch = this._input.charCodeAt(this.offset - 1);
// 0 - 9
if (ch > 47 && ch < 58) return true;
// A - F
if (ch > 64 && ch < 71) return true;
// a - f
if (ch > 96 && ch < 103) return true;
// _ (code 95)
if (ch === 95) return true;
// else
return false;
},
// check if current char can be an octal number
is_OCTAL() {
const ch = this._input.charCodeAt(this.offset - 1);
// 0 - 7
if (ch > 47 && ch < 56) return true;
// _ (code 95)
if (ch === 95) return true;
// else
return false;
},
};