ABC notation language toolkit - parser, analyzer, formatter, and tokenizer
npm install chamber-abcABC notation language toolkit for the browser - parser, analyzer, formatter, and tokenizer.
``bash`
npm install chamber-abc
`javascript
import init, { parse, analyze, format, format_default } from 'chamber-abc';
// Initialize WASM
await init();
const source = X:1
T:Test Tune
M:4/4
L:1/8
K:C
CDEF GABc|;
// Parse
const result = parse(source);
console.log(result.tune); // AST
console.log(result.diagnostics); // Parse errors/warnings
// Analyze (semantic checks)
const analysis = analyze(result.tune);
console.log(analysis.diagnostics); // Lint warnings
// Format
const formatted = format_default(source);
`
javascript
const tokens = tokenize(source);
// [
// { kind: "FieldLabel", range: { start: 0, end: 1 } },
// { kind: "Colon", range: { start: 1, end: 2 } },
// { kind: "Note", range: { start: 20, end: 21 } },
// ...
// ]
`Token kinds:
FieldLabel, Note, Rest, Sharp, Flat, Natural, Bar, DoubleBar, RepeatStart, RepeatEnd, Decoration, Comment, Tuplet, Tie, Number, Text, Whitespace, Newline`, etc.MIT