@adminide-stack/extension-api 0.0.2-alpha.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/LICENSE +39 -0
- package/README.md +9 -0
- package/lib/connections/jsonrpc2/connection.d.ts +55 -0
- package/lib/connections/jsonrpc2/connection.js +575 -0
- package/lib/connections/jsonrpc2/connection.js.map +1 -0
- package/lib/connections/jsonrpc2/connection.test.d.ts +1 -0
- package/lib/connections/jsonrpc2/connection.test.js +443 -0
- package/lib/connections/jsonrpc2/connection.test.js.map +1 -0
- package/lib/connections/jsonrpc2/events.d.ts +24 -0
- package/lib/connections/jsonrpc2/events.js +117 -0
- package/lib/connections/jsonrpc2/events.js.map +1 -0
- package/lib/connections/jsonrpc2/index.d.ts +5 -0
- package/lib/connections/jsonrpc2/index.js +24 -0
- package/lib/connections/jsonrpc2/index.js.map +1 -0
- package/lib/connections/jsonrpc2/linkedMap.d.ts +29 -0
- package/lib/connections/jsonrpc2/linkedMap.js +254 -0
- package/lib/connections/jsonrpc2/linkedMap.js.map +1 -0
- package/lib/connections/jsonrpc2/linkedMap.test.d.ts +1 -0
- package/lib/connections/jsonrpc2/linkedMap.test.js +62 -0
- package/lib/connections/jsonrpc2/linkedMap.test.js.map +1 -0
- package/lib/connections/jsonrpc2/messages.d.ts +117 -0
- package/lib/connections/jsonrpc2/messages.js +72 -0
- package/lib/connections/jsonrpc2/messages.js.map +1 -0
- package/lib/connections/jsonrpc2/test-helper.d.ts +8 -0
- package/lib/connections/jsonrpc2/test-helper.js +36 -0
- package/lib/connections/jsonrpc2/test-helper.js.map +1 -0
- package/lib/connections/jsonrpc2/trace.d.ts +30 -0
- package/lib/connections/jsonrpc2/trace.js +96 -0
- package/lib/connections/jsonrpc2/trace.js.map +1 -0
- package/lib/connections/jsonrpc2/transport.d.ts +36 -0
- package/lib/connections/jsonrpc2/transport.js +66 -0
- package/lib/connections/jsonrpc2/transport.js.map +1 -0
- package/lib/connections/jsonrpc2/transports/browser-websocket.d.ts +0 -0
- package/lib/connections/jsonrpc2/transports/browser-websocket.js +189 -0
- package/lib/connections/jsonrpc2/transports/browser-websocket.js.map +1 -0
- package/lib/connections/jsonrpc2/transports/merged.d.ts +0 -0
- package/lib/connections/jsonrpc2/transports/merged.js +239 -0
- package/lib/connections/jsonrpc2/transports/merged.js.map +1 -0
- package/lib/connections/jsonrpc2/transports/webSocket.d.ts +0 -0
- package/lib/connections/jsonrpc2/transports/webSocket.js +138 -0
- package/lib/connections/jsonrpc2/transports/webSocket.js.map +1 -0
- package/lib/connections/jsonrpc2/transports/webWorker.d.ts +22 -0
- package/lib/connections/jsonrpc2/transports/webWorker.js +111 -0
- package/lib/connections/jsonrpc2/transports/webWorker.js.map +1 -0
- package/lib/connections/proxy/index.d.ts +1 -0
- package/lib/connections/proxy/index.js +18 -0
- package/lib/connections/proxy/index.js.map +1 -0
- package/lib/connections/proxy/proxy.d.ts +49 -0
- package/lib/connections/proxy/proxy.js +108 -0
- package/lib/connections/proxy/proxy.js.map +1 -0
- package/lib/connections/proxy/proxy.test.d.ts +1 -0
- package/lib/connections/proxy/proxy.test.js +55 -0
- package/lib/connections/proxy/proxy.test.js.map +1 -0
- package/lib/connections/remote-rpc/browser-remote-rpc.d.ts +12 -0
- package/lib/connections/remote-rpc/browser-remote-rpc.js +62 -0
- package/lib/connections/remote-rpc/browser-remote-rpc.js.map +1 -0
- package/lib/connections/remote-rpc/browser-server-rpc.test.d.ts +0 -0
- package/lib/connections/remote-rpc/browser-server-rpc.test.js +317 -0
- package/lib/connections/remote-rpc/browser-server-rpc.test.js.map +1 -0
- package/lib/connections/remote-rpc/index.d.ts +1 -0
- package/lib/connections/remote-rpc/index.js +18 -0
- package/lib/connections/remote-rpc/index.js.map +1 -0
- package/lib/connections/remote-rpc/old-browser-remote-rpc.d.ts +12 -0
- package/lib/connections/remote-rpc/old-browser-remote-rpc.js +41 -0
- package/lib/connections/remote-rpc/old-browser-remote-rpc.js.map +1 -0
- package/lib/connections/remote-rpc/rxjs-websockets.d.ts +18 -0
- package/lib/connections/remote-rpc/rxjs-websockets.js +80 -0
- package/lib/connections/remote-rpc/rxjs-websockets.js.map +1 -0
- package/lib/constants/action-types.d.ts +30 -0
- package/lib/constants/action-types.js +38 -0
- package/lib/constants/action-types.js.map +1 -0
- package/lib/constants/index.d.ts +2 -0
- package/lib/constants/index.js +19 -0
- package/lib/constants/index.js.map +1 -0
- package/lib/constants/types.d.ts +8 -0
- package/lib/constants/types.js +12 -0
- package/lib/constants/types.js.map +1 -0
- package/lib/core/expr/evaluator.d.ts +27 -0
- package/lib/core/expr/evaluator.js +144 -0
- package/lib/core/expr/evaluator.js.map +1 -0
- package/lib/core/expr/evaluator.test.d.ts +1 -0
- package/lib/core/expr/evaluator.test.js +52 -0
- package/lib/core/expr/evaluator.test.js.map +1 -0
- package/lib/core/expr/index.d.ts +3 -0
- package/lib/core/expr/index.js +20 -0
- package/lib/core/expr/index.js.map +1 -0
- package/lib/core/expr/lexer.d.ts +114 -0
- package/lib/core/expr/lexer.js +418 -0
- package/lib/core/expr/lexer.js.map +1 -0
- package/lib/core/expr/parser.d.ts +52 -0
- package/lib/core/expr/parser.js +242 -0
- package/lib/core/expr/parser.js.map +1 -0
- package/lib/core/index.d.ts +2 -0
- package/lib/core/index.js +19 -0
- package/lib/core/index.js.map +1 -0
- package/lib/core/types/ext-host-types-bk.d.ts +0 -0
- package/lib/core/types/ext-host-types-bk.js +1275 -0
- package/lib/core/types/ext-host-types-bk.js.map +1 -0
- package/lib/core/types/ext-host-types.d.ts +32 -0
- package/lib/core/types/ext-host-types.js +71 -0
- package/lib/core/types/ext-host-types.js.map +1 -0
- package/lib/core/types/index.d.ts +1 -0
- package/lib/core/types/index.js +18 -0
- package/lib/core/types/index.js.map +1 -0
- package/lib/errors/errors.d.ts +1 -0
- package/lib/errors/errors.js +13 -0
- package/lib/errors/errors.js.map +1 -0
- package/lib/errors/index.d.ts +1 -0
- package/lib/errors/index.js +18 -0
- package/lib/errors/index.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +24 -0
- package/lib/index.js.map +1 -0
- package/lib/interfaces/command.d.ts +28 -0
- package/lib/interfaces/command.js +3 -0
- package/lib/interfaces/command.js.map +1 -0
- package/lib/interfaces/configuration.d.ts +36 -0
- package/lib/interfaces/configuration.js +3 -0
- package/lib/interfaces/configuration.js.map +1 -0
- package/lib/interfaces/connection.d.ts +12 -0
- package/lib/interfaces/connection.js +3 -0
- package/lib/interfaces/connection.js.map +1 -0
- package/lib/interfaces/context.d.ts +12 -0
- package/lib/interfaces/context.js +3 -0
- package/lib/interfaces/context.js.map +1 -0
- package/lib/interfaces/contributions/contribution-service.d.ts +20 -0
- package/lib/interfaces/contributions/contribution-service.js +3 -0
- package/lib/interfaces/contributions/contribution-service.js.map +1 -0
- package/lib/interfaces/contributions/contribution.d.ts +383 -0
- package/lib/interfaces/contributions/contribution.js +49 -0
- package/lib/interfaces/contributions/contribution.js.map +1 -0
- package/lib/interfaces/contributions/index.d.ts +2 -0
- package/lib/interfaces/contributions/index.js +19 -0
- package/lib/interfaces/contributions/index.js.map +1 -0
- package/lib/interfaces/controller.d.ts +30 -0
- package/lib/interfaces/controller.js +3 -0
- package/lib/interfaces/controller.js.map +1 -0
- package/lib/interfaces/errors.d.ts +5 -0
- package/lib/interfaces/errors.js +3 -0
- package/lib/interfaces/errors.js.map +1 -0
- package/lib/interfaces/ext-services/contributon-registry.d.ts +45 -0
- package/lib/interfaces/ext-services/contributon-registry.js +3 -0
- package/lib/interfaces/ext-services/contributon-registry.js.map +1 -0
- package/lib/interfaces/ext-services/ext-services.d.ts +23 -0
- package/lib/interfaces/ext-services/ext-services.js +3 -0
- package/lib/interfaces/ext-services/ext-services.js.map +1 -0
- package/lib/interfaces/ext-services/extension-service.d.ts +8 -0
- package/lib/interfaces/ext-services/extension-service.js +3 -0
- package/lib/interfaces/ext-services/extension-service.js.map +1 -0
- package/lib/interfaces/ext-services/index.d.ts +8 -0
- package/lib/interfaces/ext-services/index.js +25 -0
- package/lib/interfaces/ext-services/index.js.map +1 -0
- package/lib/interfaces/ext-services/model-service.d.ts +89 -0
- package/lib/interfaces/ext-services/model-service.js +3 -0
- package/lib/interfaces/ext-services/model-service.js.map +1 -0
- package/lib/interfaces/ext-services/panel-view-registry.d.ts +21 -0
- package/lib/interfaces/ext-services/panel-view-registry.js +3 -0
- package/lib/interfaces/ext-services/panel-view-registry.js.map +1 -0
- package/lib/interfaces/ext-services/settings-service.d.ts +18 -0
- package/lib/interfaces/ext-services/settings-service.js +3 -0
- package/lib/interfaces/ext-services/settings-service.js.map +1 -0
- package/lib/interfaces/ext-services/view-service.d.ts +65 -0
- package/lib/interfaces/ext-services/view-service.js +4 -0
- package/lib/interfaces/ext-services/view-service.js.map +1 -0
- package/lib/interfaces/ext-services/viewer-service.d.ts +125 -0
- package/lib/interfaces/ext-services/viewer-service.js +5 -0
- package/lib/interfaces/ext-services/viewer-service.js.map +1 -0
- package/lib/interfaces/extension-manifest.d.ts +8 -0
- package/lib/interfaces/extension-manifest.js +3 -0
- package/lib/interfaces/extension-manifest.js.map +1 -0
- package/lib/interfaces/extension.d.ts +72 -0
- package/lib/interfaces/extension.js +3 -0
- package/lib/interfaces/extension.js.map +1 -0
- package/lib/interfaces/generated-models.d.ts +3716 -0
- package/lib/interfaces/generated-models.js +648 -0
- package/lib/interfaces/generated-models.js.map +1 -0
- package/lib/interfaces/graphql.d.ts +17 -0
- package/lib/interfaces/graphql.js +5 -0
- package/lib/interfaces/graphql.js.map +1 -0
- package/lib/interfaces/index.d.ts +21 -0
- package/lib/interfaces/index.js +38 -0
- package/lib/interfaces/index.js.map +1 -0
- package/lib/interfaces/languages-types.d.ts +65 -0
- package/lib/interfaces/languages-types.js +3 -0
- package/lib/interfaces/languages-types.js.map +1 -0
- package/lib/interfaces/model.d.ts +51 -0
- package/lib/interfaces/model.js +9 -0
- package/lib/interfaces/model.js.map +1 -0
- package/lib/interfaces/plain-types.d.ts +4 -0
- package/lib/interfaces/plain-types.js +6 -0
- package/lib/interfaces/plain-types.js.map +1 -0
- package/lib/interfaces/plainTypes.d.ts +68 -0
- package/lib/interfaces/plainTypes.js +3 -0
- package/lib/interfaces/plainTypes.js.map +1 -0
- package/lib/interfaces/platform-context.d.ts +82 -0
- package/lib/interfaces/platform-context.js +3 -0
- package/lib/interfaces/platform-context.js.map +1 -0
- package/lib/interfaces/react-props/action-item.d.ts +20 -0
- package/lib/interfaces/react-props/action-item.js +3 -0
- package/lib/interfaces/react-props/action-item.js.map +1 -0
- package/lib/interfaces/react-props/extension-controller.d.ts +11 -0
- package/lib/interfaces/react-props/extension-controller.js +3 -0
- package/lib/interfaces/react-props/extension-controller.js.map +1 -0
- package/lib/interfaces/react-props/index.d.ts +3 -0
- package/lib/interfaces/react-props/index.js +20 -0
- package/lib/interfaces/react-props/index.js.map +1 -0
- package/lib/interfaces/react-props/platform-context.d.ts +7 -0
- package/lib/interfaces/react-props/platform-context.js +3 -0
- package/lib/interfaces/react-props/platform-context.js.map +1 -0
- package/lib/interfaces/registry-extension.d.ts +21 -0
- package/lib/interfaces/registry-extension.js +3 -0
- package/lib/interfaces/registry-extension.js.map +1 -0
- package/lib/interfaces/settings.d.ts +51 -0
- package/lib/interfaces/settings.js +3 -0
- package/lib/interfaces/settings.js.map +1 -0
- package/lib/interfaces/text-document.d.ts +57 -0
- package/lib/interfaces/text-document.js +119 -0
- package/lib/interfaces/text-document.js.map +1 -0
- package/lib/interfaces/webview/index.d.ts +3 -0
- package/lib/interfaces/webview/index.js +20 -0
- package/lib/interfaces/webview/index.js.map +1 -0
- package/lib/interfaces/webview/webview-manager-service.d.ts +22 -0
- package/lib/interfaces/webview/webview-manager-service.js +3 -0
- package/lib/interfaces/webview/webview-manager-service.js.map +1 -0
- package/lib/interfaces/webview/webview-port-mapping.d.ts +4 -0
- package/lib/interfaces/webview/webview-port-mapping.js +3 -0
- package/lib/interfaces/webview/webview-port-mapping.js.map +1 -0
- package/lib/interfaces/webview/webview.d.ts +99 -0
- package/lib/interfaces/webview/webview.js +9 -0
- package/lib/interfaces/webview/webview.js.map +1 -0
- package/lib/main.d.ts +0 -0
- package/lib/main.js +3 -0
- package/lib/main.js.map +1 -0
- package/lib/protocol/client.protocol.d.ts +99 -0
- package/lib/protocol/client.protocol.js +8 -0
- package/lib/protocol/client.protocol.js.map +1 -0
- package/lib/protocol/common.protocol.d.ts +289 -0
- package/lib/protocol/common.protocol.js +68 -0
- package/lib/protocol/common.protocol.js.map +1 -0
- package/lib/protocol/editor-missing-types.d.ts +87 -0
- package/lib/protocol/editor-missing-types.js +10 -0
- package/lib/protocol/editor-missing-types.js.map +1 -0
- package/lib/protocol/index.d.ts +6 -0
- package/lib/protocol/index.js +24 -0
- package/lib/protocol/index.js.map +1 -0
- package/lib/protocol/proxy-identifier.d.ts +51 -0
- package/lib/protocol/proxy-identifier.js +59 -0
- package/lib/protocol/proxy-identifier.js.map +1 -0
- package/lib/protocol/rpc-logger.d.ts +8 -0
- package/lib/protocol/rpc-logger.js +60 -0
- package/lib/protocol/rpc-logger.js.map +1 -0
- package/lib/protocol/rpc-protocol.d.ts +148 -0
- package/lib/protocol/rpc-protocol.js +750 -0
- package/lib/protocol/rpc-protocol.js.map +1 -0
- package/lib/protocol/rpc-protocol.test.d.ts +1 -0
- package/lib/protocol/rpc-protocol.test.js +171 -0
- package/lib/protocol/rpc-protocol.test.js.map +1 -0
- package/lib/protocol/server.protocol-bk.d.ts +0 -0
- package/lib/protocol/server.protocol-bk.js +719 -0
- package/lib/protocol/server.protocol-bk.js.map +1 -0
- package/lib/protocol/server.protocol.d.ts +91 -0
- package/lib/protocol/server.protocol.js +31 -0
- package/lib/protocol/server.protocol.js.map +1 -0
- package/lib/protocol/shared/editor.d.ts +4 -0
- package/lib/protocol/shared/editor.js +28 -0
- package/lib/protocol/shared/editor.js.map +1 -0
- package/lib/protocol/shared/tasks.d.ts +104 -0
- package/lib/protocol/shared/tasks.js +4 -0
- package/lib/protocol/shared/tasks.js.map +1 -0
- package/lib/protocol/temporary-types.d.ts +198 -0
- package/lib/protocol/temporary-types.js +30 -0
- package/lib/protocol/temporary-types.js.map +1 -0
- package/lib/protocol/utils/index.d.ts +1 -0
- package/lib/protocol/utils/index.js +18 -0
- package/lib/protocol/utils/index.js.map +1 -0
- package/lib/protocol/utils/lazy-promise.d.ts +18 -0
- package/lib/protocol/utils/lazy-promise.js +69 -0
- package/lib/protocol/utils/lazy-promise.js.map +1 -0
- package/lib/utils/errors.d.ts +6 -0
- package/lib/utils/errors.js +19 -0
- package/lib/utils/errors.js.map +1 -0
- package/lib/utils/extensions.d.ts +9 -0
- package/lib/utils/extensions.js +25 -0
- package/lib/utils/extensions.js.map +1 -0
- package/lib/utils/helper.test.d.ts +9 -0
- package/lib/utils/helper.test.js +15 -0
- package/lib/utils/helper.test.js.map +1 -0
- package/lib/utils/index.d.ts +7 -0
- package/lib/utils/index.js +25 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/paths-util.d.ts +27 -0
- package/lib/utils/paths-util.js +127 -0
- package/lib/utils/paths-util.js.map +1 -0
- package/lib/utils/rxjs/combineLatestOrDefault.d.ts +28 -0
- package/lib/utils/rxjs/combineLatestOrDefault.js +111 -0
- package/lib/utils/rxjs/combineLatestOrDefault.js.map +1 -0
- package/lib/utils/rxjs/combineLatestOrDefault.test.d.ts +1 -0
- package/lib/utils/rxjs/combineLatestOrDefault.test.js +52 -0
- package/lib/utils/rxjs/combineLatestOrDefault.test.js.map +1 -0
- package/lib/utils/rxjs/index.d.ts +1 -0
- package/lib/utils/rxjs/index.js +18 -0
- package/lib/utils/rxjs/index.js.map +1 -0
- package/lib/utils/util.d.ts +19 -0
- package/lib/utils/util.js +57 -0
- package/lib/utils/util.js.map +1 -0
- package/lib/worker-lib/MessageTypes.d.ts +5 -0
- package/lib/worker-lib/MessageTypes.js +9 -0
- package/lib/worker-lib/MessageTypes.js.map +1 -0
- package/lib/worker-lib/index.d.ts +2 -0
- package/lib/worker-lib/index.js +19 -0
- package/lib/worker-lib/index.js.map +1 -0
- package/lib/worker-lib/webWorkerLink.d.ts +12 -0
- package/lib/worker-lib/webWorkerLink.js +96 -0
- package/lib/worker-lib/webWorkerLink.js.map +1 -0
- package/lib/worker-lib/workerUtils.d.ts +11 -0
- package/lib/worker-lib/workerUtils.js +178 -0
- package/lib/worker-lib/workerUtils.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/** Valid token types in expressions. */
|
|
2
|
+
export declare enum TokenType {
|
|
3
|
+
/** An operator. */
|
|
4
|
+
Operator = 0,
|
|
5
|
+
/** An identifier. */
|
|
6
|
+
Identifier = 1,
|
|
7
|
+
/** A string literal. */
|
|
8
|
+
String = 2,
|
|
9
|
+
/**
|
|
10
|
+
* The start of a template until its first expression.
|
|
11
|
+
*
|
|
12
|
+
* See https://tc39.github.io/ecma262/#sec-template-literal-lexical-components for documentation on the
|
|
13
|
+
* ECMAScript lexical components for templates, upon which this is based.
|
|
14
|
+
*/
|
|
15
|
+
TemplateHead = 3,
|
|
16
|
+
/** The end of a previous template expression until the next template expression. */
|
|
17
|
+
TemplateMiddle = 4,
|
|
18
|
+
/** The end of a previous template expression until the end of the template. */
|
|
19
|
+
TemplateTail = 5,
|
|
20
|
+
/** A template with no substitutions. */
|
|
21
|
+
NoSubstitutionTemplate = 6,
|
|
22
|
+
/** A number literal. */
|
|
23
|
+
Number = 7
|
|
24
|
+
}
|
|
25
|
+
/** A token that the expression lexer scanned in an expression. */
|
|
26
|
+
export interface Token {
|
|
27
|
+
/** The type of this token. */
|
|
28
|
+
type: TokenType;
|
|
29
|
+
/**
|
|
30
|
+
* The token's value.
|
|
31
|
+
*
|
|
32
|
+
* For string and template literals, this is the parsed string value (after accounting for escape sequences but
|
|
33
|
+
* not template expressions). For number literals, this is the (unparsed) string representation.
|
|
34
|
+
*/
|
|
35
|
+
value: any;
|
|
36
|
+
/** The start character position of this token. */
|
|
37
|
+
start: number;
|
|
38
|
+
/** The end character position of this token. */
|
|
39
|
+
end: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* All valid operators in expressions. The values are the operator precedence (or, for operators that are not operators, 0). This
|
|
43
|
+
* must be kept in sync with OPERATOR_CHARS.
|
|
44
|
+
*
|
|
45
|
+
* Exported for testing only.
|
|
46
|
+
*/
|
|
47
|
+
export declare const OPERATORS: {
|
|
48
|
+
'(': number;
|
|
49
|
+
')': number;
|
|
50
|
+
'}': number;
|
|
51
|
+
',': number;
|
|
52
|
+
'=': number;
|
|
53
|
+
'||': number;
|
|
54
|
+
'&&': number;
|
|
55
|
+
'^': number;
|
|
56
|
+
'==': number;
|
|
57
|
+
'!=': number;
|
|
58
|
+
'===': number;
|
|
59
|
+
'!==': number;
|
|
60
|
+
'<': number;
|
|
61
|
+
'>': number;
|
|
62
|
+
'<=': number;
|
|
63
|
+
'>=': number;
|
|
64
|
+
'+': number;
|
|
65
|
+
'-': number;
|
|
66
|
+
'*': number;
|
|
67
|
+
'/': number;
|
|
68
|
+
'%': number;
|
|
69
|
+
'!': number;
|
|
70
|
+
};
|
|
71
|
+
/** All valid operators. */
|
|
72
|
+
export declare type Operator = keyof typeof OPERATORS;
|
|
73
|
+
export declare type OperatorTree = boolean | {
|
|
74
|
+
[ch: string]: OperatorTree;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* A tree with the next valid operator characters for multi-character operators. This must be kept in sync with
|
|
78
|
+
* OPERATORS.
|
|
79
|
+
*
|
|
80
|
+
* Exported for testing only.
|
|
81
|
+
*/
|
|
82
|
+
export declare const OPERATOR_CHARS: {
|
|
83
|
+
[ch: string]: OperatorTree;
|
|
84
|
+
};
|
|
85
|
+
/** Scans an expression. */
|
|
86
|
+
export declare class Lexer {
|
|
87
|
+
private expression;
|
|
88
|
+
private length;
|
|
89
|
+
protected _index: number;
|
|
90
|
+
private marker;
|
|
91
|
+
protected curlyStack: number;
|
|
92
|
+
/** The current character position of the lexer's cursor. */
|
|
93
|
+
get index(): number;
|
|
94
|
+
reset(string: string): void;
|
|
95
|
+
next(): Token | undefined;
|
|
96
|
+
peek(): Omit<Token, 'start' | 'end'> | undefined;
|
|
97
|
+
protected scanNext(): Token | undefined;
|
|
98
|
+
private peekNextChar;
|
|
99
|
+
private getNextChar;
|
|
100
|
+
private createToken;
|
|
101
|
+
private skipSpaces;
|
|
102
|
+
private scanOperator;
|
|
103
|
+
private scanIdentifier;
|
|
104
|
+
private scanString;
|
|
105
|
+
private scanTemplate;
|
|
106
|
+
protected backtick(): boolean;
|
|
107
|
+
protected doScanTemplate(head: boolean): Token;
|
|
108
|
+
private scanNumber;
|
|
109
|
+
}
|
|
110
|
+
/** Scans a template. */
|
|
111
|
+
export declare class TemplateLexer extends Lexer {
|
|
112
|
+
next(): Token | undefined;
|
|
113
|
+
protected backtick(): boolean;
|
|
114
|
+
}
|
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TemplateLexer = exports.Lexer = exports.OPERATOR_CHARS = exports.OPERATORS = exports.TokenType = void 0;
|
|
4
|
+
/** Valid token types in expressions. */
|
|
5
|
+
var TokenType;
|
|
6
|
+
(function (TokenType) {
|
|
7
|
+
/** An operator. */
|
|
8
|
+
TokenType[TokenType["Operator"] = 0] = "Operator";
|
|
9
|
+
/** An identifier. */
|
|
10
|
+
TokenType[TokenType["Identifier"] = 1] = "Identifier";
|
|
11
|
+
/** A string literal. */
|
|
12
|
+
TokenType[TokenType["String"] = 2] = "String";
|
|
13
|
+
/**
|
|
14
|
+
* The start of a template until its first expression.
|
|
15
|
+
*
|
|
16
|
+
* See https://tc39.github.io/ecma262/#sec-template-literal-lexical-components for documentation on the
|
|
17
|
+
* ECMAScript lexical components for templates, upon which this is based.
|
|
18
|
+
*/
|
|
19
|
+
TokenType[TokenType["TemplateHead"] = 3] = "TemplateHead";
|
|
20
|
+
/** The end of a previous template expression until the next template expression. */
|
|
21
|
+
TokenType[TokenType["TemplateMiddle"] = 4] = "TemplateMiddle";
|
|
22
|
+
/** The end of a previous template expression until the end of the template. */
|
|
23
|
+
TokenType[TokenType["TemplateTail"] = 5] = "TemplateTail";
|
|
24
|
+
/** A template with no substitutions. */
|
|
25
|
+
TokenType[TokenType["NoSubstitutionTemplate"] = 6] = "NoSubstitutionTemplate";
|
|
26
|
+
/** A number literal. */
|
|
27
|
+
TokenType[TokenType["Number"] = 7] = "Number";
|
|
28
|
+
})(TokenType = exports.TokenType || (exports.TokenType = {}));
|
|
29
|
+
/**
|
|
30
|
+
* All valid operators in expressions. The values are the operator precedence (or, for operators that are not operators, 0). This
|
|
31
|
+
* must be kept in sync with OPERATOR_CHARS.
|
|
32
|
+
*
|
|
33
|
+
* Exported for testing only.
|
|
34
|
+
*/
|
|
35
|
+
exports.OPERATORS = {
|
|
36
|
+
'(': 0,
|
|
37
|
+
')': 0,
|
|
38
|
+
'}': 0,
|
|
39
|
+
',': 0,
|
|
40
|
+
'=': 0,
|
|
41
|
+
'||': 1,
|
|
42
|
+
'&&': 2,
|
|
43
|
+
'^': 4,
|
|
44
|
+
'==': 6,
|
|
45
|
+
'!=': 6,
|
|
46
|
+
'===': 6,
|
|
47
|
+
'!==': 6,
|
|
48
|
+
'<': 7,
|
|
49
|
+
'>': 7,
|
|
50
|
+
'<=': 7,
|
|
51
|
+
'>=': 7,
|
|
52
|
+
'+': 9,
|
|
53
|
+
'-': 9,
|
|
54
|
+
'*': 10,
|
|
55
|
+
'/': 10,
|
|
56
|
+
'%': 10,
|
|
57
|
+
'!': 11,
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* A tree with the next valid operator characters for multi-character operators. This must be kept in sync with
|
|
61
|
+
* OPERATORS.
|
|
62
|
+
*
|
|
63
|
+
* Exported for testing only.
|
|
64
|
+
*/
|
|
65
|
+
exports.OPERATOR_CHARS = {
|
|
66
|
+
'&': { '&': true },
|
|
67
|
+
'|': { '|': true },
|
|
68
|
+
'=': {
|
|
69
|
+
'\u0000': true,
|
|
70
|
+
'=': {
|
|
71
|
+
'\u0000': true,
|
|
72
|
+
'=': true,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
'!': {
|
|
76
|
+
'\u0000': true,
|
|
77
|
+
'=': {
|
|
78
|
+
'\u0000': true,
|
|
79
|
+
'=': true,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
'<': { '\u0000': true, '=': true },
|
|
83
|
+
'>': { '\u0000': true, '=': true },
|
|
84
|
+
'^': true,
|
|
85
|
+
'}': true,
|
|
86
|
+
'(': true,
|
|
87
|
+
')': true,
|
|
88
|
+
',': true,
|
|
89
|
+
'+': true,
|
|
90
|
+
'-': true,
|
|
91
|
+
'*': true,
|
|
92
|
+
'/': true,
|
|
93
|
+
'%': true,
|
|
94
|
+
};
|
|
95
|
+
function isWhiteSpace(character) {
|
|
96
|
+
return character === '\u0009' || character === ' ' || character === '\u00A0';
|
|
97
|
+
}
|
|
98
|
+
function isLetter(character) {
|
|
99
|
+
return (character >= 'a' && character <= 'z') || (character >= 'A' && character <= 'Z');
|
|
100
|
+
}
|
|
101
|
+
function isDecimalDigit(character) {
|
|
102
|
+
return character >= '0' && character <= '9';
|
|
103
|
+
}
|
|
104
|
+
function isIdentifierStart(character) {
|
|
105
|
+
return character === '_' || isLetter(character);
|
|
106
|
+
}
|
|
107
|
+
function isIdentifierPart(character) {
|
|
108
|
+
return isIdentifierStart(character) || isDecimalDigit(character) || character === '.';
|
|
109
|
+
}
|
|
110
|
+
/** Scans an expression. */
|
|
111
|
+
class Lexer {
|
|
112
|
+
constructor() {
|
|
113
|
+
this.expression = '';
|
|
114
|
+
this.length = 0;
|
|
115
|
+
this._index = 0;
|
|
116
|
+
this.marker = 0;
|
|
117
|
+
this.curlyStack = 0;
|
|
118
|
+
}
|
|
119
|
+
/** The current character position of the lexer's cursor. */
|
|
120
|
+
get index() {
|
|
121
|
+
return this._index;
|
|
122
|
+
}
|
|
123
|
+
reset(string) {
|
|
124
|
+
this.expression = string;
|
|
125
|
+
this.length = string.length;
|
|
126
|
+
this._index = 0;
|
|
127
|
+
this.curlyStack = 0;
|
|
128
|
+
}
|
|
129
|
+
next() {
|
|
130
|
+
this.skipSpaces();
|
|
131
|
+
if (this._index >= this.length) {
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
this.marker = this._index;
|
|
135
|
+
const token = this.scanNext();
|
|
136
|
+
if (token !== undefined) {
|
|
137
|
+
return token;
|
|
138
|
+
}
|
|
139
|
+
throw new SyntaxError(`Unexpected character ${JSON.stringify(this.peekNextChar())} (at ${this.index})`);
|
|
140
|
+
}
|
|
141
|
+
peek() {
|
|
142
|
+
const savedIndex = this._index;
|
|
143
|
+
const savedCurlyStack = this.curlyStack;
|
|
144
|
+
let token;
|
|
145
|
+
try {
|
|
146
|
+
token = this.next();
|
|
147
|
+
}
|
|
148
|
+
catch (_a) {
|
|
149
|
+
token = undefined;
|
|
150
|
+
}
|
|
151
|
+
this._index = savedIndex;
|
|
152
|
+
this.curlyStack = savedCurlyStack;
|
|
153
|
+
if (!token) {
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
return { type: token.type, value: token.value };
|
|
157
|
+
}
|
|
158
|
+
scanNext() {
|
|
159
|
+
let token = this.scanString();
|
|
160
|
+
if (token !== undefined) {
|
|
161
|
+
return token;
|
|
162
|
+
}
|
|
163
|
+
token = this.scanTemplate();
|
|
164
|
+
if (token !== undefined) {
|
|
165
|
+
return token;
|
|
166
|
+
}
|
|
167
|
+
token = this.scanNumber();
|
|
168
|
+
if (token !== undefined) {
|
|
169
|
+
return token;
|
|
170
|
+
}
|
|
171
|
+
token = this.scanOperator();
|
|
172
|
+
if (token !== undefined) {
|
|
173
|
+
return token;
|
|
174
|
+
}
|
|
175
|
+
token = this.scanIdentifier();
|
|
176
|
+
if (token !== undefined) {
|
|
177
|
+
return token;
|
|
178
|
+
}
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
181
|
+
peekNextChar(advance = 0) {
|
|
182
|
+
const index = this._index + advance;
|
|
183
|
+
return index < this.length ? this.expression.charAt(index) : '\u0000';
|
|
184
|
+
}
|
|
185
|
+
getNextChar() {
|
|
186
|
+
let character = '\u0000';
|
|
187
|
+
const index = this._index;
|
|
188
|
+
if (index < this.length) {
|
|
189
|
+
character = this.expression.charAt(index);
|
|
190
|
+
this._index += 1;
|
|
191
|
+
}
|
|
192
|
+
return character;
|
|
193
|
+
}
|
|
194
|
+
createToken(type, value) {
|
|
195
|
+
return {
|
|
196
|
+
type,
|
|
197
|
+
value,
|
|
198
|
+
start: this.marker,
|
|
199
|
+
end: this._index,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
skipSpaces() {
|
|
203
|
+
while (this._index < this.length) {
|
|
204
|
+
const character = this.peekNextChar();
|
|
205
|
+
if (!isWhiteSpace(character)) {
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
this.getNextChar();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
scanOperator() {
|
|
212
|
+
let searchTree = exports.OPERATOR_CHARS;
|
|
213
|
+
let value = '';
|
|
214
|
+
while (searchTree && searchTree !== true) {
|
|
215
|
+
const character = this.peekNextChar();
|
|
216
|
+
searchTree = searchTree[character];
|
|
217
|
+
if (searchTree) {
|
|
218
|
+
value += character;
|
|
219
|
+
this.getNextChar();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (value === '}') {
|
|
223
|
+
this.curlyStack--;
|
|
224
|
+
}
|
|
225
|
+
if (value === '') {
|
|
226
|
+
return undefined;
|
|
227
|
+
}
|
|
228
|
+
return this.createToken(TokenType.Operator, value);
|
|
229
|
+
}
|
|
230
|
+
scanIdentifier() {
|
|
231
|
+
let character = this.peekNextChar();
|
|
232
|
+
if (!isIdentifierStart(character)) {
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
let id = this.getNextChar();
|
|
236
|
+
while (true) {
|
|
237
|
+
character = this.peekNextChar();
|
|
238
|
+
if (!isIdentifierPart(character)) {
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
id += this.getNextChar();
|
|
242
|
+
}
|
|
243
|
+
return this.createToken(TokenType.Identifier, id);
|
|
244
|
+
}
|
|
245
|
+
scanString() {
|
|
246
|
+
const quote = this.peekNextChar();
|
|
247
|
+
if (quote !== "'" && quote !== '"') {
|
|
248
|
+
return undefined;
|
|
249
|
+
}
|
|
250
|
+
this.getNextChar();
|
|
251
|
+
let terminated = false;
|
|
252
|
+
let string = '';
|
|
253
|
+
while (this._index < this.length) {
|
|
254
|
+
const character = this.getNextChar();
|
|
255
|
+
if (character === quote) {
|
|
256
|
+
terminated = true;
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
if (character === '\\') {
|
|
260
|
+
string += backslashEscapeCodeString(this.getNextChar());
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
string += character;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
if (!terminated) {
|
|
267
|
+
throw new Error(`Unterminated string literal (at ${this.index})`);
|
|
268
|
+
}
|
|
269
|
+
return this.createToken(TokenType.String, string);
|
|
270
|
+
}
|
|
271
|
+
scanTemplate() {
|
|
272
|
+
const character = this.peekNextChar();
|
|
273
|
+
if (!(character === '`' || (character === '}' && this.curlyStack > 0))) {
|
|
274
|
+
return undefined;
|
|
275
|
+
}
|
|
276
|
+
this.getNextChar();
|
|
277
|
+
const head = character === '`';
|
|
278
|
+
return this.doScanTemplate(head);
|
|
279
|
+
}
|
|
280
|
+
backtick() {
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
doScanTemplate(head) {
|
|
284
|
+
let tail = false;
|
|
285
|
+
let terminated = false;
|
|
286
|
+
let hasSubstitution = false;
|
|
287
|
+
let string = '';
|
|
288
|
+
while (this._index < this.length) {
|
|
289
|
+
const character = this.getNextChar();
|
|
290
|
+
if (character === '`' && this.backtick()) {
|
|
291
|
+
tail = true;
|
|
292
|
+
terminated = true;
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
if (character === '\\') {
|
|
296
|
+
string += backslashEscapeCodeString(this.getNextChar());
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
if (character === '$') {
|
|
300
|
+
const character2 = this.peekNextChar();
|
|
301
|
+
if (character2 === '{') {
|
|
302
|
+
this.curlyStack++;
|
|
303
|
+
this.getNextChar();
|
|
304
|
+
terminated = true;
|
|
305
|
+
hasSubstitution = true;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
string += character;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (!head) {
|
|
313
|
+
this.curlyStack--;
|
|
314
|
+
}
|
|
315
|
+
if (this.backtick()) {
|
|
316
|
+
if (!terminated) {
|
|
317
|
+
throw new Error(`Unterminated template literal (at ${this.index})`);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
else if (this._index === this.length) {
|
|
321
|
+
tail = true;
|
|
322
|
+
}
|
|
323
|
+
let type;
|
|
324
|
+
if (head && terminated && !hasSubstitution) {
|
|
325
|
+
type = TokenType.NoSubstitutionTemplate;
|
|
326
|
+
}
|
|
327
|
+
else if (head) {
|
|
328
|
+
type = TokenType.TemplateHead;
|
|
329
|
+
}
|
|
330
|
+
else if (tail) {
|
|
331
|
+
type = TokenType.TemplateTail;
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
type = TokenType.TemplateMiddle;
|
|
335
|
+
}
|
|
336
|
+
return this.createToken(type, string);
|
|
337
|
+
}
|
|
338
|
+
scanNumber() {
|
|
339
|
+
let character = this.peekNextChar();
|
|
340
|
+
if (!isDecimalDigit(character) && character !== '.') {
|
|
341
|
+
return undefined;
|
|
342
|
+
}
|
|
343
|
+
let number = '';
|
|
344
|
+
if (character !== '.') {
|
|
345
|
+
number = this.getNextChar();
|
|
346
|
+
while (true) {
|
|
347
|
+
character = this.peekNextChar();
|
|
348
|
+
if (!isDecimalDigit(character)) {
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
number += this.getNextChar();
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
if (character === '.') {
|
|
355
|
+
number += this.getNextChar();
|
|
356
|
+
while (true) {
|
|
357
|
+
character = this.peekNextChar();
|
|
358
|
+
if (!isDecimalDigit(character)) {
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
number += this.getNextChar();
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (character === 'e' || character === 'E') {
|
|
365
|
+
number += this.getNextChar();
|
|
366
|
+
character = this.peekNextChar();
|
|
367
|
+
if (character === '+' || character === '-' || isDecimalDigit(character)) {
|
|
368
|
+
number += this.getNextChar();
|
|
369
|
+
while (true) {
|
|
370
|
+
character = this.peekNextChar();
|
|
371
|
+
if (!isDecimalDigit(character)) {
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
number += this.getNextChar();
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
character = `character ${JSON.stringify(character)}`;
|
|
379
|
+
if (this._index >= this.length) {
|
|
380
|
+
character = '<end>';
|
|
381
|
+
}
|
|
382
|
+
throw new SyntaxError(`Unexpected ${character} after the exponent sign (at ${this.index})`);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
if (number === '.') {
|
|
386
|
+
throw new SyntaxError(`Expected decimal digits after the dot sign (at ${this.index})`);
|
|
387
|
+
}
|
|
388
|
+
return this.createToken(TokenType.Number, number);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
exports.Lexer = Lexer;
|
|
392
|
+
/** Scans a template. */
|
|
393
|
+
class TemplateLexer extends Lexer {
|
|
394
|
+
next() {
|
|
395
|
+
if (this._index === 0) {
|
|
396
|
+
return this.doScanTemplate(true);
|
|
397
|
+
}
|
|
398
|
+
return super.next();
|
|
399
|
+
}
|
|
400
|
+
backtick() {
|
|
401
|
+
// The root is not surrounded with backticks.
|
|
402
|
+
return this.curlyStack !== 0;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
exports.TemplateLexer = TemplateLexer;
|
|
406
|
+
function backslashEscapeCodeString(character) {
|
|
407
|
+
switch (character) {
|
|
408
|
+
case 'n':
|
|
409
|
+
return '\n';
|
|
410
|
+
case 'r':
|
|
411
|
+
return '\r';
|
|
412
|
+
case 't':
|
|
413
|
+
return '\t';
|
|
414
|
+
default:
|
|
415
|
+
return character;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
//# sourceMappingURL=lexer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexer.js","sourceRoot":"","sources":["../../../src/core/expr/lexer.ts"],"names":[],"mappings":";;;AAAA,wCAAwC;AACxC,IAAY,SA6BX;AA7BD,WAAY,SAAS;IACjB,mBAAmB;IACnB,iDAAQ,CAAA;IAER,qBAAqB;IACrB,qDAAU,CAAA;IAEV,wBAAwB;IACxB,6CAAM,CAAA;IAEN;;;;;OAKG;IACH,yDAAY,CAAA;IAEZ,oFAAoF;IACpF,6DAAc,CAAA;IAEd,+EAA+E;IAC/E,yDAAY,CAAA;IAEZ,wCAAwC;IACxC,6EAAsB,CAAA;IAEtB,wBAAwB;IACxB,6CAAM,CAAA;AACV,CAAC,EA7BW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QA6BpB;AAsBD;;;;;GAKG;AACU,QAAA,SAAS,GAAG;IACrB,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;IACR,GAAG,EAAE,CAAC;IACN,GA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aACJ;iBAAM;gBACH,SAAS,GAAG,aAAa,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAA;gBACpD,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE;oBAC5B,SAAS,GAAG,OAAO,CAAA;iBACtB;gBACD,MAAM,IAAI,WAAW,CAAC,cAAc,SAAS,gCAAgC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAA;aAC9F;SACJ;QAED,IAAI,MAAM,KAAK,GAAG,EAAE;YAChB,MAAM,IAAI,WAAW,CAAC,kDAAkD,IAAI,CAAC,KAAK,GAAG,CAAC,CAAA;SACzF;QAED,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrD,CAAC;CACJ;AAjTD,sBAiTC;AAED,wBAAwB;AACxB,MAAa,aAAc,SAAQ,KAAK;IAC7B,IAAI;QACP,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YACnB,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;SACnC;QACD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAA;IACvB,CAAC;IAES,QAAQ;QACd,6CAA6C;QAC7C,OAAO,IAAI,CAAC,UAAU,KAAK,CAAC,CAAA;IAChC,CAAC;CACJ;AAZD,sCAYC;AAED,SAAS,yBAAyB,CAAC,SAAiB;IAChD,QAAQ,SAAS,EAAE;QACf,KAAK,GAAG;YACJ,OAAO,IAAI,CAAA;QACf,KAAK,GAAG;YACJ,OAAO,IAAI,CAAA;QACf,KAAK,GAAG;YACJ,OAAO,IAAI,CAAA;QACf;YACI,OAAO,SAAS,CAAA;KACvB;AACL,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Lexer, Operator, TokenType } from './lexer';
|
|
2
|
+
export declare type ExpressionNode = {
|
|
3
|
+
FunctionCall: {
|
|
4
|
+
name: string;
|
|
5
|
+
args: ExpressionNode[];
|
|
6
|
+
};
|
|
7
|
+
} | {
|
|
8
|
+
Identifier: string;
|
|
9
|
+
} | {
|
|
10
|
+
Literal: {
|
|
11
|
+
type: TokenType.String | TokenType.Number;
|
|
12
|
+
value: string;
|
|
13
|
+
};
|
|
14
|
+
} | {
|
|
15
|
+
Template: {
|
|
16
|
+
parts: ExpressionNode[];
|
|
17
|
+
};
|
|
18
|
+
} | {
|
|
19
|
+
Unary: {
|
|
20
|
+
operator: Operator;
|
|
21
|
+
expression: ExpressionNode;
|
|
22
|
+
};
|
|
23
|
+
} | {
|
|
24
|
+
Binary: {
|
|
25
|
+
operator: Operator;
|
|
26
|
+
left: ExpressionNode;
|
|
27
|
+
right: ExpressionNode;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Parses an expression.
|
|
32
|
+
*
|
|
33
|
+
* TODO: Operator precedence is not handled correctly. Use parentheses to be explicit about your desired
|
|
34
|
+
* precedence.
|
|
35
|
+
*/
|
|
36
|
+
export declare class Parser {
|
|
37
|
+
protected lexer: Lexer;
|
|
38
|
+
parse(expressionString: string): ExpressionNode;
|
|
39
|
+
private parseArgumentList;
|
|
40
|
+
private parseFunctionCall;
|
|
41
|
+
private parseTemplateParts;
|
|
42
|
+
protected parseTemplate(): ExpressionNode;
|
|
43
|
+
private parsePrimary;
|
|
44
|
+
private parseUnary;
|
|
45
|
+
private parseMultiplicative;
|
|
46
|
+
private parseAdditive;
|
|
47
|
+
private parseExpression;
|
|
48
|
+
}
|
|
49
|
+
/** Parses a template. */
|
|
50
|
+
export declare class TemplateParser extends Parser {
|
|
51
|
+
parse(templateString: string): ExpressionNode;
|
|
52
|
+
}
|