/** * LT Language AST Node Definitions * All AST node types for the parser */ export declare enum NodeType { Program = "Program", VariableDecl = "VariableDecl", AssignmentStmt = "AssignmentStmt", CompoundAssignment = "CompoundAssignment", IfStmt = "IfStmt", ForStmt = "ForStmt", RangeForStmt = "RangeForStmt", WhileStmt = "WhileStmt", ReturnStmt = "ReturnStmt", BreakStmt = "BreakStmt", ContinueStmt = "ContinueStmt", SwitchStmt = "SwitchStmt", Block = "Block", GuardStmt = "GuardStmt", SafeCallStmt = "SafeCallStmt", ThreadStmt = "ThreadStmt", LoopStmt = "LoopStmt", WaitStmt = "WaitStmt", TimeoutStmt = "TimeoutStmt", IntervalStmt = "IntervalStmt", TryCatchStmt = "TryCatchStmt", CommandStmt = "CommandStmt", EmitStmt = "EmitStmt", EventHandler = "EventHandler", ExportDecl = "ExportDecl", TypeDecl = "TypeDecl", TypeAliasDecl = "TypeAliasDecl", BinaryExpr = "BinaryExpr", UnaryExpr = "UnaryExpr", UpdateExpr = "UpdateExpr",// ++, -- ConditionalExpr = "ConditionalExpr",// Ternary ? : CallExpr = "CallExpr", MemberExpr = "MemberExpr", OptionalChainExpr = "OptionalChainExpr", NullCoalesceExpr = "NullCoalesceExpr", ArrowFunc = "ArrowFunc", FunctionDecl = "FunctionDecl", Identifier = "Identifier", NumberLiteral = "NumberLiteral", StringLiteral = "StringLiteral", InterpolatedString = "InterpolatedString", BooleanLiteral = "BooleanLiteral", NilLiteral = "NilLiteral", TableLiteral = "TableLiteral", VectorLiteral = "VectorLiteral", SpreadExpr = "SpreadExpr", ObjectDestructure = "ObjectDestructure", ArrayDestructure = "ArrayDestructure" } export interface Node { kind: NodeType; line?: number; column?: number; } export interface Statement extends Node { } export interface Expression extends Node { } export interface Program extends Node { kind: NodeType.Program; body: Statement[]; } export interface VariableDecl extends Statement { kind: NodeType.VariableDecl; scope: "var" | "let" | "const" | "local"; names: (Identifier | ObjectDestructure | ArrayDestructure)[]; typeAnnotations?: (string | undefined)[]; values?: Expression[]; } export interface FunctionDecl extends Statement { kind: NodeType.FunctionDecl; name?: Identifier | MemberExpr; params: Parameter[]; returnType?: string; body: Block; isLocal?: boolean; } export interface Parameter { name: Identifier; typeAnnotation?: string; defaultValue?: Expression; } export interface TypeField { name: string; type: string; } export interface TypeDecl extends Statement { kind: NodeType.TypeDecl; name: Identifier; fields: TypeField[]; } export interface TypeAliasDecl extends Statement { kind: NodeType.TypeAliasDecl; name: Identifier; type: string; } export interface AssignmentStmt extends Statement { kind: NodeType.AssignmentStmt; targets: Expression[]; values: Expression[]; typeAnnotation?: string; } export interface CompoundAssignment extends Statement { kind: NodeType.CompoundAssignment; target: Expression; operator: "+=" | "-=" | "*=" | "/=" | "%=" | "..="; value: Expression; } export interface IfStmt extends Statement { kind: NodeType.IfStmt; condition: Expression; thenBody: Block; elseIfClauses?: { condition: Expression; body: Block; }[]; elseBody?: Block; } export interface ForStmt extends Statement { kind: NodeType.ForStmt; iterators: Identifier[]; iterable: Expression; body: Block; } export interface RangeForStmt extends Statement { kind: NodeType.RangeForStmt; counter: Identifier; start: Expression; end: Expression; step?: Expression; body: Block; } export interface WhileStmt extends Statement { kind: NodeType.WhileStmt; condition: Expression; body: Block; } export interface ReturnStmt extends Statement { kind: NodeType.ReturnStmt; values?: Expression[]; } export interface BreakStmt extends Statement { kind: NodeType.BreakStmt; } export interface ContinueStmt extends Statement { kind: NodeType.ContinueStmt; } export interface SwitchStmt extends Statement { kind: NodeType.SwitchStmt; discriminant: Expression; cases: SwitchCase[]; defaultCase?: Block; } export interface SwitchCase { values: Expression[]; body: Block; } export interface Block extends Node { kind: NodeType.Block; statements: Statement[]; } export interface GuardStmt extends Statement { kind: NodeType.GuardStmt; condition: Expression; elseBody?: Statement[]; returnValue?: Expression; } export interface SafeCallStmt extends Statement { kind: NodeType.SafeCallStmt; call: CallExpr; } export interface ThreadStmt extends Statement { kind: NodeType.ThreadStmt; body: Block; } export interface LoopStmt extends Statement { kind: NodeType.LoopStmt; conditions: Expression[]; body: Block; } export interface WaitStmt extends Statement { kind: NodeType.WaitStmt; time: Expression; } export interface TimeoutStmt extends Statement { kind: NodeType.TimeoutStmt; delay: Expression; body: Block; } export interface IntervalStmt extends Statement { kind: NodeType.IntervalStmt; interval: Expression; body: Block; } export interface TryCatchStmt extends Statement { kind: NodeType.TryCatchStmt; tryBody: Block; catchParam: Identifier; catchBody: Block; } export interface EmitStmt extends Statement { kind: NodeType.EmitStmt; emitType: "emit" | "emitClient" | "emitServer"; eventName: Expression; args: Expression[]; } export interface EventHandler extends Statement { kind: NodeType.EventHandler; isNet: boolean; eventName: Expression; params: Parameter[]; body: Block; } export interface ExportDecl extends Statement { kind: NodeType.ExportDecl; declaration: FunctionDecl; } export interface CommandStmt extends Statement { kind: NodeType.CommandStmt; commandName: string; params: Parameter[]; body: Block; } export interface BinaryExpr extends Expression { kind: NodeType.BinaryExpr; left: Expression; operator: string; right: Expression; } export interface UnaryExpr extends Expression { kind: NodeType.UnaryExpr; operator: string; operand: Expression; } export interface UpdateExpr extends Expression { kind: NodeType.UpdateExpr; operator: "++" | "--"; argument: Expression; prefix: boolean; } export interface ConditionalExpr extends Expression { kind: NodeType.ConditionalExpr; test: Expression; consequent: Expression; alternate: Expression; } export interface SpreadExpr extends Expression { kind: NodeType.SpreadExpr; argument: Expression; } export interface CallExpr extends Expression { kind: NodeType.CallExpr; callee: Expression; args: Expression[]; } export interface MemberExpr extends Expression { kind: NodeType.MemberExpr; object: Expression; property: Expression; computed: boolean; isMethod?: boolean; } export interface OptionalChainExpr extends Expression { kind: NodeType.OptionalChainExpr; object: Expression; property: Expression; computed: boolean; isMethod?: boolean; } export interface NullCoalesceExpr extends Expression { kind: NodeType.NullCoalesceExpr; left: Expression; right: Expression; } export interface ArrowFunc extends Expression { kind: NodeType.ArrowFunc; params: Parameter[]; body: Block | Expression; } export interface Identifier extends Expression { kind: NodeType.Identifier; name: string; attribute?: string; } export interface NumberLiteral extends Expression { kind: NodeType.NumberLiteral; value: number; } export interface StringLiteral extends Expression { kind: NodeType.StringLiteral; value: string; isLong?: boolean; quote?: "'" | '"'; } export interface InterpolatedString extends Expression { kind: NodeType.InterpolatedString; parts: (string | Expression)[]; quote?: "'" | '"'; } export interface BooleanLiteral extends Expression { kind: NodeType.BooleanLiteral; value: boolean; } export interface NilLiteral extends Expression { kind: NodeType.NilLiteral; } export interface TableLiteral extends Expression { kind: NodeType.TableLiteral; fields: TableField[]; } export interface TableField { key?: Expression; value: Expression; shorthand?: boolean; } export interface VectorLiteral extends Expression { kind: NodeType.VectorLiteral; components: Expression[]; } export interface ObjectDestructure extends Node { kind: NodeType.ObjectDestructure; properties: Identifier[]; } export interface ArrayDestructure extends Node { kind: NodeType.ArrayDestructure; elements: Identifier[]; }