@zenstackhq/language 0.6.0-pre.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 +21 -0
- package/ast.d.ts +2 -0
- package/ast.js +18 -0
- package/ast.js.map +1 -0
- package/generated/ast.d.ts +268 -0
- package/generated/ast.js +445 -0
- package/generated/ast.js.map +1 -0
- package/generated/grammar.d.ts +6 -0
- package/generated/grammar.js +2723 -0
- package/generated/grammar.js.map +1 -0
- package/generated/module.d.ts +8 -0
- package/generated/module.js +23 -0
- package/generated/module.js.map +1 -0
- package/grammar.d.ts +6 -0
- package/grammar.js +2723 -0
- package/grammar.js.map +1 -0
- package/module.d.ts +1 -0
- package/module.js +18 -0
- package/module.js.map +1 -0
- package/package.json +26 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 ZenStack
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/ast.d.ts
ADDED
package/ast.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./generated/ast"), exports);
|
|
18
|
+
//# sourceMappingURL=ast.js.map
|
package/ast.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC"}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
* This file was generated by langium-cli 0.5.0.
|
|
3
|
+
* DO NOT EDIT MANUALLY!
|
|
4
|
+
******************************************************************************/
|
|
5
|
+
import { AstNode, AstReflection, Reference, ReferenceInfo, TypeMetaData } from 'langium';
|
|
6
|
+
export type AbstractDeclaration = Attribute | DataModel | DataSource | Enum | Function | Generator | Plugin;
|
|
7
|
+
export declare const AbstractDeclaration = "AbstractDeclaration";
|
|
8
|
+
export declare function isAbstractDeclaration(item: unknown): item is AbstractDeclaration;
|
|
9
|
+
export type AttributeAttributeName = string;
|
|
10
|
+
export type AttributeName = string;
|
|
11
|
+
export type BuiltinType = 'BigInt' | 'Boolean' | 'Bytes' | 'DateTime' | 'Decimal' | 'Float' | 'Int' | 'Json' | 'String';
|
|
12
|
+
export type DataModelAttributeName = string;
|
|
13
|
+
export type DataModelFieldAttributeName = string;
|
|
14
|
+
export type Expression = ArrayExpr | BinaryExpr | InvocationExpr | LiteralExpr | MemberAccessExpr | NullExpr | ReferenceExpr | ThisExpr | UnaryExpr;
|
|
15
|
+
export declare const Expression = "Expression";
|
|
16
|
+
export declare function isExpression(item: unknown): item is Expression;
|
|
17
|
+
export type ExpressionType = 'Any' | 'Boolean' | 'DateTime' | 'Float' | 'Int' | 'Null' | 'String';
|
|
18
|
+
export type ReferenceTarget = DataModelField | EnumField | FunctionParam;
|
|
19
|
+
export declare const ReferenceTarget = "ReferenceTarget";
|
|
20
|
+
export declare function isReferenceTarget(item: unknown): item is ReferenceTarget;
|
|
21
|
+
export type TypeDeclaration = DataModel | Enum;
|
|
22
|
+
export declare const TypeDeclaration = "TypeDeclaration";
|
|
23
|
+
export declare function isTypeDeclaration(item: unknown): item is TypeDeclaration;
|
|
24
|
+
export interface Argument extends AstNode {
|
|
25
|
+
readonly $container: InvocationExpr;
|
|
26
|
+
name?: string;
|
|
27
|
+
value: Expression;
|
|
28
|
+
}
|
|
29
|
+
export declare const Argument = "Argument";
|
|
30
|
+
export declare function isArgument(item: unknown): item is Argument;
|
|
31
|
+
export interface ArrayExpr extends AstNode {
|
|
32
|
+
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | Function | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
|
|
33
|
+
items: Array<Expression>;
|
|
34
|
+
}
|
|
35
|
+
export declare const ArrayExpr = "ArrayExpr";
|
|
36
|
+
export declare function isArrayExpr(item: unknown): item is ArrayExpr;
|
|
37
|
+
export interface Attribute extends AstNode {
|
|
38
|
+
readonly $container: Model;
|
|
39
|
+
attributes: Array<AttributeAttribute>;
|
|
40
|
+
name: AttributeName;
|
|
41
|
+
params: Array<AttributeParam>;
|
|
42
|
+
}
|
|
43
|
+
export declare const Attribute = "Attribute";
|
|
44
|
+
export declare function isAttribute(item: unknown): item is Attribute;
|
|
45
|
+
export interface AttributeArg extends AstNode {
|
|
46
|
+
readonly $container: AttributeAttribute | DataModelAttribute | DataModelFieldAttribute;
|
|
47
|
+
name?: string;
|
|
48
|
+
value: Expression;
|
|
49
|
+
}
|
|
50
|
+
export declare const AttributeArg = "AttributeArg";
|
|
51
|
+
export declare function isAttributeArg(item: unknown): item is AttributeArg;
|
|
52
|
+
export interface AttributeAttribute extends AstNode {
|
|
53
|
+
readonly $container: Attribute;
|
|
54
|
+
args: Array<AttributeArg>;
|
|
55
|
+
decl: Reference<Attribute>;
|
|
56
|
+
}
|
|
57
|
+
export declare const AttributeAttribute = "AttributeAttribute";
|
|
58
|
+
export declare function isAttributeAttribute(item: unknown): item is AttributeAttribute;
|
|
59
|
+
export interface AttributeParam extends AstNode {
|
|
60
|
+
readonly $container: Attribute;
|
|
61
|
+
default: boolean;
|
|
62
|
+
name: string;
|
|
63
|
+
type: AttributeParamType;
|
|
64
|
+
}
|
|
65
|
+
export declare const AttributeParam = "AttributeParam";
|
|
66
|
+
export declare function isAttributeParam(item: unknown): item is AttributeParam;
|
|
67
|
+
export interface AttributeParamType extends AstNode {
|
|
68
|
+
readonly $container: AttributeParam;
|
|
69
|
+
array: boolean;
|
|
70
|
+
optional: boolean;
|
|
71
|
+
reference?: Reference<TypeDeclaration>;
|
|
72
|
+
type?: 'ContextType' | 'FieldReference' | ExpressionType;
|
|
73
|
+
}
|
|
74
|
+
export declare const AttributeParamType = "AttributeParamType";
|
|
75
|
+
export declare function isAttributeParamType(item: unknown): item is AttributeParamType;
|
|
76
|
+
export interface BinaryExpr extends AstNode {
|
|
77
|
+
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | Function | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
|
|
78
|
+
left: Expression;
|
|
79
|
+
operator: '!' | '!=' | '&&' | '<' | '<=' | '==' | '>' | '>=' | '?' | '^' | '||';
|
|
80
|
+
right: Expression;
|
|
81
|
+
}
|
|
82
|
+
export declare const BinaryExpr = "BinaryExpr";
|
|
83
|
+
export declare function isBinaryExpr(item: unknown): item is BinaryExpr;
|
|
84
|
+
export interface DataModel extends AstNode {
|
|
85
|
+
readonly $container: Model;
|
|
86
|
+
attributes: Array<DataModelAttribute>;
|
|
87
|
+
fields: Array<DataModelField>;
|
|
88
|
+
name: string;
|
|
89
|
+
}
|
|
90
|
+
export declare const DataModel = "DataModel";
|
|
91
|
+
export declare function isDataModel(item: unknown): item is DataModel;
|
|
92
|
+
export interface DataModelAttribute extends AstNode {
|
|
93
|
+
readonly $container: DataModel;
|
|
94
|
+
args: Array<AttributeArg>;
|
|
95
|
+
decl: Reference<Attribute>;
|
|
96
|
+
}
|
|
97
|
+
export declare const DataModelAttribute = "DataModelAttribute";
|
|
98
|
+
export declare function isDataModelAttribute(item: unknown): item is DataModelAttribute;
|
|
99
|
+
export interface DataModelField extends AstNode {
|
|
100
|
+
readonly $container: DataModel;
|
|
101
|
+
attributes: Array<DataModelFieldAttribute>;
|
|
102
|
+
name: string;
|
|
103
|
+
type: DataModelFieldType;
|
|
104
|
+
}
|
|
105
|
+
export declare const DataModelField = "DataModelField";
|
|
106
|
+
export declare function isDataModelField(item: unknown): item is DataModelField;
|
|
107
|
+
export interface DataModelFieldAttribute extends AstNode {
|
|
108
|
+
readonly $container: DataModelField;
|
|
109
|
+
args: Array<AttributeArg>;
|
|
110
|
+
decl: Reference<Attribute>;
|
|
111
|
+
}
|
|
112
|
+
export declare const DataModelFieldAttribute = "DataModelFieldAttribute";
|
|
113
|
+
export declare function isDataModelFieldAttribute(item: unknown): item is DataModelFieldAttribute;
|
|
114
|
+
export interface DataModelFieldType extends AstNode {
|
|
115
|
+
readonly $container: DataModelField;
|
|
116
|
+
array: boolean;
|
|
117
|
+
optional: boolean;
|
|
118
|
+
reference?: Reference<TypeDeclaration>;
|
|
119
|
+
type?: BuiltinType;
|
|
120
|
+
}
|
|
121
|
+
export declare const DataModelFieldType = "DataModelFieldType";
|
|
122
|
+
export declare function isDataModelFieldType(item: unknown): item is DataModelFieldType;
|
|
123
|
+
export interface DataSource extends AstNode {
|
|
124
|
+
readonly $container: Model;
|
|
125
|
+
fields: Array<DataSourceField>;
|
|
126
|
+
name: string;
|
|
127
|
+
}
|
|
128
|
+
export declare const DataSource = "DataSource";
|
|
129
|
+
export declare function isDataSource(item: unknown): item is DataSource;
|
|
130
|
+
export interface DataSourceField extends AstNode {
|
|
131
|
+
readonly $container: DataSource;
|
|
132
|
+
name: string;
|
|
133
|
+
value: InvocationExpr | LiteralExpr;
|
|
134
|
+
}
|
|
135
|
+
export declare const DataSourceField = "DataSourceField";
|
|
136
|
+
export declare function isDataSourceField(item: unknown): item is DataSourceField;
|
|
137
|
+
export interface Enum extends AstNode {
|
|
138
|
+
readonly $container: Model;
|
|
139
|
+
fields: Array<EnumField>;
|
|
140
|
+
name: string;
|
|
141
|
+
}
|
|
142
|
+
export declare const Enum = "Enum";
|
|
143
|
+
export declare function isEnum(item: unknown): item is Enum;
|
|
144
|
+
export interface EnumField extends AstNode {
|
|
145
|
+
readonly $container: Enum;
|
|
146
|
+
name: string;
|
|
147
|
+
}
|
|
148
|
+
export declare const EnumField = "EnumField";
|
|
149
|
+
export declare function isEnumField(item: unknown): item is EnumField;
|
|
150
|
+
export interface Function extends AstNode {
|
|
151
|
+
readonly $container: Model;
|
|
152
|
+
expression?: Expression;
|
|
153
|
+
name: string;
|
|
154
|
+
params: Array<FunctionParam>;
|
|
155
|
+
returnType: FunctionParamType;
|
|
156
|
+
}
|
|
157
|
+
export declare const Function = "Function";
|
|
158
|
+
export declare function isFunction(item: unknown): item is Function;
|
|
159
|
+
export interface FunctionParam extends AstNode {
|
|
160
|
+
readonly $container: Function;
|
|
161
|
+
name: string;
|
|
162
|
+
type: FunctionParamType;
|
|
163
|
+
}
|
|
164
|
+
export declare const FunctionParam = "FunctionParam";
|
|
165
|
+
export declare function isFunctionParam(item: unknown): item is FunctionParam;
|
|
166
|
+
export interface FunctionParamType extends AstNode {
|
|
167
|
+
readonly $container: Function | FunctionParam;
|
|
168
|
+
array: boolean;
|
|
169
|
+
reference?: Reference<TypeDeclaration>;
|
|
170
|
+
type?: ExpressionType;
|
|
171
|
+
}
|
|
172
|
+
export declare const FunctionParamType = "FunctionParamType";
|
|
173
|
+
export declare function isFunctionParamType(item: unknown): item is FunctionParamType;
|
|
174
|
+
export interface Generator extends AstNode {
|
|
175
|
+
readonly $container: Model;
|
|
176
|
+
fields: Array<GeneratorField>;
|
|
177
|
+
name: string;
|
|
178
|
+
}
|
|
179
|
+
export declare const Generator = "Generator";
|
|
180
|
+
export declare function isGenerator(item: unknown): item is Generator;
|
|
181
|
+
export interface GeneratorField extends AstNode {
|
|
182
|
+
readonly $container: Generator;
|
|
183
|
+
name: string;
|
|
184
|
+
value: ArrayExpr | LiteralExpr;
|
|
185
|
+
}
|
|
186
|
+
export declare const GeneratorField = "GeneratorField";
|
|
187
|
+
export declare function isGeneratorField(item: unknown): item is GeneratorField;
|
|
188
|
+
export interface InvocationExpr extends AstNode {
|
|
189
|
+
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | Function | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
|
|
190
|
+
args: Array<Argument>;
|
|
191
|
+
function: Reference<Function>;
|
|
192
|
+
}
|
|
193
|
+
export declare const InvocationExpr = "InvocationExpr";
|
|
194
|
+
export declare function isInvocationExpr(item: unknown): item is InvocationExpr;
|
|
195
|
+
export interface LiteralExpr extends AstNode {
|
|
196
|
+
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | Function | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
|
|
197
|
+
value: boolean | number | string;
|
|
198
|
+
}
|
|
199
|
+
export declare const LiteralExpr = "LiteralExpr";
|
|
200
|
+
export declare function isLiteralExpr(item: unknown): item is LiteralExpr;
|
|
201
|
+
export interface MemberAccessExpr extends AstNode {
|
|
202
|
+
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | Function | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
|
|
203
|
+
member: Reference<DataModelField>;
|
|
204
|
+
operand: Expression;
|
|
205
|
+
}
|
|
206
|
+
export declare const MemberAccessExpr = "MemberAccessExpr";
|
|
207
|
+
export declare function isMemberAccessExpr(item: unknown): item is MemberAccessExpr;
|
|
208
|
+
export interface Model extends AstNode {
|
|
209
|
+
declarations: Array<AbstractDeclaration>;
|
|
210
|
+
}
|
|
211
|
+
export declare const Model = "Model";
|
|
212
|
+
export declare function isModel(item: unknown): item is Model;
|
|
213
|
+
export interface NullExpr extends AstNode {
|
|
214
|
+
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | Function | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
|
|
215
|
+
value: string;
|
|
216
|
+
}
|
|
217
|
+
export declare const NullExpr = "NullExpr";
|
|
218
|
+
export declare function isNullExpr(item: unknown): item is NullExpr;
|
|
219
|
+
export interface Plugin extends AstNode {
|
|
220
|
+
readonly $container: Model;
|
|
221
|
+
fields: Array<PluginField>;
|
|
222
|
+
name: string;
|
|
223
|
+
}
|
|
224
|
+
export declare const Plugin = "Plugin";
|
|
225
|
+
export declare function isPlugin(item: unknown): item is Plugin;
|
|
226
|
+
export interface PluginField extends AstNode {
|
|
227
|
+
readonly $container: Plugin;
|
|
228
|
+
name: string;
|
|
229
|
+
value: ArrayExpr | LiteralExpr;
|
|
230
|
+
}
|
|
231
|
+
export declare const PluginField = "PluginField";
|
|
232
|
+
export declare function isPluginField(item: unknown): item is PluginField;
|
|
233
|
+
export interface ReferenceArg extends AstNode {
|
|
234
|
+
readonly $container: ReferenceExpr;
|
|
235
|
+
name: 'sort';
|
|
236
|
+
value: 'Asc' | 'Desc';
|
|
237
|
+
}
|
|
238
|
+
export declare const ReferenceArg = "ReferenceArg";
|
|
239
|
+
export declare function isReferenceArg(item: unknown): item is ReferenceArg;
|
|
240
|
+
export interface ReferenceExpr extends AstNode {
|
|
241
|
+
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | Function | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
|
|
242
|
+
args: Array<ReferenceArg>;
|
|
243
|
+
target: Reference<ReferenceTarget>;
|
|
244
|
+
}
|
|
245
|
+
export declare const ReferenceExpr = "ReferenceExpr";
|
|
246
|
+
export declare function isReferenceExpr(item: unknown): item is ReferenceExpr;
|
|
247
|
+
export interface ThisExpr extends AstNode {
|
|
248
|
+
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | Function | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
|
|
249
|
+
value: string;
|
|
250
|
+
}
|
|
251
|
+
export declare const ThisExpr = "ThisExpr";
|
|
252
|
+
export declare function isThisExpr(item: unknown): item is ThisExpr;
|
|
253
|
+
export interface UnaryExpr extends AstNode {
|
|
254
|
+
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | Function | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
|
|
255
|
+
operand: Expression;
|
|
256
|
+
operator: '!';
|
|
257
|
+
}
|
|
258
|
+
export declare const UnaryExpr = "UnaryExpr";
|
|
259
|
+
export declare function isUnaryExpr(item: unknown): item is UnaryExpr;
|
|
260
|
+
export type ZModelAstType = 'AbstractDeclaration' | 'Argument' | 'ArrayExpr' | 'Attribute' | 'AttributeArg' | 'AttributeAttribute' | 'AttributeParam' | 'AttributeParamType' | 'BinaryExpr' | 'DataModel' | 'DataModelAttribute' | 'DataModelField' | 'DataModelFieldAttribute' | 'DataModelFieldType' | 'DataSource' | 'DataSourceField' | 'Enum' | 'EnumField' | 'Expression' | 'Function' | 'FunctionParam' | 'FunctionParamType' | 'Generator' | 'GeneratorField' | 'InvocationExpr' | 'LiteralExpr' | 'MemberAccessExpr' | 'Model' | 'NullExpr' | 'Plugin' | 'PluginField' | 'ReferenceArg' | 'ReferenceExpr' | 'ReferenceTarget' | 'ThisExpr' | 'TypeDeclaration' | 'UnaryExpr';
|
|
261
|
+
export declare class ZModelAstReflection implements AstReflection {
|
|
262
|
+
getAllTypes(): string[];
|
|
263
|
+
isInstance(node: unknown, type: string): boolean;
|
|
264
|
+
isSubtype(subtype: string, supertype: string): boolean;
|
|
265
|
+
getReferenceType(refInfo: ReferenceInfo): string;
|
|
266
|
+
getTypeMetaData(type: string): TypeMetaData;
|
|
267
|
+
}
|
|
268
|
+
export declare const reflection: ZModelAstReflection;
|