Skip to content

Commit 27ccf55

Browse files
committed
parser options should be a part of collected metadata to standardise all constructor signatures and depollute the class instantiations
1 parent 708700f commit 27ccf55

162 files changed

Lines changed: 501 additions & 1412 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/slang-nodes/AdditiveExpression.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,15 @@ export class AdditiveExpression extends SlangNode {
3535

3636
rightOperand: Expression['variant'];
3737

38-
constructor(
39-
ast: ast.AdditiveExpression,
40-
collected: CollectedMetadata,
41-
options: ParserOptions<PrintableNode>
42-
) {
38+
constructor(ast: ast.AdditiveExpression, collected: CollectedMetadata) {
4339
super(ast, collected);
4440

4541
this.leftOperand = extractVariant(
46-
new Expression(ast.leftOperand, collected, options)
42+
new Expression(ast.leftOperand, collected)
4743
);
4844
this.operator = ast.operator.unparse();
4945
this.rightOperand = extractVariant(
50-
new Expression(ast.rightOperand, collected, options)
46+
new Expression(ast.rightOperand, collected)
5147
);
5248

5349
this.updateMetadata(this.leftOperand, this.rightOperand);

src/slang-nodes/AndExpression.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,15 @@ export class AndExpression extends SlangNode {
1818

1919
rightOperand: Expression['variant'];
2020

21-
constructor(
22-
ast: ast.AndExpression,
23-
collected: CollectedMetadata,
24-
options: ParserOptions<PrintableNode>
25-
) {
21+
constructor(ast: ast.AndExpression, collected: CollectedMetadata) {
2622
super(ast, collected);
2723

2824
this.leftOperand = extractVariant(
29-
new Expression(ast.leftOperand, collected, options)
25+
new Expression(ast.leftOperand, collected)
3026
);
3127
this.operator = ast.operator.unparse();
3228
this.rightOperand = extractVariant(
33-
new Expression(ast.rightOperand, collected, options)
29+
new Expression(ast.rightOperand, collected)
3430
);
3531

3632
this.updateMetadata(this.leftOperand, this.rightOperand);

src/slang-nodes/ArgumentsDeclaration.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import { SlangNode } from './SlangNode.js';
55
import { PositionalArgumentsDeclaration } from './PositionalArgumentsDeclaration.js';
66
import { NamedArgumentsDeclaration } from './NamedArgumentsDeclaration.js';
77

8-
import type { ParserOptions } from 'prettier';
98
import type { CollectedMetadata } from '../types.d.ts';
10-
import type { PrintableNode } from './types.d.ts';
119

1210
const createNonterminalVariant = createNonterminalVariantSimpleCreator<
1311
ast.ArgumentsDeclaration,
@@ -22,14 +20,10 @@ export class ArgumentsDeclaration extends SlangNode {
2220

2321
variant: PositionalArgumentsDeclaration | NamedArgumentsDeclaration;
2422

25-
constructor(
26-
ast: ast.ArgumentsDeclaration,
27-
collected: CollectedMetadata,
28-
options: ParserOptions<PrintableNode>
29-
) {
23+
constructor(ast: ast.ArgumentsDeclaration, collected: CollectedMetadata) {
3024
super(ast, collected);
3125

32-
this.variant = createNonterminalVariant(ast.variant, collected, options);
26+
this.variant = createNonterminalVariant(ast.variant, collected);
3327

3428
this.updateMetadata(this.variant);
3529
}

src/slang-nodes/ArrayExpression.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,18 @@ import { SlangNode } from './SlangNode.js';
33
import { ArrayValues } from './ArrayValues.js';
44

55
import type * as ast from '@nomicfoundation/slang/ast';
6-
import type { Doc, ParserOptions } from 'prettier';
6+
import type { Doc } from 'prettier';
77
import type { CollectedMetadata, PrintFunction } from '../types.d.ts';
8-
import type { PrintableNode } from './types.d.ts';
98

109
export class ArrayExpression extends SlangNode {
1110
readonly kind = NonterminalKind.ArrayExpression;
1211

1312
items: ArrayValues;
1413

15-
constructor(
16-
ast: ast.ArrayExpression,
17-
collected: CollectedMetadata,
18-
options: ParserOptions<PrintableNode>
19-
) {
14+
constructor(ast: ast.ArrayExpression, collected: CollectedMetadata) {
2015
super(ast, collected);
2116

22-
this.items = new ArrayValues(ast.items, collected, options);
17+
this.items = new ArrayValues(ast.items, collected);
2318

2419
this.updateMetadata(this.items);
2520
}

src/slang-nodes/ArrayTypeName.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import { TypeName } from './TypeName.js';
55
import { Expression } from './Expression.js';
66

77
import type * as ast from '@nomicfoundation/slang/ast';
8-
import type { Doc, ParserOptions } from 'prettier';
8+
import type { Doc } from 'prettier';
99
import type { CollectedMetadata, PrintFunction } from '../types.d.ts';
10-
import type { PrintableNode } from './types.d.ts';
1110

1211
export class ArrayTypeName extends SlangNode {
1312
readonly kind = NonterminalKind.ArrayTypeName;
@@ -16,20 +15,12 @@ export class ArrayTypeName extends SlangNode {
1615

1716
index?: Expression['variant'];
1817

19-
constructor(
20-
ast: ast.ArrayTypeName,
21-
collected: CollectedMetadata,
22-
options: ParserOptions<PrintableNode>
23-
) {
18+
constructor(ast: ast.ArrayTypeName, collected: CollectedMetadata) {
2419
super(ast, collected);
2520

26-
this.operand = extractVariant(
27-
new TypeName(ast.operand, collected, options)
28-
);
21+
this.operand = extractVariant(new TypeName(ast.operand, collected));
2922
if (ast.index) {
30-
this.index = extractVariant(
31-
new Expression(ast.index, collected, options)
32-
);
23+
this.index = extractVariant(new Expression(ast.index, collected));
3324
}
3425

3526
this.updateMetadata(this.operand, this.index);

src/slang-nodes/ArrayValues.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,19 @@ import { SlangNode } from './SlangNode.js';
55
import { Expression } from './Expression.js';
66

77
import type * as ast from '@nomicfoundation/slang/ast';
8-
import type { AstPath, Doc, ParserOptions } from 'prettier';
8+
import type { AstPath, Doc } from 'prettier';
99
import type { CollectedMetadata, PrintFunction } from '../types.d.ts';
10-
import type { PrintableNode } from './types.d.ts';
1110

1211
export class ArrayValues extends SlangNode {
1312
readonly kind = NonterminalKind.ArrayValues;
1413

1514
items: Expression['variant'][];
1615

17-
constructor(
18-
ast: ast.ArrayValues,
19-
collected: CollectedMetadata,
20-
options: ParserOptions<PrintableNode>
21-
) {
16+
constructor(ast: ast.ArrayValues, collected: CollectedMetadata) {
2217
super(ast, collected, true);
2318

2419
this.items = ast.items.map((item) =>
25-
extractVariant(new Expression(item, collected, options))
20+
extractVariant(new Expression(item, collected))
2621
);
2722
}
2823

src/slang-nodes/AssemblyFlags.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,18 @@ import { SlangNode } from './SlangNode.js';
44
import { StringLiteral } from './StringLiteral.js';
55

66
import type * as ast from '@nomicfoundation/slang/ast';
7-
import type { AstPath, Doc, ParserOptions } from 'prettier';
7+
import type { AstPath, Doc } from 'prettier';
88
import type { CollectedMetadata, PrintFunction } from '../types.d.ts';
9-
import type { PrintableNode } from './types.d.ts';
109

1110
export class AssemblyFlags extends SlangNode {
1211
readonly kind = NonterminalKind.AssemblyFlags;
1312

1413
items: StringLiteral[];
1514

16-
constructor(
17-
ast: ast.AssemblyFlags,
18-
collected: CollectedMetadata,
19-
options: ParserOptions<PrintableNode>
20-
) {
15+
constructor(ast: ast.AssemblyFlags, collected: CollectedMetadata) {
2116
super(ast, collected, true);
2217

23-
this.items = ast.items.map(
24-
(item) => new StringLiteral(item, collected, options)
25-
);
18+
this.items = ast.items.map((item) => new StringLiteral(item, collected));
2619
}
2720

2821
print(print: PrintFunction, path: AstPath<AssemblyFlags>): Doc {

src/slang-nodes/AssemblyFlagsDeclaration.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,18 @@ import { SlangNode } from './SlangNode.js';
33
import { AssemblyFlags } from './AssemblyFlags.js';
44

55
import type * as ast from '@nomicfoundation/slang/ast';
6-
import type { Doc, ParserOptions } from 'prettier';
6+
import type { Doc } from 'prettier';
77
import type { CollectedMetadata, PrintFunction } from '../types.d.ts';
8-
import type { PrintableNode } from './types.d.ts';
98

109
export class AssemblyFlagsDeclaration extends SlangNode {
1110
readonly kind = NonterminalKind.AssemblyFlagsDeclaration;
1211

1312
flags: AssemblyFlags;
1413

15-
constructor(
16-
ast: ast.AssemblyFlagsDeclaration,
17-
collected: CollectedMetadata,
18-
options: ParserOptions<PrintableNode>
19-
) {
14+
constructor(ast: ast.AssemblyFlagsDeclaration, collected: CollectedMetadata) {
2015
super(ast, collected);
2116

22-
this.flags = new AssemblyFlags(ast.flags, collected, options);
17+
this.flags = new AssemblyFlags(ast.flags, collected);
2318

2419
this.updateMetadata(this.flags);
2520
}

src/slang-nodes/AssemblyStatement.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ import { AssemblyFlagsDeclaration } from './AssemblyFlagsDeclaration.js';
66
import { YulBlock } from './YulBlock.js';
77

88
import type * as ast from '@nomicfoundation/slang/ast';
9-
import type { Doc, ParserOptions } from 'prettier';
9+
import type { Doc } from 'prettier';
1010
import type { CollectedMetadata, PrintFunction } from '../types.d.ts';
11-
import type { PrintableNode } from './types.d.ts';
1211

1312
export class AssemblyStatement extends SlangNode {
1413
readonly kind = NonterminalKind.AssemblyStatement;
@@ -19,20 +18,16 @@ export class AssemblyStatement extends SlangNode {
1918

2019
body: YulBlock;
2120

22-
constructor(
23-
ast: ast.AssemblyStatement,
24-
collected: CollectedMetadata,
25-
options: ParserOptions<PrintableNode>
26-
) {
21+
constructor(ast: ast.AssemblyStatement, collected: CollectedMetadata) {
2722
super(ast, collected);
2823

2924
if (ast.label) {
30-
this.label = new StringLiteral(ast.label, collected, options);
25+
this.label = new StringLiteral(ast.label, collected);
3126
}
3227
if (ast.flags) {
33-
this.flags = new AssemblyFlagsDeclaration(ast.flags, collected, options);
28+
this.flags = new AssemblyFlagsDeclaration(ast.flags, collected);
3429
}
35-
this.body = new YulBlock(ast.body, collected, options);
30+
this.body = new YulBlock(ast.body, collected);
3631

3732
this.updateMetadata(this.label, this.flags, this.body);
3833
}

src/slang-nodes/AssignmentExpression.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import { SlangNode } from './SlangNode.js';
55
import { Expression } from './Expression.js';
66

77
import type * as ast from '@nomicfoundation/slang/ast';
8-
import type { Doc, ParserOptions } from 'prettier';
8+
import type { Doc } from 'prettier';
99
import type { CollectedMetadata, PrintFunction } from '../types.d.ts';
10-
import type { PrintableNode } from './types.d.ts';
1110

1211
export class AssignmentExpression extends SlangNode {
1312
readonly kind = NonterminalKind.AssignmentExpression;
@@ -18,19 +17,15 @@ export class AssignmentExpression extends SlangNode {
1817

1918
rightOperand: Expression['variant'];
2019

21-
constructor(
22-
ast: ast.AssignmentExpression,
23-
collected: CollectedMetadata,
24-
options: ParserOptions<PrintableNode>
25-
) {
20+
constructor(ast: ast.AssignmentExpression, collected: CollectedMetadata) {
2621
super(ast, collected);
2722

2823
this.leftOperand = extractVariant(
29-
new Expression(ast.leftOperand, collected, options)
24+
new Expression(ast.leftOperand, collected)
3025
);
3126
this.operator = ast.operator.unparse();
3227
this.rightOperand = extractVariant(
33-
new Expression(ast.rightOperand, collected, options)
28+
new Expression(ast.rightOperand, collected)
3429
);
3530

3631
this.updateMetadata(this.leftOperand, this.rightOperand);

0 commit comments

Comments
 (0)