From 852a9d11a63fef31b0a830d3572bb4a86beb38e4 Mon Sep 17 00:00:00 2001 From: Sam Vervaeck Date: Sat, 9 May 2020 22:18:13 +0200 Subject: [PATCH] treegen: Add type definitions for treegen-AST --- treegen/src/ast.ts | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 treegen/src/ast.ts diff --git a/treegen/src/ast.ts b/treegen/src/ast.ts new file mode 100644 index 000000000..5ca183ac8 --- /dev/null +++ b/treegen/src/ast.ts @@ -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 +