@abapify/aclass 0.0.0 → 0.4.6

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.
@@ -0,0 +1,359 @@
1
+ import { ILexingError, IRecognitionException, IToken, Lexer } from "chevrotain";
2
+ //#region src/errors.d.ts
3
+ interface ParseError {
4
+ severity: 'error' | 'warning';
5
+ message: string;
6
+ line: number;
7
+ column: number;
8
+ offset: number;
9
+ length: number;
10
+ }
11
+ declare function fromLexError(err: ILexingError): ParseError;
12
+ declare function fromParseError(err: IRecognitionException): ParseError;
13
+ //#endregion
14
+ //#region src/ast.d.ts
15
+ /**
16
+ * Typed AST for `@abapify/aclass` — ABAP OO structural parser.
17
+ *
18
+ * Covers class / interface declarations, sections, and member
19
+ * declarations. Method-implementation bodies are preserved as opaque
20
+ * source slices; their statements are NOT modelled.
21
+ */
22
+ interface SourceSpan {
23
+ readonly startOffset: number;
24
+ readonly endOffset: number;
25
+ readonly startLine: number;
26
+ readonly startColumn: number;
27
+ }
28
+ type Visibility = 'public' | 'protected' | 'private';
29
+ type TypeRef = BuiltinTypeRef | NamedTypeRef | RefToTypeRef | TableTypeRef;
30
+ interface BuiltinTypeRef {
31
+ readonly kind: 'BuiltinTypeRef';
32
+ readonly name: string;
33
+ readonly source: string;
34
+ }
35
+ interface NamedTypeRef {
36
+ readonly kind: 'NamedTypeRef';
37
+ readonly name: string;
38
+ readonly source: string;
39
+ }
40
+ interface RefToTypeRef {
41
+ readonly kind: 'RefToTypeRef';
42
+ readonly target: TypeRef;
43
+ readonly source: string;
44
+ }
45
+ type TableKind = 'standard' | 'sorted' | 'hashed';
46
+ interface TableTypeRef {
47
+ readonly kind: 'TableTypeRef';
48
+ readonly tableKind: TableKind;
49
+ readonly row: TypeRef;
50
+ readonly keyClause: string;
51
+ readonly source: string;
52
+ }
53
+ interface MethodParam {
54
+ readonly kind: 'MethodParam';
55
+ readonly name: string;
56
+ readonly type: TypeRef;
57
+ readonly isValue: boolean;
58
+ readonly isOptional: boolean;
59
+ readonly defaultValue?: string;
60
+ readonly abapDoc?: readonly string[];
61
+ readonly span: SourceSpan;
62
+ }
63
+ type AbapDefinition = ClassDef | ClassImpl | InterfaceDef;
64
+ interface AbapSourceFile {
65
+ readonly kind: 'AbapSourceFile';
66
+ readonly source: string;
67
+ readonly definitions: readonly AbapDefinition[];
68
+ }
69
+ interface ClassDef {
70
+ readonly kind: 'ClassDef';
71
+ readonly name: string;
72
+ readonly abapDoc?: readonly string[];
73
+ readonly isFinal: boolean;
74
+ readonly isAbstract: boolean;
75
+ readonly isForTesting: boolean;
76
+ readonly createVisibility: Visibility;
77
+ readonly superClass?: string;
78
+ readonly sections: readonly Section[];
79
+ readonly span: SourceSpan;
80
+ }
81
+ interface Section {
82
+ readonly kind: 'Section';
83
+ readonly visibility: Visibility;
84
+ readonly members: readonly ClassMember[];
85
+ readonly span: SourceSpan;
86
+ }
87
+ type ClassMember = MethodDecl | AttributeDecl | TypeDecl | ConstantDecl | EventDecl | InterfaceStmt | AliasDecl | RawMember;
88
+ interface MethodDecl {
89
+ readonly kind: 'MethodDecl';
90
+ readonly name: string;
91
+ readonly abapDoc?: readonly string[];
92
+ readonly isClassMethod: boolean;
93
+ readonly isAbstract: boolean;
94
+ readonly isFinal: boolean;
95
+ readonly isRedefinition: boolean;
96
+ readonly isForTesting: boolean;
97
+ readonly importing: readonly MethodParam[];
98
+ readonly exporting: readonly MethodParam[];
99
+ readonly changing: readonly MethodParam[];
100
+ readonly returning?: MethodParam;
101
+ readonly raising: readonly string[];
102
+ readonly span: SourceSpan;
103
+ }
104
+ interface AttributeDecl {
105
+ readonly kind: 'AttributeDecl';
106
+ readonly name: string;
107
+ readonly abapDoc?: readonly string[];
108
+ readonly isClassData: boolean;
109
+ readonly isReadOnly: boolean;
110
+ readonly type: TypeRef;
111
+ readonly span: SourceSpan;
112
+ }
113
+ interface TypeDecl {
114
+ readonly kind: 'TypeDecl';
115
+ readonly name: string;
116
+ readonly abapDoc?: readonly string[];
117
+ readonly shape: TypeDeclShape;
118
+ readonly span: SourceSpan;
119
+ }
120
+ type TypeDeclShape = {
121
+ readonly kind: 'alias';
122
+ readonly type: TypeRef;
123
+ } | {
124
+ readonly kind: 'structure';
125
+ readonly fields: readonly StructureField[];
126
+ };
127
+ interface StructureField {
128
+ readonly kind: 'StructureField';
129
+ readonly name: string;
130
+ readonly type: TypeRef;
131
+ readonly abapDoc?: readonly string[];
132
+ readonly span: SourceSpan;
133
+ }
134
+ interface ConstantDecl {
135
+ readonly kind: 'ConstantDecl';
136
+ readonly name: string;
137
+ readonly type: TypeRef;
138
+ readonly value: string;
139
+ readonly abapDoc?: readonly string[];
140
+ readonly span: SourceSpan;
141
+ }
142
+ interface EventDecl {
143
+ readonly kind: 'EventDecl';
144
+ readonly name: string;
145
+ readonly abapDoc?: readonly string[];
146
+ /** True when the declaration is `CLASS-EVENTS`, false for instance-level `EVENTS`. */
147
+ readonly isClassEvent: boolean;
148
+ /**
149
+ * Parameters declared after `EXPORTING`. Each entry is a `MethodParam`
150
+ * for shape consistency with `MethodDecl.importing` / .exporting. Events
151
+ * only support `VALUE(...) TYPE <ref>` in practice; other slots are
152
+ * always empty for events.
153
+ */
154
+ readonly exporting: readonly MethodParam[];
155
+ readonly span: SourceSpan;
156
+ }
157
+ interface InterfaceStmt {
158
+ readonly kind: 'InterfaceStmt';
159
+ readonly name: string;
160
+ readonly abapDoc?: readonly string[];
161
+ readonly span: SourceSpan;
162
+ }
163
+ interface AliasDecl {
164
+ readonly kind: 'AliasDecl';
165
+ readonly name: string;
166
+ readonly target: string;
167
+ readonly abapDoc?: readonly string[];
168
+ readonly span: SourceSpan;
169
+ }
170
+ interface RawMember {
171
+ readonly kind: 'RawMember';
172
+ readonly source: string;
173
+ readonly abapDoc?: readonly string[];
174
+ readonly span: SourceSpan;
175
+ }
176
+ interface ClassImpl {
177
+ readonly kind: 'ClassImpl';
178
+ readonly name: string;
179
+ readonly methods: readonly MethodImpl[];
180
+ readonly span: SourceSpan;
181
+ }
182
+ interface MethodImpl {
183
+ readonly kind: 'MethodImpl';
184
+ readonly name: string;
185
+ readonly body: string;
186
+ readonly bodySpan: SourceSpan;
187
+ readonly span: SourceSpan;
188
+ }
189
+ interface InterfaceDef {
190
+ readonly kind: 'InterfaceDef';
191
+ readonly name: string;
192
+ readonly abapDoc?: readonly string[];
193
+ readonly isPublic: boolean;
194
+ readonly members: readonly ClassMember[];
195
+ readonly span: SourceSpan;
196
+ }
197
+ //#endregion
198
+ //#region src/parser.d.ts
199
+ interface ParseResult {
200
+ readonly ast: AbapSourceFile;
201
+ readonly errors: readonly ParseError[];
202
+ }
203
+ /**
204
+ * Parse an ABAP OO source file into a typed AST plus any diagnostics.
205
+ * Returns a `{ ast, errors }` shape; never throws for malformed input.
206
+ */
207
+ declare function parse(source: string): ParseResult;
208
+ declare namespace tokens_d_exports {
209
+ export { ABAPDocLine, Abstract, AclassLexer, Aliases, Ampersand, Arrow, As, At, BacktickLiteral, Begin, Changing, Class, ClassData, ClassEvents, ClassMethods, Colon, ColonColon, Comma, Constants, Create, Data, Default, Deferred, Definition, Dot, Duration, Empty, End, EndClass, EndInterface, EndMethod, Eq, Events, Exporting, FatArrow, Final, For, From, Gt, Hash, Hashed, Identifier, Implementation, Importing, Inheriting, IntegerLiteral, Interface, Interfaces, Key, LBrace, LBracket, LParen, Level, Like, LineComment, Load, Lt, Method, Methods, Minus, Newline, NonUnique, Of, Optional, Pipe, Plus, Private, Protected, Public, Question, RBrace, RBracket, RParen, Raising, ReadOnly, Redefinition, Ref, Returning, Risk, Section$1 as Section, Slash, Sorted, Standard, Star, StarComment, StringLiteral, Table, Testing, Tilde, To, Type, Types, Unique, Value, WhiteSpace, With, allTokens };
210
+ }
211
+ declare const WhiteSpace: import("chevrotain").TokenType;
212
+ declare const Newline: import("chevrotain").TokenType;
213
+ /**
214
+ * ABAPDoc line: `"! …` up to end of line. MUST come before LineComment
215
+ * because `"!` is a prefix of `"`.
216
+ */
217
+ declare const ABAPDocLine: import("chevrotain").TokenType;
218
+ /** Regular line comment: `" …` up to end of line. */
219
+ declare const LineComment: import("chevrotain").TokenType;
220
+ declare const StarComment: import("chevrotain").TokenType;
221
+ /** Single-quoted ABAP text literal: `'...'` with doubled `''` for escaping. */
222
+ declare const StringLiteral: import("chevrotain").TokenType;
223
+ /** Backtick string literal: \`...\`. */
224
+ declare const BacktickLiteral: import("chevrotain").TokenType;
225
+ declare const IntegerLiteral: import("chevrotain").TokenType;
226
+ /**
227
+ * ABAP identifier: starts with letter or underscore; may contain letters,
228
+ * digits, underscores, slash (for namespaces like `/ui2/cl_json`), and
229
+ * tilde (for qualified names like `zif_foo~method`) — but tilde is
230
+ * reserved for qualified references, so at the lexer level we only allow
231
+ * the "simple" form here. Qualified `~` and `=>` are handled in the
232
+ * parser via separate tokens.
233
+ *
234
+ * Note: the `=>` operator (static scope) is tokenised as a distinct
235
+ * symbol, not as part of the identifier.
236
+ */
237
+ declare const Identifier: import("chevrotain").TokenType;
238
+ declare const ClassMethods: import("chevrotain").TokenType;
239
+ declare const ClassData: import("chevrotain").TokenType;
240
+ declare const ClassEvents: import("chevrotain").TokenType;
241
+ declare const NonUnique: import("chevrotain").TokenType;
242
+ declare const Class: import("chevrotain").TokenType;
243
+ declare const Interfaces: import("chevrotain").TokenType;
244
+ declare const Interface: import("chevrotain").TokenType;
245
+ declare const EndClass: import("chevrotain").TokenType;
246
+ declare const EndInterface: import("chevrotain").TokenType;
247
+ declare const EndMethod: import("chevrotain").TokenType;
248
+ declare const Definition: import("chevrotain").TokenType;
249
+ declare const Implementation: import("chevrotain").TokenType;
250
+ declare const Deferred: import("chevrotain").TokenType;
251
+ declare const Load: import("chevrotain").TokenType;
252
+ declare const Public: import("chevrotain").TokenType;
253
+ declare const Protected: import("chevrotain").TokenType;
254
+ declare const Private: import("chevrotain").TokenType;
255
+ declare const Section$1: import("chevrotain").TokenType;
256
+ declare const Methods: import("chevrotain").TokenType;
257
+ declare const Method: import("chevrotain").TokenType;
258
+ declare const Data: import("chevrotain").TokenType;
259
+ declare const Types: import("chevrotain").TokenType;
260
+ declare const Constants: import("chevrotain").TokenType;
261
+ declare const Events: import("chevrotain").TokenType;
262
+ declare const Aliases: import("chevrotain").TokenType;
263
+ declare const Inheriting: import("chevrotain").TokenType;
264
+ declare const From: import("chevrotain").TokenType;
265
+ declare const For: import("chevrotain").TokenType;
266
+ declare const Testing: import("chevrotain").TokenType;
267
+ declare const Risk: import("chevrotain").TokenType;
268
+ declare const Level: import("chevrotain").TokenType;
269
+ declare const Duration: import("chevrotain").TokenType;
270
+ declare const Final: import("chevrotain").TokenType;
271
+ declare const Abstract: import("chevrotain").TokenType;
272
+ declare const Create: import("chevrotain").TokenType;
273
+ declare const Importing: import("chevrotain").TokenType;
274
+ declare const Exporting: import("chevrotain").TokenType;
275
+ declare const Changing: import("chevrotain").TokenType;
276
+ declare const Returning: import("chevrotain").TokenType;
277
+ declare const Raising: import("chevrotain").TokenType;
278
+ declare const Value: import("chevrotain").TokenType;
279
+ declare const Optional: import("chevrotain").TokenType;
280
+ declare const Default: import("chevrotain").TokenType;
281
+ declare const Redefinition: import("chevrotain").TokenType;
282
+ declare const Type: import("chevrotain").TokenType;
283
+ declare const Ref: import("chevrotain").TokenType;
284
+ declare const To: import("chevrotain").TokenType;
285
+ declare const Like: import("chevrotain").TokenType;
286
+ declare const Begin: import("chevrotain").TokenType;
287
+ declare const End: import("chevrotain").TokenType;
288
+ declare const Of: import("chevrotain").TokenType;
289
+ declare const Standard: import("chevrotain").TokenType;
290
+ declare const Sorted: import("chevrotain").TokenType;
291
+ declare const Hashed: import("chevrotain").TokenType;
292
+ declare const Table: import("chevrotain").TokenType;
293
+ declare const With: import("chevrotain").TokenType;
294
+ declare const Key: import("chevrotain").TokenType;
295
+ declare const Empty: import("chevrotain").TokenType;
296
+ declare const Unique: import("chevrotain").TokenType;
297
+ declare const As: import("chevrotain").TokenType;
298
+ declare const ReadOnly: import("chevrotain").TokenType;
299
+ /** Static scope operator: `=>` */
300
+ declare const FatArrow: import("chevrotain").TokenType;
301
+ /** Instance member operator: `->` */
302
+ declare const Arrow: import("chevrotain").TokenType;
303
+ /** Component selector inside generic reference: `::` (rare, reserved). */
304
+ declare const ColonColon: import("chevrotain").TokenType;
305
+ declare const Dot: import("chevrotain").TokenType;
306
+ declare const Comma: import("chevrotain").TokenType;
307
+ declare const Colon: import("chevrotain").TokenType;
308
+ declare const Tilde: import("chevrotain").TokenType;
309
+ declare const LParen: import("chevrotain").TokenType;
310
+ declare const RParen: import("chevrotain").TokenType;
311
+ declare const LBracket: import("chevrotain").TokenType;
312
+ declare const RBracket: import("chevrotain").TokenType;
313
+ declare const Eq: import("chevrotain").TokenType;
314
+ declare const Hash: import("chevrotain").TokenType;
315
+ declare const Pipe: import("chevrotain").TokenType;
316
+ declare const LBrace: import("chevrotain").TokenType;
317
+ declare const RBrace: import("chevrotain").TokenType;
318
+ declare const Plus: import("chevrotain").TokenType;
319
+ declare const Minus: import("chevrotain").TokenType;
320
+ declare const Star: import("chevrotain").TokenType;
321
+ declare const Slash: import("chevrotain").TokenType;
322
+ declare const Lt: import("chevrotain").TokenType;
323
+ declare const Gt: import("chevrotain").TokenType;
324
+ declare const Question: import("chevrotain").TokenType;
325
+ declare const At: import("chevrotain").TokenType;
326
+ declare const Ampersand: import("chevrotain").TokenType;
327
+ declare const allTokens: import("chevrotain").TokenType[];
328
+ declare const AclassLexer: Lexer;
329
+ //#endregion
330
+ //#region src/lex.d.ts
331
+ interface LexResult {
332
+ tokens: IToken[];
333
+ errors: ParseError[];
334
+ }
335
+ declare function tokenize(source: string): LexResult;
336
+ //#endregion
337
+ //#region src/assert.d.ts
338
+ declare class AclassParseError extends Error {
339
+ readonly source: string;
340
+ readonly errors: readonly ParseError[];
341
+ constructor(fileLabel: string, errors: readonly ParseError[], source: string);
342
+ }
343
+ /**
344
+ * Throw `AclassParseError` if the source has any lex / parse errors.
345
+ * `fileLabel` is included in the message so CI output points at the
346
+ * offending file without the caller having to format it.
347
+ *
348
+ * Intended use in test suites:
349
+ *
350
+ * ```ts
351
+ * for (const f of generated) {
352
+ * assertCleanParse(readFileSync(f, 'utf8'), f);
353
+ * }
354
+ * ```
355
+ */
356
+ declare function assertCleanParse(source: string, fileLabel?: string): void;
357
+ //#endregion
358
+ export { AbapDefinition, AbapSourceFile, AclassLexer, AclassParseError, AliasDecl, AttributeDecl, BuiltinTypeRef, ClassDef, ClassImpl, ClassMember, ConstantDecl, EventDecl, InterfaceDef, InterfaceStmt, type LexResult, MethodDecl, MethodImpl, MethodParam, NamedTypeRef, type ParseError, type ParseResult, RawMember, RefToTypeRef, Section, SourceSpan, StructureField, TableKind, TableTypeRef, TypeDecl, TypeDeclShape, TypeRef, Visibility, allTokens, assertCleanParse, fromLexError, fromParseError, parse, tokenize, tokens_d_exports as tokens };
359
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/errors.ts","../src/ast.ts","../src/parser.ts","../src/tokens.ts","../src/lex.ts","../src/assert.ts"],"mappings":";;UASiB;EACf;EACA;EACA;EACA;EACA;EACA;;iBAGc,aAAa,KAAK,eAAe;iBAWjC,eAAe,KAAK,wBAAwB;;;;;;;;;;UCrB3C;WACN;WACA;WACA;WACA;;KAGC;KAIA,UACR,iBACA,eACA,eACA;UAEa;WACN;WACA;WACA;;UAGM;WACN;WACA;WACA;;UAGM;WACN;WACA,QAAQ;WACR;;KAGC;UAEK;WACN;WACA,WAAW;WACX,KAAK;WACL;WACA;;UAGM;WACN;WACA;WACA,MAAM;WACN;WACA;WACA;WACA;WACA,MAAM;;KAKL,iBAAiB,WAAW,YAAY;UAEnC;WACN;WACA;WACA,sBAAsB;;UAGhB;WACN;WACA;WACA;WACA;WACA;WACA;WACA,kBAAkB;WAClB;WACA,mBAAmB;WACnB,MAAM;;UAGA;WACN;WACA,YAAY;WACZ,kBAAkB;WAClB,MAAM;;KAGL,cACR,aACA,gBACA,WAC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