(options: ParseOptions)
| 125 | * @yields 解析事件流 |
| 126 | */ |
| 127 | export async function* parseFile(options: ParseOptions): AsyncGenerator<ParseEvent, void, unknown> { |
| 128 | const parser = sniffer.getParser(options.filePath) |
| 129 | if (!parser) { |
| 130 | yield { type: 'error', data: new Error(`无法识别文件格式: ${options.filePath}`) } |
| 131 | return |
| 132 | } |
| 133 | |
| 134 | console.log(`[Parser V2] Using parser: ${parser.feature.name}`) |
| 135 | yield* parser.parse(options) |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * 使用指定格式解析文件(用于 fallback 机制) |
no test coverage detected