-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-parse.js
More file actions
31 lines (28 loc) · 1.32 KB
/
debug-parse.js
File metadata and controls
31 lines (28 loc) · 1.32 KB
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
const { GabcParser } = require('./lsp-server/parser/gabc-parser.js');
const fs = require('fs');
const content = fs.readFileSync('test-alterations.gabc', 'utf-8');
const parser = new GabcParser(content);
const parsed = parser.parse();
console.log('Full file content:');
content.split('\n').forEach((line, i) => {
console.log(`${i}: ${line}`);
});
// Find all syllables with notes
parsed.notation.syllables.forEach(syl => {
if (syl.text && syl.notes.length > 0) {
console.log(`\n=== Syllable: '${syl.text}' ===`);
syl.notes.forEach((ng, i) => {
console.log(` NoteGroup ${i}: gabc='${ng.gabc}'`);
const lines = content.split('\n');
const ngText = lines[ng.range.start.line]?.substring(ng.range.start.character, ng.range.end.character) || '';
console.log(` Full text: '${ngText}'`);
ng.notes.forEach((note, j) => {
const noteText = lines[note.range.start.line]?.substring(note.range.start.character, note.range.end.character) || '';
console.log(` Note ${j}: pitch=${note.pitch} shape=${note.shape}`);
console.log(` Text: '${noteText}'`);
console.log(` Range: (${note.range.start.line},${note.range.start.character})-(${note.range.end.line},${note.range.end.character})`);
console.log(` Modifiers:`, note.modifiers);
});
});
}
});