shaderkit 0.2.1 → 0.3.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 +1 -1
- package/README.md +350 -153
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -14
- package/src/ast.ts +343 -77
- package/src/constants.ts +4 -4
- package/src/generator.ts +102 -150
- package/src/index.ts +6 -5
- package/src/minifier.ts +25 -8
- package/src/parser.ts +497 -405
- package/src/tokenizer.ts +24 -13
- package/dist/index.cjs +0 -5
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -14,32 +14,53 @@ Tools and IntelliSense for GLSL and WGSL.
|
|
|
14
14
|
- [Parse](#parse)
|
|
15
15
|
- [Generate](#generate)
|
|
16
16
|
- [AST](#ast)
|
|
17
|
-
- [
|
|
17
|
+
- [Node Objects](#node-objects)
|
|
18
18
|
- [Identifier](#identifier)
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
|
|
19
|
+
- [Literal](#literal)
|
|
20
|
+
- [ArraySpecifier](#arrayspecifier)
|
|
21
|
+
- [Program](#program)
|
|
22
|
+
- Statements
|
|
23
|
+
- [ExpressionStatement](#expressionstatement)
|
|
24
|
+
- [BlockStatement](#blockstatement)
|
|
25
|
+
- [DiscardStatement](#discardstatement)
|
|
26
|
+
- [PreprocessorStatement](#preprocessorstatement)
|
|
27
|
+
- [PrecisionStatement](#precisionstatement)
|
|
28
|
+
- Control Flow
|
|
29
|
+
- [ReturnStatement](#returnstatement)
|
|
30
|
+
- [BreakStatement](#breakstatement)
|
|
31
|
+
- [ContinueStatement](#continuestatement)
|
|
32
|
+
- Choice
|
|
33
|
+
- [IfStatement](#ifstatement)
|
|
34
|
+
- [SwitchStatement](#switchstatement)
|
|
35
|
+
- [SwitchCase](#switchcase)
|
|
36
|
+
- Loops
|
|
37
|
+
- [WhileStatement](#whilestatement)
|
|
38
|
+
- [DoWhileStatement](#dowhilestatement)
|
|
39
|
+
- [ForStatement](#forstatement)
|
|
40
|
+
- Declarations
|
|
41
|
+
- [FunctionDeclaration](#functiondeclaration)
|
|
42
|
+
- [FunctionParameter](#functionparameter)
|
|
43
|
+
- [VariableDeclaration](#variabledeclaration)
|
|
44
|
+
- [VariableDeclarator](#variabledeclarator)
|
|
45
|
+
- [UniformDeclarationBlock](#uniformdeclarationblock)
|
|
46
|
+
- [StructDeclaration](#structdeclaration)
|
|
47
|
+
- Expressions
|
|
48
|
+
- [ArrayExpression](#arrayexpression)
|
|
49
|
+
- Unary operations
|
|
50
|
+
- [UnaryExpression](#unaryexpression)
|
|
51
|
+
- [UnaryOperator](#unaryoperator)
|
|
52
|
+
- [UpdateExpression](#updateexpression)
|
|
53
|
+
- [UpdateOperator](#updateoperator)
|
|
54
|
+
- Binary Operations
|
|
55
|
+
- [BinaryExpression](#binaryexpression)
|
|
56
|
+
- [BinaryOperator](#binaryoperator)
|
|
57
|
+
- [AssignmentExpression](#assignmentexpression)
|
|
58
|
+
- [AssignmentOperator](#assignmentoperator)
|
|
59
|
+
- [LogicalExpression](#logicalexpression)
|
|
60
|
+
- [LogicalOperator](#logicaloperator)
|
|
61
|
+
- [MemberExpression](#memberexpression)
|
|
62
|
+
- [ConditionalExpression](#conditionalexpression)
|
|
63
|
+
- [CallExpression](#callexpression)
|
|
43
64
|
|
|
44
65
|
## Installation
|
|
45
66
|
|
|
@@ -231,7 +252,7 @@ minify(`#version 300 es\nin vec2 c;out vec4 data[gl_MaxDrawBuffers];void main(){
|
|
|
231
252
|
Parses a string of GLSL (WGSL is WIP) code into an [AST](#ast).
|
|
232
253
|
|
|
233
254
|
```ts
|
|
234
|
-
const ast:
|
|
255
|
+
const ast: Program = parse(code: string)
|
|
235
256
|
```
|
|
236
257
|
|
|
237
258
|
## Generate
|
|
@@ -239,7 +260,7 @@ const ast: AST[] = parse(code: string)
|
|
|
239
260
|
Generates a string of GLSL (WGSL is WIP) code from an [AST](#ast).
|
|
240
261
|
|
|
241
262
|
```ts
|
|
242
|
-
const code: string = generate(
|
|
263
|
+
const code: string = generate(program: Program, {
|
|
243
264
|
target: 'GLSL' // | 'WGSL'
|
|
244
265
|
})
|
|
245
266
|
```
|
|
@@ -248,188 +269,184 @@ const code: string = generate(ast: AST[], {
|
|
|
248
269
|
|
|
249
270
|
An [Abstract Syntax Tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree) loosely based on [ESTree](https://github.com/estree/estree) for GLSL and WGSL grammars.
|
|
250
271
|
|
|
251
|
-
###
|
|
272
|
+
### Node Objects
|
|
252
273
|
|
|
253
|
-
|
|
274
|
+
AST nodes extend `Node` objects which implement the following abstract interface:
|
|
254
275
|
|
|
255
276
|
```ts
|
|
256
|
-
|
|
257
|
-
|
|
277
|
+
interface Node {
|
|
278
|
+
type: string
|
|
258
279
|
}
|
|
259
280
|
```
|
|
260
281
|
|
|
282
|
+
The `type` field is a string representing the AST variant type which can determine the interface a node implements.
|
|
283
|
+
|
|
261
284
|
### Identifier
|
|
262
285
|
|
|
263
286
|
A variable identifier.
|
|
264
287
|
|
|
265
288
|
```ts
|
|
266
|
-
|
|
267
|
-
|
|
289
|
+
interface Identifier extends Node {
|
|
290
|
+
type: 'Identifier'
|
|
291
|
+
name: string
|
|
268
292
|
}
|
|
269
293
|
```
|
|
270
294
|
|
|
271
|
-
###
|
|
295
|
+
### Literal
|
|
272
296
|
|
|
273
|
-
|
|
297
|
+
A shader literal representing a `bool`, `float`, `int`, or `uint` type.
|
|
274
298
|
|
|
275
299
|
```ts
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
300
|
+
interface Literal extends Node {
|
|
301
|
+
type: 'Literal'
|
|
302
|
+
value: string
|
|
279
303
|
}
|
|
280
304
|
```
|
|
281
305
|
|
|
282
|
-
###
|
|
306
|
+
### ArraySpecifier
|
|
283
307
|
|
|
284
|
-
|
|
308
|
+
An array and its dimensions.
|
|
285
309
|
|
|
286
310
|
```ts
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
type: Type | Identifier
|
|
292
|
-
declarations: VariableDeclarator[]
|
|
311
|
+
interface ArraySpecifier extends Node {
|
|
312
|
+
type: 'ArraySpecifier'
|
|
313
|
+
typeSpecifier: Identifier
|
|
314
|
+
dimensions: (Literal | Identifier | null)[]
|
|
293
315
|
}
|
|
294
316
|
```
|
|
295
317
|
|
|
296
|
-
|
|
318
|
+
### Program
|
|
297
319
|
|
|
298
|
-
|
|
320
|
+
Represents the root of an AST.
|
|
299
321
|
|
|
300
322
|
```ts
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
323
|
+
interface Program extends Node {
|
|
324
|
+
type: 'Program'
|
|
325
|
+
body: Statement[]
|
|
304
326
|
}
|
|
305
327
|
```
|
|
306
328
|
|
|
307
|
-
###
|
|
329
|
+
### ExpressionStatement
|
|
308
330
|
|
|
309
|
-
|
|
331
|
+
An expression as a standalone statement.
|
|
310
332
|
|
|
311
333
|
```ts
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
334
|
+
interface ExpressionStatement extends Node {
|
|
335
|
+
type: 'ExpressionStatement'
|
|
336
|
+
expression: Expression
|
|
315
337
|
}
|
|
316
338
|
```
|
|
317
339
|
|
|
318
|
-
###
|
|
340
|
+
### BlockStatement
|
|
319
341
|
|
|
320
|
-
A
|
|
342
|
+
A block statement.
|
|
321
343
|
|
|
322
344
|
```ts
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
qualifiers: string[]
|
|
327
|
-
args: VariableDeclaration[]
|
|
328
|
-
body: BlockStatement | null
|
|
345
|
+
interface BlockStatement extends Node {
|
|
346
|
+
type: 'BlockStatement'
|
|
347
|
+
body: Statement[]
|
|
329
348
|
}
|
|
330
349
|
```
|
|
331
350
|
|
|
332
|
-
###
|
|
351
|
+
### DiscardStatement
|
|
333
352
|
|
|
334
|
-
A
|
|
353
|
+
A discard statement in fragment shaders.
|
|
335
354
|
|
|
336
355
|
```ts
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
left: AST | null
|
|
340
|
-
right: AST | null
|
|
356
|
+
interface DiscardStatement extends Node {
|
|
357
|
+
type: 'DiscardStatement'
|
|
341
358
|
}
|
|
342
359
|
```
|
|
343
360
|
|
|
344
|
-
###
|
|
361
|
+
### PreprocessorStatement
|
|
345
362
|
|
|
346
|
-
A
|
|
363
|
+
A GLSL preprocessor statement with an optional value.
|
|
347
364
|
|
|
348
365
|
```ts
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
366
|
+
interface PreprocessorStatement extends Node {
|
|
367
|
+
type: 'PreprocessorStatement'
|
|
368
|
+
name: string
|
|
369
|
+
value: Expression[] | null
|
|
353
370
|
}
|
|
354
371
|
```
|
|
355
372
|
|
|
356
|
-
###
|
|
373
|
+
### PrecisionStatement
|
|
357
374
|
|
|
358
|
-
A
|
|
375
|
+
A GLSL precision statement.
|
|
359
376
|
|
|
360
377
|
```ts
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
378
|
+
interface PrecisionStatement extends Node {
|
|
379
|
+
type: 'PrecisionStatement'
|
|
380
|
+
precision: PrecisionQualifier
|
|
381
|
+
typeSpecifier: Identifier
|
|
365
382
|
}
|
|
366
383
|
```
|
|
367
384
|
|
|
368
|
-
###
|
|
385
|
+
### ReturnStatement
|
|
369
386
|
|
|
370
|
-
A
|
|
387
|
+
A return statement with an optional argument.
|
|
371
388
|
|
|
372
389
|
```ts
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
390
|
+
interface ReturnStatement extends Node {
|
|
391
|
+
type: 'ReturnStatement'
|
|
392
|
+
argument: Expression | null
|
|
376
393
|
}
|
|
377
394
|
```
|
|
378
395
|
|
|
379
|
-
###
|
|
396
|
+
### BreakStatement
|
|
380
397
|
|
|
381
|
-
A
|
|
398
|
+
A break statement.
|
|
382
399
|
|
|
383
400
|
```ts
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
property: AST
|
|
401
|
+
interface BreakStatement extends Node {
|
|
402
|
+
type: 'BreakStatement'
|
|
387
403
|
}
|
|
388
404
|
```
|
|
389
405
|
|
|
390
|
-
###
|
|
406
|
+
### ContinueStatement
|
|
391
407
|
|
|
392
|
-
|
|
408
|
+
A continue statement.
|
|
393
409
|
|
|
394
410
|
```ts
|
|
395
|
-
|
|
396
|
-
type:
|
|
397
|
-
members: AST[]
|
|
411
|
+
interface ContinueStatement extends Node {
|
|
412
|
+
type: 'ContinueStatement'
|
|
398
413
|
}
|
|
399
414
|
```
|
|
400
415
|
|
|
401
|
-
###
|
|
416
|
+
### IfStatement
|
|
402
417
|
|
|
403
|
-
|
|
418
|
+
An if-else statement.
|
|
404
419
|
|
|
405
420
|
```ts
|
|
406
|
-
|
|
407
|
-
|
|
421
|
+
interface IfStatement extends Node {
|
|
422
|
+
type: 'IfStatement'
|
|
423
|
+
test: Expression
|
|
424
|
+
consequent: Statement
|
|
425
|
+
alternate: Statement | null
|
|
408
426
|
}
|
|
409
427
|
```
|
|
410
428
|
|
|
411
|
-
###
|
|
429
|
+
### SwitchStatement
|
|
412
430
|
|
|
413
|
-
|
|
431
|
+
A switch statement.
|
|
414
432
|
|
|
415
433
|
```ts
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
434
|
+
interface SwitchStatement extends Node {
|
|
435
|
+
type: 'SwitchStatement'
|
|
436
|
+
discriminant: Expression
|
|
437
|
+
cases: SwitchCase[]
|
|
420
438
|
}
|
|
421
439
|
```
|
|
422
440
|
|
|
423
|
-
|
|
441
|
+
#### SwitchCase
|
|
424
442
|
|
|
425
|
-
A
|
|
443
|
+
A switch-case statement. `test` is null for a `default` case.
|
|
426
444
|
|
|
427
445
|
```ts
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
test:
|
|
431
|
-
|
|
432
|
-
body: AST
|
|
446
|
+
interface SwitchCase extends Node {
|
|
447
|
+
type: 'SwitchCase'
|
|
448
|
+
test: Expression | null
|
|
449
|
+
consequent: Statement[]
|
|
433
450
|
}
|
|
434
451
|
```
|
|
435
452
|
|
|
@@ -438,9 +455,10 @@ class ForStatement {
|
|
|
438
455
|
A while statement.
|
|
439
456
|
|
|
440
457
|
```ts
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
458
|
+
interface WhileStatement extends Node {
|
|
459
|
+
type: 'WhileStatement'
|
|
460
|
+
test: Expression
|
|
461
|
+
body: Statement
|
|
444
462
|
}
|
|
445
463
|
```
|
|
446
464
|
|
|
@@ -449,86 +467,265 @@ class WhileStatement {
|
|
|
449
467
|
A do-while statement.
|
|
450
468
|
|
|
451
469
|
```ts
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
body:
|
|
470
|
+
interface DoWhileStatement extends Node {
|
|
471
|
+
type: 'DoWhileStatement'
|
|
472
|
+
body: Statement
|
|
473
|
+
test: Expression
|
|
455
474
|
}
|
|
456
475
|
```
|
|
457
476
|
|
|
458
|
-
###
|
|
477
|
+
### ForStatement
|
|
459
478
|
|
|
460
|
-
A
|
|
479
|
+
A for statement.
|
|
461
480
|
|
|
462
481
|
```ts
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
482
|
+
interface ForStatement extends Node {
|
|
483
|
+
type: 'ForStatement'
|
|
484
|
+
init: VariableDeclaration | Expression | null
|
|
485
|
+
test: Expression | null
|
|
486
|
+
update: Expression | null
|
|
487
|
+
body: Statement
|
|
466
488
|
}
|
|
467
489
|
```
|
|
468
490
|
|
|
469
|
-
|
|
491
|
+
### FunctionDeclaration
|
|
470
492
|
|
|
471
|
-
A
|
|
493
|
+
A function declaration. `body` is null for overloads.
|
|
472
494
|
|
|
473
495
|
```ts
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
496
|
+
interface FunctionDeclaration extends Node {
|
|
497
|
+
type: 'FunctionDeclaration'
|
|
498
|
+
id: Identifier
|
|
499
|
+
qualifiers: PrecisionQualifier[]
|
|
500
|
+
typeSpecifier: Identifier | ArraySpecifier
|
|
501
|
+
params: FunctionParameter[]
|
|
502
|
+
body: BlockStatement | null
|
|
477
503
|
}
|
|
478
504
|
```
|
|
479
505
|
|
|
480
|
-
|
|
506
|
+
#### FunctionParameter
|
|
481
507
|
|
|
482
|
-
A
|
|
508
|
+
A function parameter within a function declaration.
|
|
483
509
|
|
|
484
510
|
```ts
|
|
485
|
-
|
|
486
|
-
|
|
511
|
+
interface FunctionParameter extends Node {
|
|
512
|
+
type: 'FunctionParameter'
|
|
513
|
+
id: Identifier
|
|
514
|
+
qualifiers: (ConstantQualifier | ParameterQualifier | PrecisionQualifier)[]
|
|
515
|
+
typeSpecifier: Identifier | ArraySpecifier
|
|
487
516
|
}
|
|
488
517
|
```
|
|
489
518
|
|
|
490
|
-
###
|
|
519
|
+
### VariableDeclaration
|
|
491
520
|
|
|
492
|
-
A
|
|
521
|
+
A variable declaration.
|
|
493
522
|
|
|
494
523
|
```ts
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
524
|
+
interface VariableDeclaration extends Node {
|
|
525
|
+
type: 'VariableDeclaration'
|
|
526
|
+
declarations: VariableDeclarator[]
|
|
498
527
|
}
|
|
499
528
|
```
|
|
500
529
|
|
|
501
|
-
|
|
530
|
+
#### VariableDeclarator
|
|
502
531
|
|
|
503
|
-
A
|
|
532
|
+
A variable declarator within a variable declaration.
|
|
504
533
|
|
|
505
534
|
```ts
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
535
|
+
interface VariableDeclarator extends Node {
|
|
536
|
+
type: 'VariableDeclarator'
|
|
537
|
+
id: Identifier
|
|
538
|
+
qualifiers: (ConstantQualifier | InterpolationQualifier | StorageQualifier | PrecisionQualifier)[]
|
|
539
|
+
typeSpecifier: Identifier | ArraySpecifier
|
|
540
|
+
layout: Record<string, string | boolean> | null
|
|
541
|
+
init: Expression | null
|
|
509
542
|
}
|
|
510
543
|
```
|
|
511
544
|
|
|
512
|
-
###
|
|
545
|
+
### UniformDeclarationBlock
|
|
513
546
|
|
|
514
|
-
A
|
|
547
|
+
A uniform declaration block with optional layout and qualifiers.
|
|
515
548
|
|
|
516
549
|
```ts
|
|
517
|
-
|
|
550
|
+
interface UniformDeclarationBlock extends Node {
|
|
551
|
+
type: 'UniformDeclarationBlock'
|
|
552
|
+
id: Identifier | null
|
|
553
|
+
qualifiers: LayoutQualifier[]
|
|
554
|
+
typeSpecifier: Identifier | ArraySpecifier
|
|
555
|
+
layout: Record<string, string | boolean> | null
|
|
556
|
+
members: VariableDeclaration[]
|
|
557
|
+
}
|
|
518
558
|
```
|
|
519
559
|
|
|
520
|
-
###
|
|
560
|
+
### StructDeclaration
|
|
521
561
|
|
|
522
|
-
A
|
|
562
|
+
A struct declaration. Can be used as a type or constructor.
|
|
523
563
|
|
|
524
564
|
```ts
|
|
525
|
-
|
|
565
|
+
interface StructDeclaration extends Node {
|
|
566
|
+
type: 'StructDeclaration'
|
|
567
|
+
id: Identifier
|
|
568
|
+
members: VariableDeclaration[]
|
|
569
|
+
}
|
|
526
570
|
```
|
|
527
571
|
|
|
528
|
-
###
|
|
572
|
+
### ArrayExpression
|
|
573
|
+
|
|
574
|
+
An array initialization expression.
|
|
575
|
+
|
|
576
|
+
```ts
|
|
577
|
+
interface ArrayExpression extends Node {
|
|
578
|
+
type: 'ArrayExpression'
|
|
579
|
+
typeSpecifier: ArraySpecifier
|
|
580
|
+
elements: Expression[]
|
|
581
|
+
}
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
### UnaryExpression
|
|
585
|
+
|
|
586
|
+
A unary expression with a left or right handed operator.
|
|
587
|
+
|
|
588
|
+
```ts
|
|
589
|
+
interface UnaryExpression extends Node {
|
|
590
|
+
type: 'UnaryExpression'
|
|
591
|
+
operator: UnaryOperator
|
|
592
|
+
prefix: boolean
|
|
593
|
+
argument: Expression
|
|
594
|
+
}
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
#### UnaryOperator
|
|
598
|
+
|
|
599
|
+
```ts
|
|
600
|
+
type UnaryOperator = '-' | '+' | '!' | '~'
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
### UpdateExpression
|
|
604
|
+
|
|
605
|
+
An update expression with an optionally prefixed operator.
|
|
606
|
+
|
|
607
|
+
```ts
|
|
608
|
+
interface UpdateExpression extends Node {
|
|
609
|
+
type: 'UpdateExpression'
|
|
610
|
+
operator: UpdateOperator
|
|
611
|
+
argument: Expression
|
|
612
|
+
prefix: boolean
|
|
613
|
+
}
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
#### UpdateOperator
|
|
617
|
+
|
|
618
|
+
```ts
|
|
619
|
+
type UpdateOperator = '++' | '--'
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
### BinaryExpression
|
|
623
|
+
|
|
624
|
+
A binary expression with a left and right operand.
|
|
625
|
+
|
|
626
|
+
```ts
|
|
627
|
+
interface BinaryExpression extends Node {
|
|
628
|
+
type: 'BinaryExpression'
|
|
629
|
+
operator: BinaryOperator
|
|
630
|
+
left: Expression
|
|
631
|
+
right: Expression
|
|
632
|
+
}
|
|
633
|
+
```
|
|
529
634
|
|
|
530
|
-
|
|
635
|
+
#### BinaryOperator
|
|
531
636
|
|
|
532
637
|
```ts
|
|
533
|
-
|
|
638
|
+
type BinaryOperator =
|
|
639
|
+
| '=='
|
|
640
|
+
| '!='
|
|
641
|
+
| '<'
|
|
642
|
+
| '<='
|
|
643
|
+
| '>'
|
|
644
|
+
| '>='
|
|
645
|
+
| '<<'
|
|
646
|
+
| '>>'
|
|
647
|
+
| '+'
|
|
648
|
+
| '-'
|
|
649
|
+
| '*'
|
|
650
|
+
| '/'
|
|
651
|
+
| '%'
|
|
652
|
+
| '|'
|
|
653
|
+
| '^'
|
|
654
|
+
| '&'
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
### AssignmentExpression
|
|
658
|
+
|
|
659
|
+
An assignment expression.
|
|
660
|
+
|
|
661
|
+
```ts
|
|
662
|
+
interface AssignmentExpression extends Node {
|
|
663
|
+
type: 'AssignmentExpression'
|
|
664
|
+
operator: AssignmentOperator
|
|
665
|
+
left: Expression
|
|
666
|
+
right: Expression
|
|
667
|
+
}
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
#### AssignmentOperator
|
|
671
|
+
|
|
672
|
+
```ts
|
|
673
|
+
type AssignmentOperator = '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '<<=' | '>>=' | '>>>=' | '|=' | '^=' | '&='
|
|
674
|
+
```
|
|
675
|
+
|
|
676
|
+
### LogicalExpression
|
|
677
|
+
|
|
678
|
+
A logical operation between two expressions.
|
|
679
|
+
|
|
680
|
+
```ts
|
|
681
|
+
interface LogicalExpression extends Node {
|
|
682
|
+
type: 'LogicalExpression'
|
|
683
|
+
operator: LogicalOperator
|
|
684
|
+
left: Expression
|
|
685
|
+
right: Expression
|
|
686
|
+
}
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
#### LogicalOperator
|
|
690
|
+
|
|
691
|
+
```ts
|
|
692
|
+
type LogicalOperator = '||' | '&&' | '^^'
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
### MemberExpression
|
|
696
|
+
|
|
697
|
+
A member expression.
|
|
698
|
+
|
|
699
|
+
```ts
|
|
700
|
+
interface MemberExpression extends Node {
|
|
701
|
+
type: 'MemberExpression'
|
|
702
|
+
object: Expression
|
|
703
|
+
property: Expression
|
|
704
|
+
computed: boolean
|
|
705
|
+
}
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
### ConditionalExpression
|
|
709
|
+
|
|
710
|
+
A conditional expression or ternary.
|
|
711
|
+
|
|
712
|
+
```ts
|
|
713
|
+
interface ConditionalExpression extends Node {
|
|
714
|
+
type: 'ConditionalExpression'
|
|
715
|
+
test: Expression
|
|
716
|
+
alternate: Expression
|
|
717
|
+
consequent: Expression
|
|
718
|
+
}
|
|
719
|
+
```
|
|
720
|
+
|
|
721
|
+
### CallExpression
|
|
722
|
+
|
|
723
|
+
A function call expression or struct initialization.
|
|
724
|
+
|
|
725
|
+
```ts
|
|
726
|
+
interface CallExpression extends Node {
|
|
727
|
+
type: 'CallExpression'
|
|
728
|
+
callee: Expression
|
|
729
|
+
arguments: Expression[]
|
|
730
|
+
}
|
|
534
731
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from '../src'
|
|
1
|
+
export * from '../src/index.ts'
|