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* overBassNoteExpr*
21 | rootNote majMinSusPowerExpr* addNotesExpr extensionExpr* overBassNoteExpr
45 susExpr: SUS ('2'|'4');
47 diminishedExpr: DIMINISHED;
49 augmentedExpr: AUGMENTED;
66 SPACE: [ \t\r\n] -> skip;
68 NOTE: (AS|BS|CS|DS|ES|FS|GS) ;
108 MAJOR: ('M'|'Maj'|'maj'|'Major'|'major');
110 MINOR: ('m'|'min'|'minor');
112 SUS: ('sus'|'suspended');
114 DIMINISHED: ('dim'|'diminished'|'-');
116 AUGMENTED: ('aug'|'augmented'|'+');
120 ADD: ('add'|'Add'|'dom');
130 MAJ_SEVEN: MAJOR '7';
132 MIN_SEVEN: MINOR '7';
134 INTERVAL: (MAJOR|MINOR)* ('b'|'#')* DIGITS ;