treegen: Add type definitions for treegen-AST
This commit is contained in:
parent
d3c5079af1
commit
852a9d11a6
1 changed files with 49 additions and 0 deletions
49
treegen/src/ast.ts
Normal file
49
treegen/src/ast.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
|
||||
export interface ReferenceTypeNode {
|
||||
type: 'ReferenceTypeNode';
|
||||
name: string;
|
||||
typeArgs: TypeNode[];
|
||||
}
|
||||
|
||||
export interface UnionTypeNode {
|
||||
type: 'UnionTypeNode';
|
||||
elements: TypeNode[];
|
||||
}
|
||||
|
||||
export type TypeNode
|
||||
= ReferenceTypeNode
|
||||
| UnionTypeNode
|
||||
|
||||
export interface NodeField {
|
||||
name: string;
|
||||
typeNode: TypeNode;
|
||||
}
|
||||
|
||||
export interface NodeDeclaration {
|
||||
type: 'NodeDeclaration';
|
||||
name: string;
|
||||
fields: NodeField[];
|
||||
}
|
||||
|
||||
export interface EnumField {
|
||||
name: string;
|
||||
value: number | null;
|
||||
}
|
||||
|
||||
export interface EnumDeclaration {
|
||||
type: 'EnumDeclaration';
|
||||
name: string;
|
||||
fields: EnumField[];
|
||||
}
|
||||
|
||||
export interface TypeDeclaration {
|
||||
type: 'TypeDeclaration';
|
||||
name: string;
|
||||
typeNode: TypeNode;
|
||||
}
|
||||
|
||||
export type Declaration
|
||||
= NodeDeclaration
|
||||
| TypeDeclaration
|
||||
| EnumDeclaration
|
||||
|
Loading…
Reference in a new issue