UNPKG

@eliseev_s/tolk-tlb-transpiler

Version:

Transpile Tolk structs to TLB definitions and generate TypeScript wrappers for TON blockchain smart contracts

65 lines 2.21 kB
import { Node, Tree } from 'web-tree-sitter'; import type { TolkType, TolkStruct, TolkConstant, TypeAliasInfo, TLBDefinition, GetMethod } from './types'; export declare class TolkASTProcessor { private parser; private structs; private typeAliases; private getMethods; private constants; private constructor(); static initialize(): Promise<TolkASTProcessor>; /** * Convert Tolk source code directly to TLB definitions */ transpile(sourceCode: string): TLBDefinition[]; /** * Transpile a Tolk file with import resolution (no cycles assumed) */ transpileFile(entryFilePath: string): TLBDefinition[]; parse(sourceCode: string): Tree; /** * Get parsed get methods */ getGetMethods(): GetMethod[]; getStructs(): TolkStruct[]; getTypeAliases(): TypeAliasInfo[]; processAST(tree: Tree): TLBDefinition[]; private collectFromFile; private extractImportsFromSource; private collectDefinitions; private processEnumDeclaration; private processStructDeclaration; private processTypeAlias; private processConstantDeclaration; private extractPackPrefix; private extractAnnotations; private extractGenerics; private inferGenericParamsFromFields; private extractStructFields; resolveType(typeNode: Node): TolkType; private processUnionType; private flattenUnion; private processTensorType; private processTupleType; private processGenericType; /** * Fallback for text-based generic parsing when AST structure is unexpected */ private processGenericTypeFallback; private parseGenericParams; /** * Split a string by pipe character (|) while respecting bracket nesting. * Returns array of alternatives if union found, or null if no union. */ private splitUnionAlternatives; private parseGenericParamToken; /** * Get all parsed constants */ getConstants(): Map<string, TolkConstant>; /** * Extract constants from Tolk source code */ extractConstants(sourceCode: string, predicate?: (constant: TolkConstant) => boolean): Record<string, number>; } //# sourceMappingURL=parser.d.ts.map