1 // © Copyright 2022, Scott Gasch
3 // antlr4 -Dlanguage=Python3 ./chords.g4
5 // Hi, self. In ANTLR grammars, there are two separate types of symbols: those
6 // for the lexer and those for the parser. The former begin with a CAPITAL
7 // whereas the latter begin with lowercase. The order of the lexer symbols
8 // is the order that the lexer will recognize them in. There's a good tutorial
11 // https://tomassetti.me/antlr-mega-tutorial/
13 // There are also a zillion premade grammars at:
15 // https://github.com/antlr/grammars-v4
20 : rootNote majMinSusPowerExpr* addNotesExpr* extensionExpr* overBassNoteExpr*
44 susExpr: SUS ('2'|'4');
46 diminishedExpr: DIMINISHED;
48 augmentedExpr: AUGMENTED;
64 SPACE: [ \t\r\n] -> skip;
66 NOTE: (AS|BS|CS|DS|ES|FS|GS) ;
106 MAJOR: ('M'|'Maj'|'maj'|'Major'|'major');
108 MINOR: ('m'|'min'|'minor');
110 SUS: ('sus'|'suspended');
112 DIMINISHED: ('dim'|'diminished'|'-');
114 AUGMENTED: ('aug'|'augmented'|'+');
118 ADD: ('add'|'Add'|'dom');
128 MAJ_SEVEN: MAJOR '7';
130 INTERVAL: (MAJOR|MINOR)* ('b'|'#')* DIGITS ;