curtis
9小時前 0756bf12d10cf1b7f78c571de0a9ad69cbaeb7ca
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const fs = require('fs');
const path = require('path');
 
const sourceFile = 'CB_IMGPSScanImp.pas.bk';
const base_path = 'doc/curtis/prompt/scanimpl_analysis';
const outputFile = path.join(base_path, 'step1_raw_methods.json');
 
function extract() {
  const lines = fs.readFileSync(sourceFile, 'utf8').split('\n');
  const totalLines = lines.length;
  const methods = [];
  const regex = /^(procedure|function)\s+TCB_IMGPSScanX\./i;
 
  for (let i = 0; i < totalLines; i++) {
    const line = lines[i];
    if (regex.test(line)) {
      methods.push({
        matcher: line.trim(),
        lIndex: i + 1,
        rIndex: -1 // To be filled
      });
    }
  }
 
  for (let i = 0; i < methods.length; i++) {
    if (i < methods.length - 1) {
      methods[i].rIndex = methods[i + 1].lIndex - 1;
    } else {
      methods[i].rIndex = totalLines;
    }
  }
 
  if (!fs.existsSync(base_path)) {
    fs.mkdirSync(base_path, {recursive: true});
  }
  fs.writeFileSync(outputFile, JSON.stringify(methods, null, 2), 'utf8');
  console.log(`Extracted ${methods.length} methods to ${outputFile}`);
}
 
extract();