-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-cn-attribute.js
More file actions
111 lines (100 loc) · 2.97 KB
/
debug-cn-attribute.js
File metadata and controls
111 lines (100 loc) · 2.97 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env node
/**
* Test NABC highlighting in cn attribute values
*/
const path = require('path');
// Import parser
const parserPath = path.join(__dirname, 'lsp-server', 'parser', 'nabc-parser.js');
const { parseNABCSnippet } = require(parserPath);
const testCases = [
{
name: 'Basic glyph: pu',
nabc: 'pu',
description: 'Two-letter basic glyph'
},
{
name: 'Basic glyph: vi',
nabc: 'vi',
description: 'Two-letter basic glyph (virga)'
},
{
name: 'Modified glyph: clhg',
nabc: 'clhg',
description: 'Clivis with pitch descriptor'
},
{
name: 'Modified glyph: viM',
nabc: 'viM',
description: 'Virga with modifier M (melismatic)'
},
{
name: 'Modified glyph: clS',
nabc: 'clS',
description: 'Clivis with modifier S (semi-circled)'
},
{
name: 'Pitch descriptor: tohd',
nabc: 'tohd',
description: 'Torculus with pitch descriptor at d'
},
{
name: 'Subpunctis: su2',
nabc: 'su2',
description: 'Subpunctis with 2 puncta'
},
{
name: 'Prepunctis: pp3',
nabc: 'pp3',
description: 'Prepunctis with 3 puncta'
}
];
console.log('Testing NABC parsing for cn attribute values...\n');
let allPassed = true;
testCases.forEach((testCase, idx) => {
console.log(`Test ${idx + 1}: ${testCase.name}`);
console.log(` NABC: "${testCase.nabc}"`);
console.log(` ${testCase.description}`);
try {
const startPos = { line: 0, character: 0 };
const glyphs = parseNABCSnippet(testCase.nabc, startPos);
if (glyphs && glyphs.length > 0) {
console.log(` ✓ PASS: Parsed successfully (${glyphs.length} glyph(s))`);
glyphs.forEach((glyph, gIdx) => {
console.log(` Glyph ${gIdx}:`);
if (glyph.basicGlyph) {
console.log(` Basic: ${glyph.basicGlyph.type}`);
}
if (glyph.subpunctis) {
console.log(` Subpunctis: ${glyph.subpunctis}`);
}
if (glyph.prepunctis) {
console.log(` Prepunctis: ${glyph.prepunctis}`);
}
if (glyph.modifiers && glyph.modifiers.length > 0) {
console.log(` Modifiers: ${glyph.modifiers.map(m => m.type).join(', ')}`);
}
});
} else {
console.log(` ✗ FAIL: No glyphs parsed`);
allPassed = false;
}
} catch (error) {
console.log(` ✗ FAIL: Parse error - ${error.message}`);
allPassed = false;
}
console.log();
});
console.log('='.repeat(60));
if (allPassed) {
console.log('✓ All NABC snippets parsed successfully');
console.log('\nThe cn attribute values should now be highlighted with NABC syntax:');
console.log(' - Basic glyphs (pu, vi, cl, etc.) → keyword');
console.log(' - Modifiers (S, M, G, etc.) → operator');
console.log(' - Pitch descriptors (h + letter) → function + parameter');
console.log(' - Sub/prepunctis prefixes → class');
console.log(' - Numbers → number');
process.exit(0);
} else {
console.log('✗ Some tests FAILED');
process.exit(1);
}