-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathErrorDefinition.ts
More file actions
35 lines (27 loc) · 1.03 KB
/
ErrorDefinition.ts
File metadata and controls
35 lines (27 loc) · 1.03 KB
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
import { NonterminalKind } from '@nomicfoundation/slang/cst';
import { SlangNode } from './SlangNode.js';
import { TerminalNode } from './TerminalNode.js';
import { ErrorParametersDeclaration } from './ErrorParametersDeclaration.js';
import type * as ast from '@nomicfoundation/slang/ast';
import type { AstPath, Doc, ParserOptions } from 'prettier';
import type { AstNode } from './types.d.ts';
import type { PrintFunction } from '../types.d.ts';
export class ErrorDefinition extends SlangNode {
readonly kind = NonterminalKind.ErrorDefinition;
name: TerminalNode;
members: ErrorParametersDeclaration;
constructor(ast: ast.ErrorDefinition, options: ParserOptions<AstNode>) {
super(ast);
this.name = new TerminalNode(ast.name);
this.members = new ErrorParametersDeclaration(ast.members, options);
this.updateMetadata(this.members);
}
print(path: AstPath<ErrorDefinition>, print: PrintFunction): Doc {
return [
'error ',
path.call(print, 'name'),
path.call(print, 'members'),
';'
];
}
}