-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathEnumDefinition.ts
More file actions
35 lines (27 loc) · 903 Bytes
/
EnumDefinition.ts
File metadata and controls
35 lines (27 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const { NonterminalKind } = await import('@nomicfoundation/slang/cst');
import { SlangNode } from './SlangNode.js';
import { Identifier } from './Identifier.js';
import { EnumMembers } from './EnumMembers.js';
import type * as ast from '@nomicfoundation/slang/ast';
import type { AstPath, Doc } from 'prettier';
import type { PrintFunction } from '../types.d.ts';
export class EnumDefinition extends SlangNode {
readonly kind = NonterminalKind.EnumDefinition;
name: Identifier;
members: EnumMembers;
constructor(ast: ast.EnumDefinition) {
super(ast);
this.name = new Identifier(ast.name);
this.members = new EnumMembers(ast.members);
this.updateMetadata(this.members);
}
print(path: AstPath<EnumDefinition>, print: PrintFunction): Doc {
return [
'enum ',
path.call(print, 'name'),
' {',
path.call(print, 'members'),
'}'
];
}
}