@rightcapital/phpdoc-parser 0.3.3-feature-add-basic-ci.7.0 → 0.3.3-feature-add-basic-ci.8.0
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/dist/index.d.ts +73 -0
- package/dist/index.js +0 -1
- package/dist/phpdoc-parser/ast/abstract-node-visitor.d.ts +8 -0
- package/dist/phpdoc-parser/ast/abstract-node-visitor.js +18 -0
- package/dist/phpdoc-parser/ast/base-node.d.ts +10 -0
- package/dist/phpdoc-parser/ast/base-node.js +27 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-array-item-node.d.ts +8 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-array-item-node.js +21 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-array-node.d.ts +8 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-array-node.js +17 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-false-node.d.ts +5 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-false-node.js +13 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-float-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-float-node.js +17 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-integer-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-integer-node.js +17 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-node.d.ts +25 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-node.js +43 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-null-node.d.ts +5 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-null-node.js +13 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-string-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-string-node.js +17 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-true-node.d.ts +5 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-true-node.js +13 -0
- package/dist/phpdoc-parser/ast/const-expr/const-fetch-node.d.ts +8 -0
- package/dist/phpdoc-parser/ast/const-expr/const-fetch-node.js +21 -0
- package/dist/phpdoc-parser/ast/const-expr/quote-aware-const-expr-string-node.d.ts +10 -0
- package/dist/phpdoc-parser/ast/const-expr/quote-aware-const-expr-string-node.js +47 -0
- package/dist/phpdoc-parser/ast/node-traverser.d.ts +11 -0
- package/dist/phpdoc-parser/ast/node-traverser.js +216 -0
- package/dist/phpdoc-parser/ast/node-visitor/cloning-visitor.d.ts +5 -0
- package/dist/phpdoc-parser/ast/node-visitor/cloning-visitor.js +14 -0
- package/dist/phpdoc-parser/ast/node-visitor.d.ts +11 -0
- package/dist/phpdoc-parser/ast/node-visitor.js +2 -0
- package/dist/phpdoc-parser/ast/node.d.ts +6 -0
- package/dist/phpdoc-parser/ast/node.js +2 -0
- package/dist/phpdoc-parser/ast/php-doc/assert-tag-method-value-node.d.ts +13 -0
- package/dist/phpdoc-parser/ast/php-doc/assert-tag-method-value-node.js +24 -0
- package/dist/phpdoc-parser/ast/php-doc/assert-tag-property-value-node.d.ts +13 -0
- package/dist/phpdoc-parser/ast/php-doc/assert-tag-property-value-node.js +24 -0
- package/dist/phpdoc-parser/ast/php-doc/assert-tag-value-node.d.ts +12 -0
- package/dist/phpdoc-parser/ast/php-doc/assert-tag-value-node.js +23 -0
- package/dist/phpdoc-parser/ast/php-doc/deprecated-tag-value-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/php-doc/deprecated-tag-value-node.js +17 -0
- package/dist/phpdoc-parser/ast/php-doc/extends-tag-value-node.d.ts +9 -0
- package/dist/phpdoc-parser/ast/php-doc/extends-tag-value-node.js +18 -0
- package/dist/phpdoc-parser/ast/php-doc/generic-tag-value-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/php-doc/generic-tag-value-node.js +17 -0
- package/dist/phpdoc-parser/ast/php-doc/implements-tag-value-node.d.ts +9 -0
- package/dist/phpdoc-parser/ast/php-doc/implements-tag-value-node.js +18 -0
- package/dist/phpdoc-parser/ast/php-doc/invalid-tag-value-node.d.ts +10 -0
- package/dist/phpdoc-parser/ast/php-doc/invalid-tag-value-node.js +33 -0
- package/dist/phpdoc-parser/ast/php-doc/method-tag-value-node.d.ts +15 -0
- package/dist/phpdoc-parser/ast/php-doc/method-tag-value-node.js +27 -0
- package/dist/phpdoc-parser/ast/php-doc/method-tag-value-parameter-node.d.ts +13 -0
- package/dist/phpdoc-parser/ast/php-doc/method-tag-value-parameter-node.js +27 -0
- package/dist/phpdoc-parser/ast/php-doc/mixin-tag-value-node.d.ts +9 -0
- package/dist/phpdoc-parser/ast/php-doc/mixin-tag-value-node.js +18 -0
- package/dist/phpdoc-parser/ast/php-doc/param-out-tag-value-node.d.ts +10 -0
- package/dist/phpdoc-parser/ast/php-doc/param-out-tag-value-node.js +19 -0
- package/dist/phpdoc-parser/ast/php-doc/param-tag-value-node.d.ts +12 -0
- package/dist/phpdoc-parser/ast/php-doc/param-tag-value-node.js +28 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-child-node.d.ts +4 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-child-node.js +10 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-node.d.ts +32 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-node.js +97 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-tag-node.d.ts +56 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-tag-node.js +90 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-tag-value-node.d.ts +4 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-tag-value-node.js +10 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-text-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-text-node.js +17 -0
- package/dist/phpdoc-parser/ast/php-doc/property-tag-value-node.d.ts +10 -0
- package/dist/phpdoc-parser/ast/php-doc/property-tag-value-node.js +19 -0
- package/dist/phpdoc-parser/ast/php-doc/return-tag-value-node.d.ts +9 -0
- package/dist/phpdoc-parser/ast/php-doc/return-tag-value-node.js +18 -0
- package/dist/phpdoc-parser/ast/php-doc/self-out-tag-value-node.d.ts +9 -0
- package/dist/phpdoc-parser/ast/php-doc/self-out-tag-value-node.js +18 -0
- package/dist/phpdoc-parser/ast/php-doc/template-tag-value-node.d.ts +11 -0
- package/dist/phpdoc-parser/ast/php-doc/template-tag-value-node.js +24 -0
- package/dist/phpdoc-parser/ast/php-doc/throws-tag-value-node.d.ts +9 -0
- package/dist/phpdoc-parser/ast/php-doc/throws-tag-value-node.js +18 -0
- package/dist/phpdoc-parser/ast/php-doc/type-alias-import-tag-value-node.d.ts +10 -0
- package/dist/phpdoc-parser/ast/php-doc/type-alias-import-tag-value-node.js +22 -0
- package/dist/phpdoc-parser/ast/php-doc/type-alias-tag-value-node.d.ts +9 -0
- package/dist/phpdoc-parser/ast/php-doc/type-alias-tag-value-node.js +18 -0
- package/dist/phpdoc-parser/ast/php-doc/typeless-param-tag-value-node.d.ts +10 -0
- package/dist/phpdoc-parser/ast/php-doc/typeless-param-tag-value-node.js +22 -0
- package/dist/phpdoc-parser/ast/php-doc/uses-tag-value-node.d.ts +9 -0
- package/dist/phpdoc-parser/ast/php-doc/uses-tag-value-node.js +18 -0
- package/dist/phpdoc-parser/ast/php-doc/var-tag-value-node.d.ts +10 -0
- package/dist/phpdoc-parser/ast/php-doc/var-tag-value-node.js +19 -0
- package/dist/phpdoc-parser/ast/type/array-shape-item-node.d.ts +12 -0
- package/dist/phpdoc-parser/ast/type/array-shape-item-node.js +22 -0
- package/dist/phpdoc-parser/ast/type/array-shape-node.d.ts +14 -0
- package/dist/phpdoc-parser/ast/type/array-shape-node.js +31 -0
- package/dist/phpdoc-parser/ast/type/array-type-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/type/array-type-node.js +25 -0
- package/dist/phpdoc-parser/ast/type/callable-type-node.d.ts +11 -0
- package/dist/phpdoc-parser/ast/type/callable-type-node.js +24 -0
- package/dist/phpdoc-parser/ast/type/callable-type-parameter-node.d.ts +11 -0
- package/dist/phpdoc-parser/ast/type/callable-type-parameter-node.js +26 -0
- package/dist/phpdoc-parser/ast/type/conditional-type-for-parameter-node.d.ts +11 -0
- package/dist/phpdoc-parser/ast/type/conditional-type-for-parameter-node.js +21 -0
- package/dist/phpdoc-parser/ast/type/conditional-type-node.d.ts +11 -0
- package/dist/phpdoc-parser/ast/type/conditional-type-node.js +21 -0
- package/dist/phpdoc-parser/ast/type/const-type-node.d.ts +8 -0
- package/dist/phpdoc-parser/ast/type/const-type-node.js +17 -0
- package/dist/phpdoc-parser/ast/type/generic-type-node.d.ts +15 -0
- package/dist/phpdoc-parser/ast/type/generic-type-node.js +37 -0
- package/dist/phpdoc-parser/ast/type/identifier-type-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/type/identifier-type-node.js +17 -0
- package/dist/phpdoc-parser/ast/type/intersection-type-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/type/intersection-type-node.js +25 -0
- package/dist/phpdoc-parser/ast/type/invalid-type-node.d.ts +10 -0
- package/dist/phpdoc-parser/ast/type/invalid-type-node.js +29 -0
- package/dist/phpdoc-parser/ast/type/nullable-type-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/type/nullable-type-node.js +17 -0
- package/dist/phpdoc-parser/ast/type/object-shape-item-node.d.ts +11 -0
- package/dist/phpdoc-parser/ast/type/object-shape-item-node.js +22 -0
- package/dist/phpdoc-parser/ast/type/object-shape-node.d.ts +8 -0
- package/dist/phpdoc-parser/ast/type/object-shape-node.js +17 -0
- package/dist/phpdoc-parser/ast/type/offset-access-type-node.d.ts +8 -0
- package/dist/phpdoc-parser/ast/type/offset-access-type-node.js +26 -0
- package/dist/phpdoc-parser/ast/type/this-type-node.d.ts +5 -0
- package/dist/phpdoc-parser/ast/type/this-type-node.js +13 -0
- package/dist/phpdoc-parser/ast/type/type-node.d.ts +40 -0
- package/dist/phpdoc-parser/ast/type/type-node.js +64 -0
- package/dist/phpdoc-parser/ast/type/union-type-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/type/union-type-node.js +25 -0
- package/dist/phpdoc-parser/ast/types.d.ts +13 -0
- package/dist/phpdoc-parser/ast/types.js +18 -0
- package/dist/phpdoc-parser/lexer/lexer.d.ts +46 -0
- package/dist/phpdoc-parser/lexer/lexer.js +143 -0
- package/dist/phpdoc-parser/parser/const-expr-parser.d.ts +16 -0
- package/dist/phpdoc-parser/parser/const-expr-parser.js +146 -0
- package/dist/phpdoc-parser/parser/node-collecting-visitor.d.ts +7 -0
- package/dist/phpdoc-parser/parser/node-collecting-visitor.js +15 -0
- package/dist/phpdoc-parser/parser/parser-exception.d.ts +16 -0
- package/dist/phpdoc-parser/parser/parser-exception.js +44 -0
- package/dist/phpdoc-parser/parser/php-doc-parser.d.ts +47 -0
- package/dist/phpdoc-parser/parser/php-doc-parser.js +558 -0
- package/dist/phpdoc-parser/parser/string-unescaper.d.ts +6 -0
- package/dist/phpdoc-parser/parser/string-unescaper.js +41 -0
- package/dist/phpdoc-parser/parser/token-iterator.d.ts +40 -0
- package/dist/phpdoc-parser/parser/token-iterator.js +215 -0
- package/dist/phpdoc-parser/parser/type-parser.d.ts +41 -0
- package/dist/phpdoc-parser/parser/type-parser.js +576 -0
- package/dist/phpdoc-parser/printer/diff-elem.d.ts +12 -0
- package/dist/phpdoc-parser/printer/diff-elem.js +19 -0
- package/dist/phpdoc-parser/printer/differ.d.ts +10 -0
- package/dist/phpdoc-parser/printer/differ.js +111 -0
- package/dist/phpdoc-parser/printer/printer.d.ts +20 -0
- package/dist/phpdoc-parser/printer/printer.js +612 -0
- package/package.json +2 -2
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjectShapeNode = void 0;
|
|
4
|
+
const type_node_1 = require("./type-node");
|
|
5
|
+
class ObjectShapeNode extends type_node_1.TypeNode {
|
|
6
|
+
constructor(items) {
|
|
7
|
+
super();
|
|
8
|
+
this.items = items;
|
|
9
|
+
}
|
|
10
|
+
toString() {
|
|
11
|
+
return `object{${this.items.join(', ')}`;
|
|
12
|
+
}
|
|
13
|
+
getNodeType() {
|
|
14
|
+
return 'ObjectShapeNode';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.ObjectShapeNode = ObjectShapeNode;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OffsetAccessTypeNode = void 0;
|
|
4
|
+
const callable_type_node_1 = require("./callable-type-node");
|
|
5
|
+
const const_type_node_1 = require("./const-type-node");
|
|
6
|
+
const nullable_type_node_1 = require("./nullable-type-node");
|
|
7
|
+
const type_node_1 = require("./type-node");
|
|
8
|
+
class OffsetAccessTypeNode extends type_node_1.TypeNode {
|
|
9
|
+
constructor(type, offset) {
|
|
10
|
+
super();
|
|
11
|
+
this.type = type;
|
|
12
|
+
this.offset = offset;
|
|
13
|
+
}
|
|
14
|
+
toString() {
|
|
15
|
+
if (this.type instanceof callable_type_node_1.CallableTypeNode ||
|
|
16
|
+
this.type instanceof const_type_node_1.ConstTypeNode ||
|
|
17
|
+
this.type instanceof nullable_type_node_1.NullableTypeNode) {
|
|
18
|
+
return `(${this.type.toString()})[${this.offset.toString()}]`;
|
|
19
|
+
}
|
|
20
|
+
return `${this.type.toString()}[${this.offset.toString()}]`;
|
|
21
|
+
}
|
|
22
|
+
getNodeType() {
|
|
23
|
+
return 'OffsetAccessTypeNode';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.OffsetAccessTypeNode = OffsetAccessTypeNode;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ThisTypeNode = void 0;
|
|
4
|
+
const type_node_1 = require("./type-node");
|
|
5
|
+
class ThisTypeNode extends type_node_1.TypeNode {
|
|
6
|
+
toString() {
|
|
7
|
+
return '$this';
|
|
8
|
+
}
|
|
9
|
+
getNodeType() {
|
|
10
|
+
return 'ThisTypeNode';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.ThisTypeNode = ThisTypeNode;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ArrayShapeItemNode } from './array-shape-item-node';
|
|
2
|
+
import type { ArrayShapeNode } from './array-shape-node';
|
|
3
|
+
import type { ArrayTypeNode } from './array-type-node';
|
|
4
|
+
import type { CallableTypeNode } from './callable-type-node';
|
|
5
|
+
import type { CallableTypeParameterNode } from './callable-type-parameter-node';
|
|
6
|
+
import type { ConditionalTypeForParameterNode } from './conditional-type-for-parameter-node';
|
|
7
|
+
import type { ConditionalTypeNode } from './conditional-type-node';
|
|
8
|
+
import type { ConstTypeNode } from './const-type-node';
|
|
9
|
+
import type { GenericTypeNode } from './generic-type-node';
|
|
10
|
+
import type { IdentifierTypeNode } from './identifier-type-node';
|
|
11
|
+
import type { IntersectionTypeNode } from './intersection-type-node';
|
|
12
|
+
import type { InvalidTypeNode } from './invalid-type-node';
|
|
13
|
+
import type { NullableTypeNode } from './nullable-type-node';
|
|
14
|
+
import type { ObjectShapeItemNode } from './object-shape-item-node';
|
|
15
|
+
import type { ObjectShapeNode } from './object-shape-node';
|
|
16
|
+
import type { OffsetAccessTypeNode } from './offset-access-type-node';
|
|
17
|
+
import type { ThisTypeNode } from './this-type-node';
|
|
18
|
+
import type { UnionTypeNode } from './union-type-node';
|
|
19
|
+
import { BaseNode } from '../base-node';
|
|
20
|
+
export declare class TypeNode extends BaseNode {
|
|
21
|
+
getNodeType(): string;
|
|
22
|
+
isArrayShapeItemNode(): this is ArrayShapeItemNode;
|
|
23
|
+
isArrayShapeNode(): this is ArrayShapeNode;
|
|
24
|
+
isArrayTypeNode(): this is ArrayTypeNode;
|
|
25
|
+
isCallableTypeNode(): this is CallableTypeNode;
|
|
26
|
+
isCallableTypeParameterNode(): this is CallableTypeParameterNode;
|
|
27
|
+
isConditionalTypeForParameterNode(): this is ConditionalTypeForParameterNode;
|
|
28
|
+
isConditionalTypeNode(): this is ConditionalTypeNode;
|
|
29
|
+
isConstTypeNode(): this is ConstTypeNode;
|
|
30
|
+
isGenericTypeNode(): this is GenericTypeNode;
|
|
31
|
+
isIdentifierTypeNode(): this is IdentifierTypeNode;
|
|
32
|
+
isIntersectionTypeNode(): this is IntersectionTypeNode;
|
|
33
|
+
isInvalidTypeNode(): this is InvalidTypeNode;
|
|
34
|
+
isNullableTypeNode(): this is NullableTypeNode;
|
|
35
|
+
isObjectShapeItemNode(): this is ObjectShapeItemNode;
|
|
36
|
+
isObjectShapeNode(): this is ObjectShapeNode;
|
|
37
|
+
isOffsetAccessTypeNode(): this is OffsetAccessTypeNode;
|
|
38
|
+
isThisTypeNode(): this is ThisTypeNode;
|
|
39
|
+
isUnionTypeNode(): this is UnionTypeNode;
|
|
40
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypeNode = void 0;
|
|
4
|
+
const base_node_1 = require("../base-node");
|
|
5
|
+
class TypeNode extends base_node_1.BaseNode {
|
|
6
|
+
getNodeType() {
|
|
7
|
+
return 'TypeNode';
|
|
8
|
+
}
|
|
9
|
+
isArrayShapeItemNode() {
|
|
10
|
+
return this.getNodeType() === 'ArrayShapeItemNode';
|
|
11
|
+
}
|
|
12
|
+
isArrayShapeNode() {
|
|
13
|
+
return this.getNodeType() === 'ArrayShapeNode';
|
|
14
|
+
}
|
|
15
|
+
isArrayTypeNode() {
|
|
16
|
+
return this.getNodeType() === 'ArrayTypeNode';
|
|
17
|
+
}
|
|
18
|
+
isCallableTypeNode() {
|
|
19
|
+
return this.getNodeType() === 'CallableTypeNode';
|
|
20
|
+
}
|
|
21
|
+
isCallableTypeParameterNode() {
|
|
22
|
+
return this.getNodeType() === 'CallableTypeParameterNode';
|
|
23
|
+
}
|
|
24
|
+
isConditionalTypeForParameterNode() {
|
|
25
|
+
return this.getNodeType() === 'ConditionalTypeForParameterNode';
|
|
26
|
+
}
|
|
27
|
+
isConditionalTypeNode() {
|
|
28
|
+
return this.getNodeType() === 'ConditionalTypeNode';
|
|
29
|
+
}
|
|
30
|
+
isConstTypeNode() {
|
|
31
|
+
return this.getNodeType() === 'ConstTypeNode';
|
|
32
|
+
}
|
|
33
|
+
isGenericTypeNode() {
|
|
34
|
+
return this.getNodeType() === 'GenericTypeNode';
|
|
35
|
+
}
|
|
36
|
+
isIdentifierTypeNode() {
|
|
37
|
+
return this.getNodeType() === 'IdentifierTypeNode';
|
|
38
|
+
}
|
|
39
|
+
isIntersectionTypeNode() {
|
|
40
|
+
return this.getNodeType() === 'IntersectionTypeNode';
|
|
41
|
+
}
|
|
42
|
+
isInvalidTypeNode() {
|
|
43
|
+
return this.getNodeType() === 'InvalidTypeNode';
|
|
44
|
+
}
|
|
45
|
+
isNullableTypeNode() {
|
|
46
|
+
return this.getNodeType() === 'NullableTypeNode';
|
|
47
|
+
}
|
|
48
|
+
isObjectShapeItemNode() {
|
|
49
|
+
return this.getNodeType() === 'ObjectShapeItemNode';
|
|
50
|
+
}
|
|
51
|
+
isObjectShapeNode() {
|
|
52
|
+
return this.getNodeType() === 'ObjectShapeNode';
|
|
53
|
+
}
|
|
54
|
+
isOffsetAccessTypeNode() {
|
|
55
|
+
return this.getNodeType() === 'OffsetAccessTypeNode';
|
|
56
|
+
}
|
|
57
|
+
isThisTypeNode() {
|
|
58
|
+
return this.getNodeType() === 'ThisTypeNode';
|
|
59
|
+
}
|
|
60
|
+
isUnionTypeNode() {
|
|
61
|
+
return this.getNodeType() === 'UnionTypeNode';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.TypeNode = TypeNode;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnionTypeNode = void 0;
|
|
4
|
+
const nullable_type_node_1 = require("./nullable-type-node");
|
|
5
|
+
const type_node_1 = require("./type-node");
|
|
6
|
+
class UnionTypeNode extends type_node_1.TypeNode {
|
|
7
|
+
constructor(types) {
|
|
8
|
+
super();
|
|
9
|
+
this.types = types;
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return `(${this.types
|
|
13
|
+
.map((type) => {
|
|
14
|
+
if (type instanceof nullable_type_node_1.NullableTypeNode) {
|
|
15
|
+
return `(${type.toString()})`;
|
|
16
|
+
}
|
|
17
|
+
return type.toString();
|
|
18
|
+
})
|
|
19
|
+
.join(' | ')})`;
|
|
20
|
+
}
|
|
21
|
+
getNodeType() {
|
|
22
|
+
return 'UnionTypeNode';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.UnionTypeNode = UnionTypeNode;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const enum NodeTraverserState {
|
|
2
|
+
DONT_TRAVERSE_CHILDREN = 1,
|
|
3
|
+
STOP_TRAVERSAL = 2,
|
|
4
|
+
REMOVE_NODE = 3,
|
|
5
|
+
DONT_TRAVERSE_CURRENT_AND_CHILDREN = 4
|
|
6
|
+
}
|
|
7
|
+
export declare enum Attribute {
|
|
8
|
+
START_LINE = "startLine",
|
|
9
|
+
END_LINE = "endLine",
|
|
10
|
+
START_INDEX = "startIndex",
|
|
11
|
+
END_INDEX = "endIndex",
|
|
12
|
+
ORIGINAL_NODE = "originalNode"
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Attribute = exports.NodeTraverserState = void 0;
|
|
4
|
+
var NodeTraverserState;
|
|
5
|
+
(function (NodeTraverserState) {
|
|
6
|
+
NodeTraverserState[NodeTraverserState["DONT_TRAVERSE_CHILDREN"] = 1] = "DONT_TRAVERSE_CHILDREN";
|
|
7
|
+
NodeTraverserState[NodeTraverserState["STOP_TRAVERSAL"] = 2] = "STOP_TRAVERSAL";
|
|
8
|
+
NodeTraverserState[NodeTraverserState["REMOVE_NODE"] = 3] = "REMOVE_NODE";
|
|
9
|
+
NodeTraverserState[NodeTraverserState["DONT_TRAVERSE_CURRENT_AND_CHILDREN"] = 4] = "DONT_TRAVERSE_CURRENT_AND_CHILDREN";
|
|
10
|
+
})(NodeTraverserState || (exports.NodeTraverserState = NodeTraverserState = {}));
|
|
11
|
+
var Attribute;
|
|
12
|
+
(function (Attribute) {
|
|
13
|
+
Attribute["START_LINE"] = "startLine";
|
|
14
|
+
Attribute["END_LINE"] = "endLine";
|
|
15
|
+
Attribute["START_INDEX"] = "startIndex";
|
|
16
|
+
Attribute["END_INDEX"] = "endIndex";
|
|
17
|
+
Attribute["ORIGINAL_NODE"] = "originalNode";
|
|
18
|
+
})(Attribute || (exports.Attribute = Attribute = {}));
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export declare class Lexer {
|
|
2
|
+
static TOKEN_REFERENCE: string;
|
|
3
|
+
static TOKEN_UNION: string;
|
|
4
|
+
static TOKEN_INTERSECTION: string;
|
|
5
|
+
static TOKEN_NULLABLE: string;
|
|
6
|
+
static TOKEN_OPEN_PARENTHESES: string;
|
|
7
|
+
static TOKEN_CLOSE_PARENTHESES: string;
|
|
8
|
+
static TOKEN_OPEN_ANGLE_BRACKET: string;
|
|
9
|
+
static TOKEN_CLOSE_ANGLE_BRACKET: string;
|
|
10
|
+
static TOKEN_OPEN_SQUARE_BRACKET: string;
|
|
11
|
+
static TOKEN_CLOSE_SQUARE_BRACKET: string;
|
|
12
|
+
static TOKEN_COMMA: string;
|
|
13
|
+
static TOKEN_VARIADIC: string;
|
|
14
|
+
static TOKEN_DOUBLE_COLON: string;
|
|
15
|
+
static TOKEN_DOUBLE_ARROW: string;
|
|
16
|
+
static TOKEN_EQUAL: string;
|
|
17
|
+
static TOKEN_OPEN_PHPDOC: string;
|
|
18
|
+
static TOKEN_CLOSE_PHPDOC: string;
|
|
19
|
+
static TOKEN_PHPDOC_TAG: string;
|
|
20
|
+
static TOKEN_FLOAT: string;
|
|
21
|
+
static TOKEN_INTEGER: string;
|
|
22
|
+
static TOKEN_SINGLE_QUOTED_STRING: string;
|
|
23
|
+
static TOKEN_DOUBLE_QUOTED_STRING: string;
|
|
24
|
+
static TOKEN_IDENTIFIER: string;
|
|
25
|
+
static TOKEN_THIS_VARIABLE: string;
|
|
26
|
+
static TOKEN_VARIABLE: string;
|
|
27
|
+
static TOKEN_HORIZONTAL_WS: string;
|
|
28
|
+
static TOKEN_PHPDOC_EOL: string;
|
|
29
|
+
static TOKEN_OTHER: string;
|
|
30
|
+
static TOKEN_END: string;
|
|
31
|
+
static TOKEN_COLON: string;
|
|
32
|
+
static TOKEN_WILDCARD: string;
|
|
33
|
+
static TOKEN_OPEN_CURLY_BRACKET: string;
|
|
34
|
+
static TOKEN_CLOSE_CURLY_BRACKET: string;
|
|
35
|
+
static TOKEN_NEGATED: string;
|
|
36
|
+
static TOKEN_ARROW: string;
|
|
37
|
+
static TOKEN_LABELS: {
|
|
38
|
+
[x: string]: string;
|
|
39
|
+
};
|
|
40
|
+
static VALUE_OFFSET: 0;
|
|
41
|
+
static TYPE_OFFSET: 1;
|
|
42
|
+
static LINE_OFFSET: 2;
|
|
43
|
+
private regexp;
|
|
44
|
+
tokenize(source: string): Array<[string, string, number]>;
|
|
45
|
+
private generateRegexp;
|
|
46
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Lexer = void 0;
|
|
4
|
+
class Lexer {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.regexp = this.generateRegexp();
|
|
7
|
+
}
|
|
8
|
+
tokenize(source) {
|
|
9
|
+
const matchArray = source.matchAll(this.regexp);
|
|
10
|
+
const tokens = [];
|
|
11
|
+
let line = 1;
|
|
12
|
+
for (const match of matchArray) {
|
|
13
|
+
const type = Object.entries(match.groups).filter(([_, value]) => typeof value !== 'undefined')[0][0];
|
|
14
|
+
tokens.push([match[0], type, line]);
|
|
15
|
+
if (type !== Lexer.TOKEN_PHPDOC_EOL) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
line++;
|
|
19
|
+
}
|
|
20
|
+
tokens.push(['', Lexer.TOKEN_END, line]);
|
|
21
|
+
return tokens;
|
|
22
|
+
}
|
|
23
|
+
generateRegexp() {
|
|
24
|
+
const patterns = {
|
|
25
|
+
[Lexer.TOKEN_HORIZONTAL_WS]: '[\\x09\\x20]+',
|
|
26
|
+
[Lexer.TOKEN_IDENTIFIER]: '(?:[\\\\]?[a-z_\\x80-\\xFF][0-9a-z_\\x80-\\xFF-]*)+',
|
|
27
|
+
[Lexer.TOKEN_THIS_VARIABLE]: '\\$this(?![0-9a-z_\\x80-\\xFF])',
|
|
28
|
+
[Lexer.TOKEN_VARIABLE]: '\\$[a-z_\\x80-\\xFF][0-9a-z_\\x80-\\xFF]*',
|
|
29
|
+
[Lexer.TOKEN_REFERENCE]: '&(?=\\s*(?:[.,=)]|(?:\\$(?!this(?![0-9a-z_\\x80-\\xFF])))))',
|
|
30
|
+
[Lexer.TOKEN_UNION]: '\\|',
|
|
31
|
+
[Lexer.TOKEN_INTERSECTION]: '&',
|
|
32
|
+
[Lexer.TOKEN_NULLABLE]: '\\?',
|
|
33
|
+
[Lexer.TOKEN_NEGATED]: '!',
|
|
34
|
+
[Lexer.TOKEN_OPEN_PARENTHESES]: '\\(',
|
|
35
|
+
[Lexer.TOKEN_CLOSE_PARENTHESES]: '\\)',
|
|
36
|
+
[Lexer.TOKEN_OPEN_ANGLE_BRACKET]: '<',
|
|
37
|
+
[Lexer.TOKEN_CLOSE_ANGLE_BRACKET]: '>',
|
|
38
|
+
[Lexer.TOKEN_OPEN_SQUARE_BRACKET]: '\\[',
|
|
39
|
+
[Lexer.TOKEN_CLOSE_SQUARE_BRACKET]: '\\]',
|
|
40
|
+
[Lexer.TOKEN_OPEN_CURLY_BRACKET]: '\\{',
|
|
41
|
+
[Lexer.TOKEN_CLOSE_CURLY_BRACKET]: '\\}',
|
|
42
|
+
[Lexer.TOKEN_COMMA]: ',',
|
|
43
|
+
[Lexer.TOKEN_VARIADIC]: '\\.\\.\\.',
|
|
44
|
+
[Lexer.TOKEN_DOUBLE_COLON]: '::',
|
|
45
|
+
[Lexer.TOKEN_DOUBLE_ARROW]: '=>',
|
|
46
|
+
[Lexer.TOKEN_ARROW]: '->',
|
|
47
|
+
[Lexer.TOKEN_EQUAL]: '=',
|
|
48
|
+
[Lexer.TOKEN_COLON]: ':',
|
|
49
|
+
[Lexer.TOKEN_OPEN_PHPDOC]: '\\/\\*\\*(?=\\s)\\x20?',
|
|
50
|
+
[Lexer.TOKEN_CLOSE_PHPDOC]: '\\*\\/',
|
|
51
|
+
[Lexer.TOKEN_PHPDOC_TAG]: '@(?:[a-z][a-z0-9-\\\\]+:)?[a-z][a-z0-9-\\\\]*',
|
|
52
|
+
[Lexer.TOKEN_PHPDOC_EOL]: '\\r?\\n[\\x09\\x20]*(?:\\*(?!\\/)\\x20?)?',
|
|
53
|
+
[Lexer.TOKEN_FLOAT]: '[+-]?(?:(?:[0-9]+(_[0-9]+)*\\.[0-9]*(_[0-9]+)*(?:e[+-]?[0-9]+(_[0-9]+)*)?)|(?:[0-9]*(_[0-9]+)*\\.[0-9]+(_[0-9]+)*(?:e[+-]?[0-9]+(_[0-9]+)*)?)|(?:[0-9]+(_[0-9]+)*e[+-]?[0-9]+(_[0-9]+)*))',
|
|
54
|
+
[Lexer.TOKEN_INTEGER]: '[+-]?(?:(?:0b[0-1]+(_[0-1]+)*)|(?:0o[0-7]+(_[0-7]+)*)|(?:0x[0-9a-f]+(_[0-9a-f]+)*)|(?:[0-9]+(_[0-9]+)*))',
|
|
55
|
+
[Lexer.TOKEN_SINGLE_QUOTED_STRING]: "'(?:\\\\[^\\r\\n]|[^'\\r\\n\\\\])*'",
|
|
56
|
+
[Lexer.TOKEN_DOUBLE_QUOTED_STRING]: '"(?:\\\\[^\\r\\n]|[^"\\r\\n\\\\])*"',
|
|
57
|
+
[Lexer.TOKEN_WILDCARD]: '\\*',
|
|
58
|
+
};
|
|
59
|
+
patterns[Lexer.TOKEN_OTHER] = '(?:(?!\\*\\/)[^\\s])+';
|
|
60
|
+
const combinedRegExp = Object.entries(patterns)
|
|
61
|
+
.map(([key, pattern]) => {
|
|
62
|
+
return `(?<${key}>${pattern})`;
|
|
63
|
+
})
|
|
64
|
+
.join('|');
|
|
65
|
+
return new RegExp(combinedRegExp, 'sig');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.Lexer = Lexer;
|
|
69
|
+
Lexer.TOKEN_REFERENCE = 'TOKEN_REFERENCE';
|
|
70
|
+
Lexer.TOKEN_UNION = 'TOKEN_UNION';
|
|
71
|
+
Lexer.TOKEN_INTERSECTION = 'TOKEN_INTERSECTION';
|
|
72
|
+
Lexer.TOKEN_NULLABLE = 'TOKEN_NULLABLE';
|
|
73
|
+
Lexer.TOKEN_OPEN_PARENTHESES = 'TOKEN_OPEN_PARENTHESES';
|
|
74
|
+
Lexer.TOKEN_CLOSE_PARENTHESES = 'TOKEN_CLOSE_PARENTHESES';
|
|
75
|
+
Lexer.TOKEN_OPEN_ANGLE_BRACKET = 'TOKEN_OPEN_ANGLE_BRACKET';
|
|
76
|
+
Lexer.TOKEN_CLOSE_ANGLE_BRACKET = 'TOKEN_CLOSE_ANGLE_BRACKET';
|
|
77
|
+
Lexer.TOKEN_OPEN_SQUARE_BRACKET = 'TOKEN_OPEN_SQUARE_BRACKET';
|
|
78
|
+
Lexer.TOKEN_CLOSE_SQUARE_BRACKET = 'TOKEN_CLOSE_SQUARE_BRACKET';
|
|
79
|
+
Lexer.TOKEN_COMMA = 'TOKEN_COMMA';
|
|
80
|
+
Lexer.TOKEN_VARIADIC = 'TOKEN_VARIADIC';
|
|
81
|
+
Lexer.TOKEN_DOUBLE_COLON = 'TOKEN_DOUBLE_COLON';
|
|
82
|
+
Lexer.TOKEN_DOUBLE_ARROW = 'TOKEN_DOUBLE_ARROW';
|
|
83
|
+
Lexer.TOKEN_EQUAL = 'TOKEN_EQUAL';
|
|
84
|
+
Lexer.TOKEN_OPEN_PHPDOC = 'TOKEN_OPEN_PHPDOC';
|
|
85
|
+
Lexer.TOKEN_CLOSE_PHPDOC = 'TOKEN_CLOSE_PHPDOC';
|
|
86
|
+
Lexer.TOKEN_PHPDOC_TAG = 'TOKEN_PHPDOC_TAG';
|
|
87
|
+
Lexer.TOKEN_FLOAT = 'TOKEN_FLOAT';
|
|
88
|
+
Lexer.TOKEN_INTEGER = 'TOKEN_INTEGER';
|
|
89
|
+
Lexer.TOKEN_SINGLE_QUOTED_STRING = 'TOKEN_SINGLE_QUOTED_STRING';
|
|
90
|
+
Lexer.TOKEN_DOUBLE_QUOTED_STRING = 'TOKEN_DOUBLE_QUOTED_STRING';
|
|
91
|
+
Lexer.TOKEN_IDENTIFIER = 'TOKEN_IDENTIFIER';
|
|
92
|
+
Lexer.TOKEN_THIS_VARIABLE = 'TOKEN_THIS_VARIABLE';
|
|
93
|
+
Lexer.TOKEN_VARIABLE = 'TOKEN_VARIABLE';
|
|
94
|
+
Lexer.TOKEN_HORIZONTAL_WS = 'TOKEN_HORIZONTAL_WS';
|
|
95
|
+
Lexer.TOKEN_PHPDOC_EOL = 'TOKEN_PHPDOC_EOL';
|
|
96
|
+
Lexer.TOKEN_OTHER = 'TOKEN_OTHER';
|
|
97
|
+
Lexer.TOKEN_END = 'TOKEN_END';
|
|
98
|
+
Lexer.TOKEN_COLON = 'TOKEN_COLON';
|
|
99
|
+
Lexer.TOKEN_WILDCARD = 'TOKEN_WILDCARD';
|
|
100
|
+
Lexer.TOKEN_OPEN_CURLY_BRACKET = 'TOKEN_OPEN_CURLY_BRACKET';
|
|
101
|
+
Lexer.TOKEN_CLOSE_CURLY_BRACKET = 'TOKEN_CLOSE_CURLY_BRACKET';
|
|
102
|
+
Lexer.TOKEN_NEGATED = 'TOKEN_NEGATED';
|
|
103
|
+
Lexer.TOKEN_ARROW = 'TOKEN_ARROW';
|
|
104
|
+
Lexer.TOKEN_LABELS = {
|
|
105
|
+
[Lexer.TOKEN_REFERENCE]: '&',
|
|
106
|
+
[Lexer.TOKEN_UNION]: '|',
|
|
107
|
+
[Lexer.TOKEN_INTERSECTION]: '&',
|
|
108
|
+
[Lexer.TOKEN_NULLABLE]: '?',
|
|
109
|
+
[Lexer.TOKEN_NEGATED]: '!',
|
|
110
|
+
[Lexer.TOKEN_OPEN_PARENTHESES]: '(',
|
|
111
|
+
[Lexer.TOKEN_CLOSE_PARENTHESES]: ')',
|
|
112
|
+
[Lexer.TOKEN_OPEN_ANGLE_BRACKET]: '<',
|
|
113
|
+
[Lexer.TOKEN_CLOSE_ANGLE_BRACKET]: '>',
|
|
114
|
+
[Lexer.TOKEN_OPEN_SQUARE_BRACKET]: '[',
|
|
115
|
+
[Lexer.TOKEN_CLOSE_SQUARE_BRACKET]: ']',
|
|
116
|
+
[Lexer.TOKEN_OPEN_CURLY_BRACKET]: '{',
|
|
117
|
+
[Lexer.TOKEN_CLOSE_CURLY_BRACKET]: '}',
|
|
118
|
+
[Lexer.TOKEN_COMMA]: ',',
|
|
119
|
+
[Lexer.TOKEN_COLON]: ':',
|
|
120
|
+
[Lexer.TOKEN_VARIADIC]: '...',
|
|
121
|
+
[Lexer.TOKEN_DOUBLE_COLON]: '::',
|
|
122
|
+
[Lexer.TOKEN_DOUBLE_ARROW]: '=>',
|
|
123
|
+
[Lexer.TOKEN_ARROW]: '->',
|
|
124
|
+
[Lexer.TOKEN_EQUAL]: '=',
|
|
125
|
+
[Lexer.TOKEN_OPEN_PHPDOC]: '/**',
|
|
126
|
+
[Lexer.TOKEN_CLOSE_PHPDOC]: '*/',
|
|
127
|
+
[Lexer.TOKEN_PHPDOC_TAG]: 'TOKEN_PHPDOC_TAG',
|
|
128
|
+
[Lexer.TOKEN_PHPDOC_EOL]: 'TOKEN_PHPDOC_EOL',
|
|
129
|
+
[Lexer.TOKEN_FLOAT]: 'TOKEN_FLOAT',
|
|
130
|
+
[Lexer.TOKEN_INTEGER]: 'TOKEN_INTEGER',
|
|
131
|
+
[Lexer.TOKEN_SINGLE_QUOTED_STRING]: 'TOKEN_SINGLE_QUOTED_STRING',
|
|
132
|
+
[Lexer.TOKEN_DOUBLE_QUOTED_STRING]: 'TOKEN_DOUBLE_QUOTED_STRING',
|
|
133
|
+
[Lexer.TOKEN_IDENTIFIER]: 'type',
|
|
134
|
+
[Lexer.TOKEN_THIS_VARIABLE]: '$this',
|
|
135
|
+
[Lexer.TOKEN_VARIABLE]: 'variable',
|
|
136
|
+
[Lexer.TOKEN_HORIZONTAL_WS]: 'TOKEN_HORIZONTAL_WS',
|
|
137
|
+
[Lexer.TOKEN_OTHER]: 'TOKEN_OTHER',
|
|
138
|
+
[Lexer.TOKEN_END]: 'TOKEN_END',
|
|
139
|
+
[Lexer.TOKEN_WILDCARD]: '*',
|
|
140
|
+
};
|
|
141
|
+
Lexer.VALUE_OFFSET = 0;
|
|
142
|
+
Lexer.TYPE_OFFSET = 1;
|
|
143
|
+
Lexer.LINE_OFFSET = 2;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TokenIterator } from './token-iterator';
|
|
2
|
+
import { ConstExprNode } from '../ast/const-expr/const-expr-node';
|
|
3
|
+
export declare class ConstExprParser {
|
|
4
|
+
private unescapeStrings;
|
|
5
|
+
private quoteAwareConstExprString;
|
|
6
|
+
private useLinesAttributes;
|
|
7
|
+
private useIndexAttributes;
|
|
8
|
+
constructor(unescapeStrings?: boolean, quoteAwareConstExprString?: boolean, usedAttributes?: {
|
|
9
|
+
lines?: boolean;
|
|
10
|
+
indexes?: boolean;
|
|
11
|
+
});
|
|
12
|
+
parse(tokens: TokenIterator, trimStrings?: boolean): ConstExprNode;
|
|
13
|
+
private parseArray;
|
|
14
|
+
private parseArrayItem;
|
|
15
|
+
private enrichWithAttributes;
|
|
16
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConstExprParser = void 0;
|
|
4
|
+
const parser_exception_1 = require("./parser-exception");
|
|
5
|
+
const string_unescaper_1 = require("./string-unescaper");
|
|
6
|
+
const const_expr_array_item_node_1 = require("../ast/const-expr/const-expr-array-item-node");
|
|
7
|
+
const const_expr_array_node_1 = require("../ast/const-expr/const-expr-array-node");
|
|
8
|
+
const const_expr_false_node_1 = require("../ast/const-expr/const-expr-false-node");
|
|
9
|
+
const const_expr_float_node_1 = require("../ast/const-expr/const-expr-float-node");
|
|
10
|
+
const const_expr_integer_node_1 = require("../ast/const-expr/const-expr-integer-node");
|
|
11
|
+
const const_expr_null_node_1 = require("../ast/const-expr/const-expr-null-node");
|
|
12
|
+
const const_expr_string_node_1 = require("../ast/const-expr/const-expr-string-node");
|
|
13
|
+
const const_expr_true_node_1 = require("../ast/const-expr/const-expr-true-node");
|
|
14
|
+
const const_fetch_node_1 = require("../ast/const-expr/const-fetch-node");
|
|
15
|
+
const quote_aware_const_expr_string_node_1 = require("../ast/const-expr/quote-aware-const-expr-string-node");
|
|
16
|
+
const types_1 = require("../ast/types");
|
|
17
|
+
const lexer_1 = require("../lexer/lexer");
|
|
18
|
+
class ConstExprParser {
|
|
19
|
+
constructor(unescapeStrings = false, quoteAwareConstExprString = false, usedAttributes = {}) {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
this.unescapeStrings = unescapeStrings;
|
|
22
|
+
this.quoteAwareConstExprString = quoteAwareConstExprString;
|
|
23
|
+
this.useLinesAttributes = (_a = usedAttributes.lines) !== null && _a !== void 0 ? _a : false;
|
|
24
|
+
this.useIndexAttributes = (_b = usedAttributes.indexes) !== null && _b !== void 0 ? _b : false;
|
|
25
|
+
}
|
|
26
|
+
parse(tokens, trimStrings = false) {
|
|
27
|
+
const startLine = tokens.currentTokenLine();
|
|
28
|
+
const startIndex = tokens.currentTokenIndex();
|
|
29
|
+
if (tokens.isCurrentTokenType(lexer_1.Lexer.TOKEN_FLOAT)) {
|
|
30
|
+
const value = tokens.currentTokenValue();
|
|
31
|
+
tokens.next();
|
|
32
|
+
return this.enrichWithAttributes(tokens, new const_expr_float_node_1.ConstExprFloatNode(value.replaceAll('_', '')), startLine, startIndex);
|
|
33
|
+
}
|
|
34
|
+
if (tokens.isCurrentTokenType(lexer_1.Lexer.TOKEN_INTEGER)) {
|
|
35
|
+
const value = tokens.currentTokenValue();
|
|
36
|
+
tokens.next();
|
|
37
|
+
return this.enrichWithAttributes(tokens, new const_expr_integer_node_1.ConstExprIntegerNode(value.replaceAll('_', '')), startLine, startIndex);
|
|
38
|
+
}
|
|
39
|
+
if (tokens.isCurrentTokenType(lexer_1.Lexer.TOKEN_SINGLE_QUOTED_STRING, lexer_1.Lexer.TOKEN_DOUBLE_QUOTED_STRING)) {
|
|
40
|
+
let value = tokens.currentTokenValue();
|
|
41
|
+
const type = tokens.currentTokenType();
|
|
42
|
+
if (trimStrings) {
|
|
43
|
+
if (this.unescapeStrings) {
|
|
44
|
+
value = string_unescaper_1.StringUnescaper.unescapeString(value);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
value = value.substring(1, value.length - 1);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
tokens.next();
|
|
51
|
+
if (this.quoteAwareConstExprString) {
|
|
52
|
+
return this.enrichWithAttributes(tokens, new quote_aware_const_expr_string_node_1.QuoteAwareConstExprStringNode(value, type === lexer_1.Lexer.TOKEN_SINGLE_QUOTED_STRING
|
|
53
|
+
? quote_aware_const_expr_string_node_1.QuoteAwareConstExprStringNode.SINGLE_QUOTED
|
|
54
|
+
: quote_aware_const_expr_string_node_1.QuoteAwareConstExprStringNode.DOUBLE_QUOTED), startLine, startIndex);
|
|
55
|
+
}
|
|
56
|
+
return this.enrichWithAttributes(tokens, new const_expr_string_node_1.ConstExprStringNode(value), startLine, startIndex);
|
|
57
|
+
}
|
|
58
|
+
if (tokens.isCurrentTokenType(lexer_1.Lexer.TOKEN_IDENTIFIER)) {
|
|
59
|
+
const identifier = tokens.currentTokenValue();
|
|
60
|
+
tokens.next();
|
|
61
|
+
switch (identifier.toLowerCase()) {
|
|
62
|
+
case 'true':
|
|
63
|
+
return this.enrichWithAttributes(tokens, new const_expr_true_node_1.ConstExprTrueNode(), startLine, startIndex);
|
|
64
|
+
case 'false':
|
|
65
|
+
return this.enrichWithAttributes(tokens, new const_expr_false_node_1.ConstExprFalseNode(), startLine, startIndex);
|
|
66
|
+
case 'null':
|
|
67
|
+
return this.enrichWithAttributes(tokens, new const_expr_null_node_1.ConstExprNullNode(), startLine, startIndex);
|
|
68
|
+
case 'array':
|
|
69
|
+
tokens.consumeTokenType(lexer_1.Lexer.TOKEN_OPEN_PARENTHESES);
|
|
70
|
+
return this.parseArray(tokens, lexer_1.Lexer.TOKEN_CLOSE_PARENTHESES, startIndex);
|
|
71
|
+
}
|
|
72
|
+
if (tokens.tryConsumeTokenType(lexer_1.Lexer.TOKEN_DOUBLE_COLON)) {
|
|
73
|
+
let classConstantName = '';
|
|
74
|
+
let lastType = null;
|
|
75
|
+
while (true) {
|
|
76
|
+
if (lastType !== lexer_1.Lexer.TOKEN_IDENTIFIER &&
|
|
77
|
+
tokens.currentTokenType() === lexer_1.Lexer.TOKEN_IDENTIFIER) {
|
|
78
|
+
classConstantName += tokens.currentTokenValue();
|
|
79
|
+
tokens.consumeTokenType(lexer_1.Lexer.TOKEN_IDENTIFIER);
|
|
80
|
+
lastType = lexer_1.Lexer.TOKEN_IDENTIFIER;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (lastType !== lexer_1.Lexer.TOKEN_WILDCARD &&
|
|
84
|
+
tokens.tryConsumeTokenType(lexer_1.Lexer.TOKEN_WILDCARD)) {
|
|
85
|
+
classConstantName += '*';
|
|
86
|
+
lastType = lexer_1.Lexer.TOKEN_WILDCARD;
|
|
87
|
+
if (tokens.getSkippedHorizontalWhiteSpaceIfAny() !== '') {
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (lastType === null) {
|
|
93
|
+
tokens.consumeTokenType(lexer_1.Lexer.TOKEN_WILDCARD);
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
return this.enrichWithAttributes(tokens, new const_fetch_node_1.ConstFetchNode(identifier, classConstantName), startLine, startIndex);
|
|
98
|
+
}
|
|
99
|
+
return this.enrichWithAttributes(tokens, new const_fetch_node_1.ConstFetchNode('', identifier), startLine, startIndex);
|
|
100
|
+
}
|
|
101
|
+
if (tokens.tryConsumeTokenType(lexer_1.Lexer.TOKEN_OPEN_SQUARE_BRACKET)) {
|
|
102
|
+
return this.parseArray(tokens, lexer_1.Lexer.TOKEN_CLOSE_SQUARE_BRACKET, startIndex);
|
|
103
|
+
}
|
|
104
|
+
throw new parser_exception_1.ParserException(tokens.currentTokenValue(), tokens.currentTokenType(), tokens.currentTokenOffset(), lexer_1.Lexer.TOKEN_IDENTIFIER, null, tokens.currentTokenLine());
|
|
105
|
+
}
|
|
106
|
+
parseArray(tokens, endToken, startIndex) {
|
|
107
|
+
const items = [];
|
|
108
|
+
const startLine = tokens.currentTokenLine();
|
|
109
|
+
if (!tokens.tryConsumeTokenType(endToken)) {
|
|
110
|
+
do {
|
|
111
|
+
items.push(this.parseArrayItem(tokens));
|
|
112
|
+
} while (tokens.tryConsumeTokenType(lexer_1.Lexer.TOKEN_COMMA) &&
|
|
113
|
+
!tokens.isCurrentTokenType(endToken));
|
|
114
|
+
tokens.consumeTokenType(endToken);
|
|
115
|
+
}
|
|
116
|
+
return this.enrichWithAttributes(tokens, new const_expr_array_node_1.ConstExprArrayNode(items), startLine, startIndex);
|
|
117
|
+
}
|
|
118
|
+
parseArrayItem(tokens) {
|
|
119
|
+
const startLine = tokens.currentTokenLine();
|
|
120
|
+
const startIndex = tokens.currentTokenIndex();
|
|
121
|
+
const expr = this.parse(tokens);
|
|
122
|
+
let key;
|
|
123
|
+
let value;
|
|
124
|
+
if (tokens.tryConsumeTokenType(lexer_1.Lexer.TOKEN_DOUBLE_ARROW)) {
|
|
125
|
+
key = expr;
|
|
126
|
+
value = this.parse(tokens);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
key = null;
|
|
130
|
+
value = expr;
|
|
131
|
+
}
|
|
132
|
+
return this.enrichWithAttributes(tokens, new const_expr_array_item_node_1.ConstExprArrayItemNode(key, value), startLine, startIndex);
|
|
133
|
+
}
|
|
134
|
+
enrichWithAttributes(tokens, node, startLine, startIndex) {
|
|
135
|
+
if (this.useLinesAttributes) {
|
|
136
|
+
node.setAttribute(types_1.Attribute.START_LINE, startLine);
|
|
137
|
+
node.setAttribute(types_1.Attribute.END_LINE, tokens.currentTokenLine());
|
|
138
|
+
}
|
|
139
|
+
if (this.useIndexAttributes) {
|
|
140
|
+
node.setAttribute(types_1.Attribute.START_INDEX, startIndex);
|
|
141
|
+
node.setAttribute(types_1.Attribute.END_INDEX, tokens.endIndexOfLastRelevantToken());
|
|
142
|
+
}
|
|
143
|
+
return node;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.ConstExprParser = ConstExprParser;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AbstractNodeVisitor } from '../ast/abstract-node-visitor';
|
|
2
|
+
import { Node } from '../ast/node';
|
|
3
|
+
import { NodeTraverserEnterReturn } from '../ast/node-visitor';
|
|
4
|
+
export declare class NodeCollectingVisitor extends AbstractNodeVisitor {
|
|
5
|
+
nodes: Array<Node>;
|
|
6
|
+
enterNode(node: Node): NodeTraverserEnterReturn;
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeCollectingVisitor = void 0;
|
|
4
|
+
const abstract_node_visitor_1 = require("../ast/abstract-node-visitor");
|
|
5
|
+
class NodeCollectingVisitor extends abstract_node_visitor_1.AbstractNodeVisitor {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.nodes = [];
|
|
9
|
+
}
|
|
10
|
+
enterNode(node) {
|
|
11
|
+
this.nodes.push(node);
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.NodeCollectingVisitor = NodeCollectingVisitor;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class ParserException extends Error {
|
|
2
|
+
private currentTokenValue;
|
|
3
|
+
private currentTokenType;
|
|
4
|
+
private currentOffset;
|
|
5
|
+
private expectedTokenType;
|
|
6
|
+
private expectedTokenValue;
|
|
7
|
+
private currentTokenLine;
|
|
8
|
+
constructor(currentTokenValue: string, currentTokenType: string, currentOffset: number, expectedTokenType: string, expectedTokenValue?: string | null, currentTokenLine?: number | null);
|
|
9
|
+
getCurrentTokenValue(): string;
|
|
10
|
+
getCurrentTokenType(): string;
|
|
11
|
+
getCurrentOffset(): number;
|
|
12
|
+
getExpectedTokenType(): string;
|
|
13
|
+
getExpectedTokenValue(): string | null;
|
|
14
|
+
getCurrentTokenLine(): number | null;
|
|
15
|
+
private formatValue;
|
|
16
|
+
}
|