@jorgsowa/php-parser 3.2.5-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +27 -0
- package/README.md +108 -0
- package/dist/@jorgsowa/php-parser.js +11239 -0
- package/dist/@jorgsowa/php-parser.min.js +2 -0
- package/dist/@jorgsowa/php-parser.min.js.LICENSE.txt +10 -0
- package/package.json +86 -0
- package/src/ast/array.js +44 -0
- package/src/ast/arrowfunc.js +43 -0
- package/src/ast/assign.js +28 -0
- package/src/ast/assignref.js +27 -0
- package/src/ast/attrgroup.js +21 -0
- package/src/ast/attribute.js +26 -0
- package/src/ast/bin.js +27 -0
- package/src/ast/block.js +24 -0
- package/src/ast/boolean.js +23 -0
- package/src/ast/break.js +21 -0
- package/src/ast/byref.js +21 -0
- package/src/ast/call.js +26 -0
- package/src/ast/case.js +26 -0
- package/src/ast/cast.js +28 -0
- package/src/ast/catch.js +29 -0
- package/src/ast/class.js +36 -0
- package/src/ast/classconstant.js +71 -0
- package/src/ast/clone.js +21 -0
- package/src/ast/closure.js +47 -0
- package/src/ast/comment.js +23 -0
- package/src/ast/commentblock.js +22 -0
- package/src/ast/commentline.js +22 -0
- package/src/ast/constant.js +26 -0
- package/src/ast/constantstatement.js +24 -0
- package/src/ast/continue.js +24 -0
- package/src/ast/declaration.js +60 -0
- package/src/ast/declare.js +71 -0
- package/src/ast/declaredirective.js +26 -0
- package/src/ast/do.js +26 -0
- package/src/ast/echo.js +26 -0
- package/src/ast/empty.js +23 -0
- package/src/ast/encapsed.js +75 -0
- package/src/ast/encapsedpart.js +28 -0
- package/src/ast/entry.js +30 -0
- package/src/ast/enum.js +30 -0
- package/src/ast/enumcase.js +26 -0
- package/src/ast/error.js +30 -0
- package/src/ast/eval.js +24 -0
- package/src/ast/exit.js +26 -0
- package/src/ast/expression.js +20 -0
- package/src/ast/expressionstatement.js +24 -0
- package/src/ast/for.js +33 -0
- package/src/ast/foreach.js +33 -0
- package/src/ast/function.js +34 -0
- package/src/ast/global.js +24 -0
- package/src/ast/goto.js +22 -0
- package/src/ast/halt.js +22 -0
- package/src/ast/identifier.js +26 -0
- package/src/ast/if.js +30 -0
- package/src/ast/include.js +28 -0
- package/src/ast/inline.js +23 -0
- package/src/ast/interface.js +28 -0
- package/src/ast/intersectiontype.js +24 -0
- package/src/ast/isset.js +23 -0
- package/src/ast/label.js +21 -0
- package/src/ast/list.js +26 -0
- package/src/ast/literal.js +28 -0
- package/src/ast/location.js +22 -0
- package/src/ast/lookup.js +26 -0
- package/src/ast/magic.js +22 -0
- package/src/ast/match.js +26 -0
- package/src/ast/matcharm.js +26 -0
- package/src/ast/method.js +24 -0
- package/src/ast/name.js +55 -0
- package/src/ast/namedargument.js +27 -0
- package/src/ast/namespace.js +26 -0
- package/src/ast/new.js +26 -0
- package/src/ast/node.js +111 -0
- package/src/ast/noop.js +20 -0
- package/src/ast/nowdoc.js +26 -0
- package/src/ast/nullkeyword.js +20 -0
- package/src/ast/nullsafepropertylookup.js +22 -0
- package/src/ast/number.js +23 -0
- package/src/ast/offsetlookup.js +22 -0
- package/src/ast/operation.js +19 -0
- package/src/ast/parameter.js +61 -0
- package/src/ast/parentreference.js +24 -0
- package/src/ast/position.js +22 -0
- package/src/ast/post.js +26 -0
- package/src/ast/pre.js +26 -0
- package/src/ast/print.js +23 -0
- package/src/ast/program.js +32 -0
- package/src/ast/property.js +46 -0
- package/src/ast/propertyhook.js +33 -0
- package/src/ast/propertylookup.js +22 -0
- package/src/ast/propertystatement.js +59 -0
- package/src/ast/reference.js +21 -0
- package/src/ast/retif.js +28 -0
- package/src/ast/return.js +21 -0
- package/src/ast/selfreference.js +24 -0
- package/src/ast/silent.js +24 -0
- package/src/ast/statement.js +19 -0
- package/src/ast/static.js +24 -0
- package/src/ast/staticlookup.js +22 -0
- package/src/ast/staticreference.js +24 -0
- package/src/ast/staticvariable.js +26 -0
- package/src/ast/string.js +28 -0
- package/src/ast/switch.js +28 -0
- package/src/ast/throw.js +21 -0
- package/src/ast/trait.js +24 -0
- package/src/ast/traitalias.js +44 -0
- package/src/ast/traitprecedence.js +28 -0
- package/src/ast/traituse.js +26 -0
- package/src/ast/try.js +28 -0
- package/src/ast/typereference.js +40 -0
- package/src/ast/unary.js +26 -0
- package/src/ast/uniontype.js +24 -0
- package/src/ast/unset.js +23 -0
- package/src/ast/usegroup.js +30 -0
- package/src/ast/useitem.js +45 -0
- package/src/ast/variable.js +36 -0
- package/src/ast/variadic.js +25 -0
- package/src/ast/variadicplaceholder.js +24 -0
- package/src/ast/while.js +28 -0
- package/src/ast/yield.js +27 -0
- package/src/ast/yieldfrom.js +25 -0
- package/src/ast.js +593 -0
- package/src/index.js +239 -0
- package/src/lexer/attribute.js +85 -0
- package/src/lexer/comments.js +63 -0
- package/src/lexer/initial.js +64 -0
- package/src/lexer/numbers.js +171 -0
- package/src/lexer/property.js +96 -0
- package/src/lexer/scripting.js +114 -0
- package/src/lexer/strings.js +524 -0
- package/src/lexer/tokens.js +356 -0
- package/src/lexer/utils.js +112 -0
- package/src/lexer.js +561 -0
- package/src/parser/array.js +113 -0
- package/src/parser/class.js +718 -0
- package/src/parser/comment.js +52 -0
- package/src/parser/enum.js +56 -0
- package/src/parser/expr.js +848 -0
- package/src/parser/function.js +507 -0
- package/src/parser/if.js +94 -0
- package/src/parser/loops.js +168 -0
- package/src/parser/main.js +21 -0
- package/src/parser/namespace.js +231 -0
- package/src/parser/scalar.js +492 -0
- package/src/parser/statement.js +444 -0
- package/src/parser/switch.js +99 -0
- package/src/parser/try.js +43 -0
- package/src/parser/utils.js +203 -0
- package/src/parser/variable.js +363 -0
- package/src/parser.js +748 -0
- package/src/tokens.js +177 -0
- package/types.d.ts +1457 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
matchST_LOOKING_FOR_PROPERTY() {
|
|
10
|
+
let ch = this.input();
|
|
11
|
+
if (ch === "-") {
|
|
12
|
+
ch = this.input();
|
|
13
|
+
if (ch === ">") {
|
|
14
|
+
// https://github.com/php/php-src/blob/master/Zend/zend_language_scanner.l#L1296
|
|
15
|
+
return this.tok.T_OBJECT_OPERATOR;
|
|
16
|
+
}
|
|
17
|
+
if (ch) this.unput(1);
|
|
18
|
+
} else if (this.is_WHITESPACE()) {
|
|
19
|
+
return this.tok.T_WHITESPACE;
|
|
20
|
+
} else if (this.is_LABEL_START()) {
|
|
21
|
+
// https://github.com/php/php-src/blob/master/Zend/zend_language_scanner.l#L1300
|
|
22
|
+
this.consume_LABEL();
|
|
23
|
+
this.popState();
|
|
24
|
+
return this.tok.T_STRING;
|
|
25
|
+
}
|
|
26
|
+
// https://github.com/php/php-src/blob/master/Zend/zend_language_scanner.l#L1306
|
|
27
|
+
this.popState();
|
|
28
|
+
if (ch) this.unput(1);
|
|
29
|
+
return false;
|
|
30
|
+
},
|
|
31
|
+
matchST_LOOKING_FOR_VARNAME() {
|
|
32
|
+
let ch = this.input();
|
|
33
|
+
|
|
34
|
+
// SHIFT STATE
|
|
35
|
+
this.popState();
|
|
36
|
+
this.begin("ST_IN_SCRIPTING");
|
|
37
|
+
|
|
38
|
+
if (this.is_LABEL_START()) {
|
|
39
|
+
this.consume_LABEL();
|
|
40
|
+
ch = this.input();
|
|
41
|
+
if (ch === "[" || ch === "}") {
|
|
42
|
+
this.unput(1);
|
|
43
|
+
return this.tok.T_STRING_VARNAME;
|
|
44
|
+
} else {
|
|
45
|
+
// any char (that's started with a label sequence)
|
|
46
|
+
this.unput(this.yytext.length);
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
// any char (thats not a label start sequence)
|
|
50
|
+
if (ch) this.unput(1);
|
|
51
|
+
}
|
|
52
|
+
// stops looking for a varname and starts the scripting mode
|
|
53
|
+
return false;
|
|
54
|
+
},
|
|
55
|
+
matchST_VAR_OFFSET() {
|
|
56
|
+
const ch = this.input();
|
|
57
|
+
if (this.is_NUM_START()) {
|
|
58
|
+
this.consume_NUM();
|
|
59
|
+
return this.tok.T_NUM_STRING;
|
|
60
|
+
} else if (ch === "]") {
|
|
61
|
+
this.popState();
|
|
62
|
+
return "]";
|
|
63
|
+
} else if (ch === "$") {
|
|
64
|
+
this.input();
|
|
65
|
+
if (this.is_LABEL_START()) {
|
|
66
|
+
this.consume_LABEL();
|
|
67
|
+
return this.tok.T_VARIABLE;
|
|
68
|
+
} else {
|
|
69
|
+
/* istanbul ignore next */
|
|
70
|
+
throw new Error("Unexpected terminal");
|
|
71
|
+
}
|
|
72
|
+
} else if (this.is_LABEL_START()) {
|
|
73
|
+
this.consume_LABEL();
|
|
74
|
+
return this.tok.T_STRING;
|
|
75
|
+
} else if (
|
|
76
|
+
this.is_WHITESPACE() ||
|
|
77
|
+
ch === "\\" ||
|
|
78
|
+
ch === "'" ||
|
|
79
|
+
ch === "#"
|
|
80
|
+
) {
|
|
81
|
+
return this.tok.T_ENCAPSED_AND_WHITESPACE;
|
|
82
|
+
} else if (
|
|
83
|
+
ch === "[" ||
|
|
84
|
+
ch === "{" ||
|
|
85
|
+
ch === "}" ||
|
|
86
|
+
ch === '"' ||
|
|
87
|
+
ch === "`" ||
|
|
88
|
+
this.is_TOKEN()
|
|
89
|
+
) {
|
|
90
|
+
return ch;
|
|
91
|
+
} else {
|
|
92
|
+
/* istanbul ignore next */
|
|
93
|
+
throw new Error("Unexpected terminal");
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2018 Glayzzle (BSD3 License)
|
|
3
|
+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
|
|
4
|
+
* @url http://glayzzle.com
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
matchST_IN_SCRIPTING() {
|
|
10
|
+
let ch = this.input();
|
|
11
|
+
switch (ch) {
|
|
12
|
+
case " ":
|
|
13
|
+
case "\t":
|
|
14
|
+
case "\n":
|
|
15
|
+
case "\r":
|
|
16
|
+
case "\r\n":
|
|
17
|
+
return this.T_WHITESPACE();
|
|
18
|
+
case "#":
|
|
19
|
+
if (this.version >= 800 && this._input[this.offset] === "[") {
|
|
20
|
+
this.input();
|
|
21
|
+
this.attributeListDepth[++this.attributeIndex] = 0;
|
|
22
|
+
this.begin("ST_ATTRIBUTE");
|
|
23
|
+
return this.tok.T_ATTRIBUTE;
|
|
24
|
+
}
|
|
25
|
+
return this.T_COMMENT();
|
|
26
|
+
case "/":
|
|
27
|
+
if (this._input[this.offset] === "/") {
|
|
28
|
+
return this.T_COMMENT();
|
|
29
|
+
} else if (this._input[this.offset] === "*") {
|
|
30
|
+
this.input();
|
|
31
|
+
return this.T_DOC_COMMENT();
|
|
32
|
+
}
|
|
33
|
+
return this.consume_TOKEN();
|
|
34
|
+
case "'":
|
|
35
|
+
return this.T_CONSTANT_ENCAPSED_STRING();
|
|
36
|
+
case '"':
|
|
37
|
+
return this.ST_DOUBLE_QUOTES();
|
|
38
|
+
case "`":
|
|
39
|
+
this.begin("ST_BACKQUOTE");
|
|
40
|
+
return "`";
|
|
41
|
+
case "?":
|
|
42
|
+
if (!this.aspTagMode && this.tryMatch(">")) {
|
|
43
|
+
this.input();
|
|
44
|
+
const nextCH = this._input[this.offset];
|
|
45
|
+
if (nextCH === "\n" || nextCH === "\r") this.input();
|
|
46
|
+
if (this.conditionStack.length > 1) {
|
|
47
|
+
this.begin("INITIAL");
|
|
48
|
+
}
|
|
49
|
+
return this.tok.T_CLOSE_TAG;
|
|
50
|
+
}
|
|
51
|
+
return this.consume_TOKEN();
|
|
52
|
+
case "%":
|
|
53
|
+
if (this.aspTagMode && this._input[this.offset] === ">") {
|
|
54
|
+
this.input(); // consume the '>'
|
|
55
|
+
ch = this._input[this.offset]; // read next
|
|
56
|
+
if (ch === "\n" || ch === "\r") {
|
|
57
|
+
this.input(); // consume the newline
|
|
58
|
+
}
|
|
59
|
+
this.aspTagMode = false;
|
|
60
|
+
if (this.conditionStack.length > 1) {
|
|
61
|
+
this.begin("INITIAL");
|
|
62
|
+
}
|
|
63
|
+
return this.tok.T_CLOSE_TAG;
|
|
64
|
+
}
|
|
65
|
+
return this.consume_TOKEN();
|
|
66
|
+
case "{":
|
|
67
|
+
this.begin("ST_IN_SCRIPTING");
|
|
68
|
+
return "{";
|
|
69
|
+
case "}":
|
|
70
|
+
if (this.conditionStack.length > 2) {
|
|
71
|
+
// Return to HEREDOC/ST_DOUBLE_QUOTES mode
|
|
72
|
+
this.popState();
|
|
73
|
+
}
|
|
74
|
+
return "}";
|
|
75
|
+
default:
|
|
76
|
+
if (ch === ".") {
|
|
77
|
+
ch = this.input();
|
|
78
|
+
if (this.is_NUM_START()) {
|
|
79
|
+
return this.consume_NUM();
|
|
80
|
+
} else {
|
|
81
|
+
if (ch) this.unput(1);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (this.is_NUM_START()) {
|
|
85
|
+
return this.consume_NUM();
|
|
86
|
+
} else if (this.is_LABEL_START()) {
|
|
87
|
+
return this.consume_LABEL().T_STRING();
|
|
88
|
+
} else if (this.is_TOKEN()) {
|
|
89
|
+
return this.consume_TOKEN();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
throw new Error(
|
|
93
|
+
'Bad terminal sequence "' +
|
|
94
|
+
ch +
|
|
95
|
+
'" at line ' +
|
|
96
|
+
this.yylineno +
|
|
97
|
+
" (offset " +
|
|
98
|
+
this.offset +
|
|
99
|
+
")",
|
|
100
|
+
);
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
T_WHITESPACE() {
|
|
104
|
+
while (this.offset < this.size) {
|
|
105
|
+
const ch = this.input();
|
|
106
|
+
if (ch === " " || ch === "\t" || ch === "\n" || ch === "\r") {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (ch) this.unput(1);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
return this.tok.T_WHITESPACE;
|
|
113
|
+
},
|
|
114
|
+
};
|