import { detectLanguage as registryDetectLanguage } from './languages/registry.js'; import type { SupportedLanguage } from './languages/registry.js'; import type { ASTParseResult } from './types.js'; /** * Detect language from file extension. * Re-exported from the language registry for backwards compatibility. */ export declare const detectLanguage: typeof registryDetectLanguage; /** * Check if a file is supported for AST parsing */ export declare function isASTSupported(filePath: string): boolean; /** * Thrown when the native parser binding itself fails to load (no * prebuilt/local build for this platform) -- as distinct from a per-file * parse failure. This is a systemic, process-wide condition: ADR-013 * Phase 4-B removed the legacy node-tree-sitter backend that per-file * failures used to fall back to, so this must propagate rather than be * swallowed by generic error handling. * * Callers that catch broad `Error`s around AST parsing (notably * chunker.ts's `astFallback` catch, which otherwise degrades any thrown * error to line-based chunking) MUST check for this type with * `instanceof` and re-throw it unconditionally -- see chunker.ts. */ export declare class NativeBindingLoadError extends Error { constructor(message: string); } /** * Parse source code into an AST via @liendev/parser-native plus the compat * deserializer in ./native/ -- see docs/architecture/native-parser.md for * the wire format and compat contract. * * `loadNativeBinding()` is deliberately called outside the try/catch below: * a binding that cannot load at all is a systemic, process-wide failure * (missing prebuilt/local build), not a per-file parse problem, and ADR-013 * Phase 4-B removed the legacy backend that used to catch that fall. Letting * it throw once (loudly, with an actionable message, as a `NativeBindingLoadError`) * is preferable to folding it into `{tree: null, error}` -- the latter reads * identically to an ordinary per-file syntax error and would let every file * in a scan silently degrade to line-based chunking. Callers that catch * broad errors around parsing (chunker.ts's `astFallback`) check for * `NativeBindingLoadError` specifically and re-throw it regardless of * fallback policy, so this guarantee holds all the way up to `chunkFile`. * A genuine per-file issue (a JSON.parse or compat-tree-build failure on * this file's own output) still returns `{tree: null, error}` as before. * * @param content - Source code to parse * @param language - Programming language * @returns Parse result with tree or error * @throws NativeBindingLoadError if the native binding cannot be loaded at * all. @throws Error if LIEN_PARSER is set to an invalid or retired value * (see ./backend.ts). */ export declare function parseAST(content: string, language: SupportedLanguage): ASTParseResult; /** * Clear parser cache (useful for testing). Resets the native-load-failure * cache (see loadNativeBinding) so a test can simulate a fresh process -- * the native binding handle itself (nativeBinding) is intentionally left * cached, since a successful load is always safe to reuse. */ export declare function clearParserCache(): void; //# sourceMappingURL=parser.d.ts.map