export type ASTDataType = 'void' | 'bool' | 'int' | 'float' | 'string' | 'vector2' | 'vector3' | 'color' | 'entity' | 'array' | 'dictionary' | 'any' | 'custom'; export interface ASTTypeInfo { type: ASTDataType; /** For array/dictionary/custom types */ genericArgs?: ASTTypeInfo[]; /** Custom type name for 'custom' type */ customName?: string; /** Whether the type is nullable */ nullable?: boolean; } export type ASTExpression = ASTLiteral | ASTIdentifier | ASTBinaryOp | ASTUnaryOp | ASTCall | ASTMethodCall | ASTPropertyAccess | ASTIndexAccess | ASTConditional | ASTArrayLiteral | ASTDictionaryLiteral | ASTCast | ASTLambda | ASTNew; export interface ASTNodeBase { kind: string; /** Source node ID for debugging/mapping */ sourceNodeId?: string; /** Line comment to emit */ comment?: string; } export interface ASTLiteral extends ASTNodeBase { kind: 'literal'; valueType: ASTDataType; value: unknown; } export interface ASTIdentifier extends ASTNodeBase { kind: 'identifier'; name: string; dataType?: ASTTypeInfo; } export interface ASTBinaryOp extends ASTNodeBase { kind: 'binaryOp'; operator: '+' | '-' | '*' | '/' | '%' | '==' | '!=' | '<' | '>' | '<=' | '>=' | '&&' | '||' | '&' | '|' | '^' | '<<' | '>>'; left: ASTExpression; right: ASTExpression; } export interface ASTUnaryOp extends ASTNodeBase { kind: 'unaryOp'; operator: '!' | '-' | '~' | '++' | '--'; operand: ASTExpression; prefix: boolean; } export interface ASTCall extends ASTNodeBase { kind: 'call'; callee: string; args: ASTExpression[]; /** Generic type arguments for the call */ typeArgs?: ASTTypeInfo[]; } export interface ASTMethodCall extends ASTNodeBase { kind: 'methodCall'; object: ASTExpression; method: string; args: ASTExpression[]; } export interface ASTPropertyAccess extends ASTNodeBase { kind: 'propertyAccess'; object: ASTExpression; property: string; } export interface ASTIndexAccess extends ASTNodeBase { kind: 'indexAccess'; object: ASTExpression; index: ASTExpression; } export interface ASTConditional extends ASTNodeBase { kind: 'conditional'; condition: ASTExpression; ifTrue: ASTExpression; ifFalse: ASTExpression; } export interface ASTArrayLiteral extends ASTNodeBase { kind: 'arrayLiteral'; elements: ASTExpression[]; elementType?: ASTTypeInfo; } export interface ASTDictionaryLiteral extends ASTNodeBase { kind: 'dictionaryLiteral'; entries: Array<{ key: ASTExpression; value: ASTExpression; }>; } export interface ASTCast extends ASTNodeBase { kind: 'cast'; expression: ASTExpression; targetType: ASTTypeInfo; } export interface ASTLambda extends ASTNodeBase { kind: 'lambda'; params: ASTParameter[]; body: ASTStatement[] | ASTExpression; returnType?: ASTTypeInfo; } export interface ASTNew extends ASTNodeBase { kind: 'new'; typeName: string; args: ASTExpression[]; } export type ASTStatement = ASTVarDecl | ASTAssignment | ASTIf | ASTWhile | ASTFor | ASTForEach | ASTReturn | ASTBreak | ASTContinue | ASTExpressionStatement | ASTBlock | ASTSwitch | ASTTry | ASTYield | ASTAwait | ASTMatch | ASTSignalEmit; export interface ASTVarDecl extends ASTNodeBase { kind: 'varDecl'; name: string; varType?: ASTTypeInfo; initializer?: ASTExpression; isConst?: boolean; /** Export for Godot @export, [SerializeField] for Unity */ isExported?: boolean; } export interface ASTAssignment extends ASTNodeBase { kind: 'assignment'; target: ASTExpression; operator: '=' | '+=' | '-=' | '*=' | '/=' | '%='; value: ASTExpression; } export interface ASTIf extends ASTNodeBase { kind: 'if'; condition: ASTExpression; thenBranch: ASTStatement[]; elseBranch?: ASTStatement[]; elseIfs?: Array<{ condition: ASTExpression; body: ASTStatement[]; }>; } export interface ASTWhile extends ASTNodeBase { kind: 'while'; condition: ASTExpression; body: ASTStatement[]; } export interface ASTFor extends ASTNodeBase { kind: 'for'; init?: ASTStatement; condition?: ASTExpression; update?: ASTExpression; body: ASTStatement[]; } export interface ASTForEach extends ASTNodeBase { kind: 'forEach'; variable: string; iterable: ASTExpression; body: ASTStatement[]; } export interface ASTReturn extends ASTNodeBase { kind: 'return'; value?: ASTExpression; } export interface ASTBreak extends ASTNodeBase { kind: 'break'; } export interface ASTContinue extends ASTNodeBase { kind: 'continue'; } export interface ASTExpressionStatement extends ASTNodeBase { kind: 'expressionStatement'; expression: ASTExpression; } export interface ASTBlock extends ASTNodeBase { kind: 'block'; statements: ASTStatement[]; } export interface ASTSwitch extends ASTNodeBase { kind: 'switch'; expression: ASTExpression; cases: Array<{ value: ASTExpression; body: ASTStatement[]; }>; defaultCase?: ASTStatement[]; } export interface ASTTry extends ASTNodeBase { kind: 'try'; tryBlock: ASTStatement[]; catchBlocks?: Array<{ errorType?: string; errorVar?: string; body: ASTStatement[]; }>; finallyBlock?: ASTStatement[]; } export interface ASTYield extends ASTNodeBase { kind: 'yield'; value?: ASTExpression; } export interface ASTAwait extends ASTNodeBase { kind: 'await'; expression: ASTExpression; } export interface ASTMatch extends ASTNodeBase { kind: 'match'; expression: ASTExpression; arms: Array<{ pattern: ASTExpression; guard?: ASTExpression; body: ASTStatement[]; }>; } export interface ASTSignalEmit extends ASTNodeBase { kind: 'signalEmit'; signalName: string; args: ASTExpression[]; } export interface ASTParameter { name: string; paramType: ASTTypeInfo; defaultValue?: ASTExpression; /** Variadic parameter (...args) */ isVariadic?: boolean; } export interface ASTFunction extends ASTNodeBase { kind: 'function'; name: string; params: ASTParameter[]; returnType: ASTTypeInfo; body: ASTStatement[]; isAsync?: boolean; isStatic?: boolean; visibility?: 'public' | 'private' | 'protected' | 'internal'; /** Virtual/override for inheritance */ isVirtual?: boolean; isOverride?: boolean; isAbstract?: boolean; /** Coroutine for Unity/Godot yields */ isCoroutine?: boolean; /** Attributes/decorators */ attributes?: string[]; } export interface ASTField { name: string; fieldType: ASTTypeInfo; initializer?: ASTExpression; visibility?: 'public' | 'private' | 'protected' | 'internal'; isStatic?: boolean; isConst?: boolean; isReadonly?: boolean; isExported?: boolean; attributes?: string[]; comment?: string; } export interface ASTProperty { name: string; propType: ASTTypeInfo; getter?: ASTStatement[]; setter?: ASTStatement[]; visibility?: 'public' | 'private' | 'protected' | 'internal'; isStatic?: boolean; attributes?: string[]; } export interface ASTSignalDef { name: string; params: ASTParameter[]; } export interface ASTEnumMember { name: string; value?: number | string; } export interface ASTEnum { name: string; members: ASTEnumMember[]; } export interface ASTClass extends ASTNodeBase { kind: 'class'; name: string; baseClass?: string; interfaces?: string[]; fields: ASTField[]; properties?: ASTProperty[]; methods: ASTFunction[]; signals?: ASTSignalDef[]; enums?: ASTEnum[]; nestedClasses?: ASTClass[]; isAbstract?: boolean; isSealed?: boolean; isPartial?: boolean; attributes?: string[]; comment?: string; } export interface ASTImport { module: string; /** Named imports */ names?: string[]; /** Import all: import * as X */ alias?: string; /** Default import */ defaultImport?: string; } export interface ASTScript { /** Script/file name without extension */ name: string; imports: ASTImport[]; classes: ASTClass[]; /** Top-level functions (for languages that support it) */ functions?: ASTFunction[]; /** Top-level statements (for scripting languages) */ topLevel?: ASTStatement[]; /** Module-level enums */ enums?: ASTEnum[]; /** File header comment */ headerComment?: string; } export declare function createLiteral(value: unknown, valueType?: ASTDataType): ASTLiteral; export declare function createIdentifier(name: string, dataType?: ASTTypeInfo): ASTIdentifier; export declare function createBinaryOp(operator: ASTBinaryOp['operator'], left: ASTExpression, right: ASTExpression): ASTBinaryOp; export declare function createCall(callee: string, args: ASTExpression[]): ASTCall; export declare function createMethodCall(object: ASTExpression, method: string, args: ASTExpression[]): ASTMethodCall; export declare function createPropertyAccess(object: ASTExpression, property: string): ASTPropertyAccess; export declare function createAssignment(target: ASTExpression, value: ASTExpression, operator?: ASTAssignment['operator']): ASTAssignment; export declare function createVarDecl(name: string, varType?: ASTTypeInfo, initializer?: ASTExpression): ASTVarDecl; export declare function createIf(condition: ASTExpression, thenBranch: ASTStatement[], elseBranch?: ASTStatement[]): ASTIf; export declare function createReturn(value?: ASTExpression): ASTReturn; export declare function createExprStatement(expression: ASTExpression): ASTExpressionStatement; export declare function createType(type: ASTDataType, nullable?: boolean): ASTTypeInfo; export declare function createArrayType(elementType: ASTTypeInfo): ASTTypeInfo; export declare function createCustomType(name: string, nullable?: boolean): ASTTypeInfo;