import { Token } from '../keywords/index.js'; type NodeType = "Program" | "Literal" | "Property" | "CommentStatement" | "EmptyLine" | "LambdaFunctionDecl" | "FunctionDeclaration" | "VariableDeclaration" | "UseDeclaration" | "UseSpecifier" | "UseDefaultSpecifier" | "TemplateElement" | "BinaryExpression" | "ArrayExpression" | "ObjectExpression" | "MemberExpression" | "CallExpression" | "AssignmentExpression" | "CompareExpression" | "EqualExpression" | "TernayExpression" | "RangeExpression" | "IterableExpression" | "ToExpression" | "TemplateLiteralExpression" | "RunStatement" | "WaitStatement" | "TaskStatement" | "BlockStatement" | "ReturnStatement" | "ExpressionStatement" | "IfStatement" | "ForStatement" | "SwitchStmtement" | "CaseBlockStatement" | "DefaultCaseBlockStatement" | "ExposeStmtement"; interface Node { type: NodeType; id?: UnitNodeInstance | Token; } interface Expr extends Node { } type UnitNodeInstance = T & { origin: T; parent: UnitNodeInstance | null; findBlock: () => UnitNodeInstance | null; }; interface Literal extends Expr { value: Token; type: "Literal"; } interface Property extends Node { key: UnitNodeInstance; value: UnitNodeInstance; type: "Property"; } interface TemplateElement extends Node { value: UnitNodeInstance; type: "TemplateElement"; } interface EmptyLineStmt extends Node { type: "EmptyLine"; } interface UseSpecifier extends Node { remote: UnitNodeInstance; local: UnitNodeInstance; type: "UseSpecifier"; } interface UseDefaultSpecifier extends Node { local: UnitNodeInstance; type: "UseDefaultSpecifier"; } interface UseDecl extends Node { type: "UseDeclaration"; source: UnitNodeInstance; specifiers: (UseSpecifier | UseDefaultSpecifier)[]; } interface FunctionDecl extends Node { preId: Token; id: UnitNodeInstance; arguments: UnitNodeInstance[]; body: UnitNodeInstance; type: "FunctionDeclaration"; } interface LambdaFunctionDecl extends Node { arguments: UnitNodeInstance[]; body: UnitNodeInstance; type: "LambdaFunctionDecl"; } interface VariableDecl extends Node { preId: Token; id: UnitNodeInstance; value: UnitNodeInstance; type: "VariableDeclaration"; is_const: boolean; } interface RangeExpr extends Expr { start: UnitNodeInstance; end: UnitNodeInstance; step: Token; type: "RangeExpression"; } interface EqualExpr extends Expr { left: UnitNodeInstance; right: UnitNodeInstance; operator: Token; type: "EqualExpression"; } interface CompareExpr extends Expr { left: UnitNodeInstance; right: UnitNodeInstance; operator: Token; type: "CompareExpression"; } interface CallExpr extends Expr { callee: UnitNodeInstance; arguments: UnitNodeInstance[]; type: "CallExpression"; } interface TernaryExpr extends Expr { condition: UnitNodeInstance; consequent: UnitNodeInstance; alternate: UnitNodeInstance; type: "TernayExpression"; } interface ObjectExpr extends Node { properties: UnitNodeInstance[]; type: "ObjectExpression"; } interface ArrayExpr extends Node { items: UnitNodeInstance[]; type: "ArrayExpression"; } interface MemberExpr extends Expr { object: UnitNodeInstance; property: UnitNodeInstance | UnitNodeInstance[]; type: "MemberExpression"; computed: boolean; } interface AssignmentExpr extends Expr { left: UnitNodeInstance; right: UnitNodeInstance; operator: Token; type: "AssignmentExpression"; } interface AssignmentExpr extends Expr { left: UnitNodeInstance; right: UnitNodeInstance; operator: Token; type: "AssignmentExpression"; } interface BinaryExpr extends Expr { left: UnitNodeInstance; right: UnitNodeInstance; operator: Token; } interface ToExpr extends Expr { body: UnitNodeInstance; arguments: UnitNodeInstance[]; type: "ToExpression"; } interface TemplateLiteralExpr extends Expr { type: "TemplateLiteralExpression"; quotes: UnitNodeInstance[]; } interface CommentStmt extends Node { value: Token; type: "CommentStatement"; } interface RunStmt extends Expr { callee: UnitNodeInstance; to: UnitNodeInstance[]; type: "RunStatement"; } interface ExposeStmt extends Node { id: Token; body: UnitNodeInstance; specifiers: UnitNodeInstance[]; type: "ExposeStmtement"; } interface BlockStmt extends Node { body: UnitNodeInstance[]; type: "BlockStatement"; } interface CaseBlockStmt extends Node { body: UnitNodeInstance; test: UnitNodeInstance; type: "CaseBlockStatement"; } interface DefaultCaseBlockStmt extends Node { body: UnitNodeInstance; test: UnitNodeInstance; type: "DefaultCaseBlockStatement"; } interface ReturnStmt extends Node { value: UnitNodeInstance; type: "ReturnStatement"; } interface ProgramStmt extends Node { body: UnitNodeInstance[]; type: "Program"; } interface IfStmt extends Node { test: UnitNodeInstance; consequent: UnitNodeInstance; alternate?: UnitNodeInstance; type: "IfStatement"; } interface ForStmt extends Node { init: UnitNodeInstance; value?: UnitNodeInstance; range: UnitNodeInstance; update: UnitNodeInstance; body: UnitNodeInstance; type: "ForStatement"; } interface SwitchStmt extends Node { test: UnitNodeInstance; cases: UnitNodeInstance[]; type: "SwitchStmtement"; } interface ExpressionStmt extends Node { expression: UnitNodeInstance; type: "ExpressionStatement"; } interface TaskStmt extends Node { fn: UnitNodeInstance; type: "TaskStatement"; } interface WaitStmt extends Node { type: "WaitStatement"; async: UnitNodeInstance; } export type { ArrayExpr, AssignmentExpr, BinaryExpr, BlockStmt, CallExpr, CaseBlockStmt, CommentStmt, CompareExpr, DefaultCaseBlockStmt, EmptyLineStmt, EqualExpr, ExposeStmt, Expr, ExpressionStmt, ForStmt, FunctionDecl, IfStmt, LambdaFunctionDecl, Literal, MemberExpr, Node, NodeType, ObjectExpr, ProgramStmt, Property, RangeExpr, ReturnStmt, RunStmt, SwitchStmt, TaskStmt, TemplateElement, TemplateLiteralExpr, TernaryExpr, ToExpr, UnitNodeInstance, UseDecl, UseDefaultSpecifier, UseSpecifier, VariableDecl, WaitStmt };