Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/slang-nodes/AbicoderPragma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ import { SlangNode } from './SlangNode.js';
import { AbicoderVersion } from './AbicoderVersion.js';

import type * as ast from '@nomicfoundation/slang/ast';
import type { AstPath, Doc } from 'prettier';
import type { AstPath, Doc, ParserOptions } from 'prettier';
import type { PrintFunction } from '../types.d.ts';
import type { AstNode } from './types.d.ts';

export class AbicoderPragma extends SlangNode {
readonly kind = NonterminalKind.AbicoderPragma;

version: AbicoderVersion;

constructor(ast: ast.AbicoderPragma) {
super(ast);
constructor(ast: ast.AbicoderPragma, options: ParserOptions<AstNode>) {
super(ast, options);

this.version = new AbicoderVersion(ast.version);
this.version = new AbicoderVersion(ast.version, options);
}

print(path: AstPath<AbicoderPragma>, print: PrintFunction): Doc {
Expand Down
7 changes: 4 additions & 3 deletions src/slang-nodes/AbicoderVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import { NonterminalKind } from '@nomicfoundation/slang/cst';
import { SlangNode } from './SlangNode.js';

import type * as ast from '@nomicfoundation/slang/ast';
import type { Doc } from 'prettier';
import type { Doc, ParserOptions } from 'prettier';
import type { AstNode } from './types.d.ts';

export class AbicoderVersion extends SlangNode {
readonly kind = NonterminalKind.AbicoderVersion;

variant: string;

constructor(ast: ast.AbicoderVersion) {
super(ast);
constructor(ast: ast.AbicoderVersion, options: ParserOptions<AstNode>) {
super(ast, options);

this.variant = ast.variant.unparse();
}
Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/AdditiveExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class AdditiveExpression extends SlangNode {
rightOperand: Expression['variant'];

constructor(ast: ast.AdditiveExpression, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

this.leftOperand = extractVariant(new Expression(ast.leftOperand, options));
this.operator = ast.operator.unparse();
Expand Down
7 changes: 4 additions & 3 deletions src/slang-nodes/AddressType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import { NonterminalKind } from '@nomicfoundation/slang/cst';
import { SlangNode } from './SlangNode.js';

import type * as ast from '@nomicfoundation/slang/ast';
import type { Doc } from 'prettier';
import type { Doc, ParserOptions } from 'prettier';
import type { AstNode } from './types.d.ts';

export class AddressType extends SlangNode {
readonly kind = NonterminalKind.AddressType;

payableKeyword?: string;

constructor(ast: ast.AddressType) {
super(ast);
constructor(ast: ast.AddressType, options: ParserOptions<AstNode>) {
super(ast, options);

this.payableKeyword = ast.payableKeyword?.unparse();
}
Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/AndExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class AndExpression extends SlangNode {
rightOperand: Expression['variant'];

constructor(ast: ast.AndExpression, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

this.leftOperand = extractVariant(new Expression(ast.leftOperand, options));
this.operator = ast.operator.unparse();
Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/ArgumentsDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class ArgumentsDeclaration extends SlangNode {
variant: PositionalArgumentsDeclaration | NamedArgumentsDeclaration;

constructor(ast: ast.ArgumentsDeclaration, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

this.variant = createNonterminalVariant(ast.variant, options);

Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/ArrayExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class ArrayExpression extends SlangNode {
items: ArrayValues;

constructor(ast: ast.ArrayExpression, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

this.items = new ArrayValues(ast.items, options);
}
Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/ArrayTypeName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class ArrayTypeName extends SlangNode {
index?: Expression['variant'];

constructor(ast: ast.ArrayTypeName, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

this.operand = extractVariant(new TypeName(ast.operand, options));
if (ast.index) {
Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/ArrayValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class ArrayValues extends SlangNode {
items: Expression['variant'][];

constructor(ast: ast.ArrayValues, options: ParserOptions<AstNode>) {
super(ast, true);
super(ast, options, true);

this.items = ast.items.map((item) =>
extractVariant(new Expression(item, options))
Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/AssemblyFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class AssemblyFlags extends SlangNode {
items: StringLiteral[];

constructor(ast: ast.AssemblyFlags, options: ParserOptions<AstNode>) {
super(ast, true);
super(ast, options, true);

this.items = ast.items.map((item) => new StringLiteral(item, options));
}
Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/AssemblyFlagsDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class AssemblyFlagsDeclaration extends SlangNode {
ast: ast.AssemblyFlagsDeclaration,
options: ParserOptions<AstNode>
) {
super(ast);
super(ast, options);

this.flags = new AssemblyFlags(ast.flags, options);

Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/AssemblyStatement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class AssemblyStatement extends SlangNode {
body: YulBlock;

constructor(ast: ast.AssemblyStatement, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

if (ast.label) {
this.label = new StringLiteral(ast.label, options);
Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/AssignmentExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class AssignmentExpression extends SlangNode {
rightOperand: Expression['variant'];

constructor(ast: ast.AssignmentExpression, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

this.leftOperand = extractVariant(new Expression(ast.leftOperand, options));
this.operator = ast.operator.unparse();
Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/BitwiseAndExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class BitwiseAndExpression extends SlangNode {
rightOperand: Expression['variant'];

constructor(ast: ast.BitwiseAndExpression, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

this.leftOperand = extractVariant(new Expression(ast.leftOperand, options));
this.operator = ast.operator.unparse();
Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/BitwiseOrExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class BitwiseOrExpression extends SlangNode {
rightOperand: Expression['variant'];

constructor(ast: ast.BitwiseOrExpression, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

this.leftOperand = extractVariant(new Expression(ast.leftOperand, options));
this.operator = ast.operator.unparse();
Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/BitwiseXorExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class BitwiseXorExpression extends SlangNode {
rightOperand: Expression['variant'];

constructor(ast: ast.BitwiseXorExpression, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

this.leftOperand = extractVariant(new Expression(ast.leftOperand, options));
this.operator = ast.operator.unparse();
Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/Block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class Block extends SlangNode {
statements: Statements;

constructor(ast: ast.Block, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

this.statements = new Statements(ast.statements, options);

Expand Down
7 changes: 4 additions & 3 deletions src/slang-nodes/BreakStatement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import { NonterminalKind } from '@nomicfoundation/slang/cst';
import { SlangNode } from './SlangNode.js';

import type * as ast from '@nomicfoundation/slang/ast';
import type { Doc } from 'prettier';
import type { Doc, ParserOptions } from 'prettier';
import type { AstNode } from './types.d.ts';

export class BreakStatement extends SlangNode {
readonly kind = NonterminalKind.BreakStatement;

constructor(ast: ast.BreakStatement) {
super(ast);
constructor(ast: ast.BreakStatement, options: ParserOptions<AstNode>) {
super(ast, options);
}

print(): Doc {
Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/CallOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class CallOptions extends SlangNode {
items: NamedArgument[];

constructor(ast: ast.CallOptions, options: ParserOptions<AstNode>) {
super(ast, true);
super(ast, options, true);

this.items = ast.items.map((item) => new NamedArgument(item, options));
}
Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/CallOptionsExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class CallOptionsExpression extends SlangNode {
options: CallOptions;

constructor(ast: ast.CallOptionsExpression, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

this.operand = extractVariant(new Expression(ast.operand, options));
this.options = new CallOptions(ast.options, options);
Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/CatchClause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class CatchClause extends SlangNode {
body: Block;

constructor(ast: ast.CatchClause, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

if (ast.error) {
this.error = new CatchClauseError(ast.error, options);
Expand Down
4 changes: 2 additions & 2 deletions src/slang-nodes/CatchClauseError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export class CatchClauseError extends SlangNode {
parameters: ParametersDeclaration;

constructor(ast: ast.CatchClauseError, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

if (ast.name) {
this.name = new TerminalNode(ast.name);
this.name = new TerminalNode(ast.name, options);
}
this.parameters = new ParametersDeclaration(ast.parameters, options);

Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/CatchClauses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class CatchClauses extends SlangNode {
items: CatchClause[];

constructor(ast: ast.CatchClauses, options: ParserOptions<AstNode>) {
super(ast, true);
super(ast, options, true);

this.items = ast.items.map((item) => new CatchClause(item, options));

Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/ConditionalExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class ConditionalExpression extends SlangNode {
falseExpression: Expression['variant'];

constructor(ast: ast.ConditionalExpression, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

this.operand = extractVariant(new Expression(ast.operand, options));
this.trueExpression = extractVariant(
Expand Down
4 changes: 2 additions & 2 deletions src/slang-nodes/ConstantDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export class ConstantDefinition extends SlangNode {
value: Expression['variant'];

constructor(ast: ast.ConstantDefinition, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

this.typeName = extractVariant(new TypeName(ast.typeName, options));
this.name = new TerminalNode(ast.name);
this.name = new TerminalNode(ast.name, options);
this.value = extractVariant(new Expression(ast.value, options));

this.updateMetadata(this.typeName, this.value);
Expand Down
4 changes: 2 additions & 2 deletions src/slang-nodes/ConstructorAttribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export class ConstructorAttribute extends SlangNode {
variant: ModifierInvocation | TerminalNode;

constructor(ast: ast.ConstructorAttribute, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

const variant = ast.variant;
if (variant instanceof SlangTerminalNode) {
this.variant = new TerminalNode(variant);
this.variant = new TerminalNode(variant, options);
return;
}
this.variant = new ModifierInvocation(variant, options);
Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/ConstructorAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class ConstructorAttributes extends SlangNode {
items: ConstructorAttribute['variant'][];

constructor(ast: ast.ConstructorAttributes, options: ParserOptions<AstNode>) {
super(ast, true);
super(ast, options, true);

this.items = ast.items.map((item) =>
extractVariant(new ConstructorAttribute(item, options))
Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/ConstructorDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class ConstructorDefinition extends SlangNode {
body: Block;

constructor(ast: ast.ConstructorDefinition, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

this.parameters = new ParametersDeclaration(ast.parameters, options);
this.attributes = new ConstructorAttributes(ast.attributes, options);
Expand Down
7 changes: 4 additions & 3 deletions src/slang-nodes/ContinueStatement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import { NonterminalKind } from '@nomicfoundation/slang/cst';
import { SlangNode } from './SlangNode.js';

import type * as ast from '@nomicfoundation/slang/ast';
import type { Doc } from 'prettier';
import type { Doc, ParserOptions } from 'prettier';
import type { AstNode } from './types.d.ts';

export class ContinueStatement extends SlangNode {
readonly kind = NonterminalKind.ContinueStatement;

constructor(ast: ast.ContinueStatement) {
super(ast);
constructor(ast: ast.ContinueStatement, options: ParserOptions<AstNode>) {
super(ast, options);
}

print(): Doc {
Expand Down
4 changes: 2 additions & 2 deletions src/slang-nodes/ContractDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ export class ContractDefinition extends SlangNode {
members: ContractMembers;

constructor(ast: ast.ContractDefinition, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

this.abstractKeyword = ast.abstractKeyword?.unparse();
this.name = new TerminalNode(ast.name);
this.name = new TerminalNode(ast.name, options);
this.specifiers = new ContractSpecifiers(ast.specifiers, options);
this.members = new ContractMembers(ast.members, options);

Expand Down
6 changes: 3 additions & 3 deletions src/slang-nodes/ContractMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function createNonterminalVariant(
return new StructDefinition(variant, options);
}
if (variant instanceof ast.EnumDefinition) {
return new EnumDefinition(variant);
return new EnumDefinition(variant, options);
}
if (variant instanceof ast.EventDefinition) {
return new EventDefinition(variant, options);
Expand All @@ -59,7 +59,7 @@ function createNonterminalVariant(
return new ErrorDefinition(variant, options);
}
if (variant instanceof ast.UserDefinedValueTypeDefinition) {
return new UserDefinedValueTypeDefinition(variant);
return new UserDefinedValueTypeDefinition(variant, options);
}
const exhaustiveCheck: never = variant;
throw new Error(`Unexpected variant: ${JSON.stringify(exhaustiveCheck)}`);
Expand All @@ -84,7 +84,7 @@ export class ContractMember extends SlangNode {
| UserDefinedValueTypeDefinition;

constructor(ast: ast.ContractMember, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

this.variant = createNonterminalVariant(ast.variant, options);

Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/ContractMembers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class ContractMembers extends SlangNode {
items: ContractMember['variant'][];

constructor(ast: ast.ContractMembers, options: ParserOptions<AstNode>) {
super(ast, true);
super(ast, options, true);

this.items = ast.items.map((item) =>
extractVariant(new ContractMember(item, options))
Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/ContractSpecifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class ContractSpecifier extends SlangNode {
variant: InheritanceSpecifier | StorageLayoutSpecifier;

constructor(ast: ast.ContractSpecifier, options: ParserOptions<AstNode>) {
super(ast);
super(ast, options);

this.variant = createNonterminalVariant(ast.variant, options);

Expand Down
2 changes: 1 addition & 1 deletion src/slang-nodes/ContractSpecifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class ContractSpecifiers extends SlangNode {
items: ContractSpecifier['variant'][];

constructor(ast: ast.ContractSpecifiers, options: ParserOptions<AstNode>) {
super(ast, true);
super(ast, options, true);

this.items = ast.items.map((item) =>
extractVariant(new ContractSpecifier(item, options))
Expand Down
Loading