From a56ff2b562d7edebe7aac6ab678748fc380c0335 Mon Sep 17 00:00:00 2001 From: pgeerkens Date: Mon, 9 May 2016 12:02:48 -0400 Subject: [PATCH] Eliminated strong dependency on whiteSpace locations, at cost of a Shift-Reduce conflict. --- QABCIronyParser/QabcGrammar.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/QABCIronyParser/QabcGrammar.cs b/QABCIronyParser/QabcGrammar.cs index f449f04..e3d0c1f 100644 --- a/QABCIronyParser/QabcGrammar.cs +++ b/QABCIronyParser/QabcGrammar.cs @@ -98,11 +98,13 @@ public QabcGrammar() : base(false) { Tune.Rule = MakePlusList(Direction, whiteSpace, true) + NewLine + MakePlusList(MusicLine); - MusicLine.Rule = MakePlusList(MusicBar, whiteSpace, true) + NewLine; + MusicLine.Rule = MakePlusList(MusicBar, whiteSpace, true) + NewLine + | whiteSpace + MusicLine; - MusicBar.Rule = MakePlusList(Music, whiteSpace, true) + bar; + MusicBar.Rule = MakePlusList(Music) + bar; Music.Rule = Direction | Beam + | Music + whiteSpace; #if KeySpec | FieldKeyLine #endif @@ -128,20 +130,20 @@ public QabcGrammar() : base(false) { Pitch.Rule = noteLetter | noteLetter + sharpFlat; - Direction.ErrorRule = SyntaxError + NewLine; - Note.ErrorRule = SyntaxError + whiteSpace; + MusicLine.ErrorRule = SyntaxError + NewLine; + Music.ErrorRule = SyntaxError + whiteSpace; #region Key Specification #if KeySpec - FieldKeyLine.Rule = FieldK + Key; // + NewLine; + FieldKeyLine.Rule = FieldK + Key; // + NewLine; Key.Rule = KeySpec | bagpipes; KeySpec.Rule = Pitch // | keyNote + modeSpec ; // | KeySpec + MakePlusList(GlobalAccidental,typeof(ListNode)); // keyNote.Rule = noteLetter | noteLetter + sharpFlat; //KeyAccidental; -// modeSpec.Rule = Mode +// modeSpec.Rule = Mode // | PreferShiftHere() + whiteSpace + Mode; -// Mode.Rule = MakePlusList(Alpha, typeof(AbcList_String)); +// Mode.Rule = MakePlusList(Alpha, typeof(AbcList_String)); // only specified modes allowed: look-up in list // GlobalAccidental.Rule= PreferShiftHere() + whiteSpace + noteLetter + sharpFlat; MarkTransient(FieldKeyLine); @@ -158,7 +160,7 @@ public QabcGrammar() : base(false) { new List() {noteLetter,sharpFlat,dot,integer}, new List() {tempo,length,octave,shift} ); - #endregion 7-Color Highlighting + #endregion 4-Color Highlighting } /// Whitespace is part of this grammar, so we override the routine that skips it.