Browse Source

[chordpro] Accepting + and * in chords

References patacrep/patadata#18
pull/79/head
Louis 9 years ago
parent
commit
af0e83bbf9
  1. 2
      patacrep/songs/chordpro/ast.py
  2. 1
      patacrep/songs/chordpro/data/chordpro/content_chord
  3. 1
      patacrep/songs/chordpro/data/latex/content_chord
  4. 2
      patacrep/songs/chordpro/lexer.py
  5. 5
      patacrep/songs/chordpro/syntax.py
  6. 2
      patacrep/songs/chordpro/test/chords.sgc
  7. 2
      patacrep/songs/chordpro/test/chords.source
  8. 2
      patacrep/songs/chordpro/test/chords.tex
  9. 2
      patacrep/songs/chordpro/test/customchords.sgc
  10. 2
      patacrep/songs/chordpro/test/customchords.source
  11. 2
      patacrep/songs/chordpro/test/customchords.tex
  12. 2
      patacrep/songs/chordpro/test/invalid_chord.source

2
patacrep/songs/chordpro/ast.py

@ -153,6 +153,7 @@ class Chord(AST):
addnote=None,
basskey=None,
bassalteration=None,
star=None,
):
# pylint: disable=too-many-arguments
self.key = key
@ -161,6 +162,7 @@ class Chord(AST):
self.addnote = addnote
self.basskey = basskey
self.bassalteration = bassalteration
self.star = star
class Verse(AST):
"""A verse (or bridge, or chorus)"""

1
patacrep/songs/chordpro/data/chordpro/content_chord

@ -6,4 +6,5 @@
/
((- content.basskey -))
(* if content.bassalteration *)(( content.bassalteration ))(* endif -*)
(* if content.star *)*(* endif -*)
(* endif -*)

1
patacrep/songs/chordpro/data/latex/content_chord

@ -8,4 +8,5 @@
((- content.basskey -))
(* if content.bassalteration == '#' *)#(* endif -*)
(* if content.bassalteration == 'b' *)&(* endif -*)
(* if content.star *)*(* endif -*)
(* endif -*)

2
patacrep/songs/chordpro/lexer.py

@ -39,7 +39,7 @@ class ChordProLexer:
t_SPACE = r'[ \t]+'
t_chord_CHORD = r'[A-G#bmajdisus2-9/ ]+'
t_chord_CHORD = r'[A-G#bmajdisus+*2-9/ ]+'
t_directive_SPACE = r'[ \t]+'
t_directive_KEYWORD = r'[a-zA-Z_]+'

5
patacrep/songs/chordpro/syntax.py

@ -12,13 +12,14 @@ CHORD_RE = re.compile(
^
(?P<key>[A-G])
(?P<alteration>[b#])?
(?P<modifier>(maj|sus|dim|m))?
(?P<modifier>(maj|sus|dim|m|\+))?
(?P<addnote>[2-9])?
(
/
(?P<basskey>[A-G])
(?P<bassalteration>[b#])?
)?
(?P<star>\*)?
$
""",
re.VERBOSE
@ -223,7 +224,7 @@ class ChordproParser(Parser):
def p_chord(self, symbols):
"""chord : CHORD"""
symbols[0] = ast.ChordList(*self._parse_chords(symbols[1], symbols=symbols))
symbols[0] = ast.ChordList(*list(self._parse_chords(symbols[1], symbols=symbols)))
@staticmethod
def p_chorus(symbols):

2
patacrep/songs/chordpro/test/chords.sgc

@ -14,4 +14,6 @@
[F/Fb]Deux notes, bémol
[B/C#]Deux notes, dièse
[Ab B#/A]Plusieurs notes à la suite
[E5/A*]Avec une étoile
[B#+8]Avec un plus
{end_of_verse}

2
patacrep/songs/chordpro/test/chords.source

@ -11,3 +11,5 @@
[F/Fb]Deux notes, bémol
[B/C#]Deux notes, dièse
[Ab B#/A]Plusieurs notes à la suite
[E5/A*]Avec une étoile
[B#+8]Avec un plus

2
patacrep/songs/chordpro/test/chords.tex

@ -20,6 +20,8 @@
\[F/F&]Deux notes, bémol
\[B/C#]Deux notes, dièse
\[A& B#/A]Plusieurs notes à la suite
\[E5/A*]Avec une étoile
\[B#+8]Avec un plus
\end{verse}
\endsong

2
patacrep/songs/chordpro/test/customchords.sgc

@ -1,3 +1,5 @@
{language: english}
{define: E4 base-fret 7 frets 0 1 3 3 x x}
{define: E5 base-fret 7 frets 0 1 3 3 x x fingers - 1 2 3 - -}
{define: E5/A* base-fret 7 frets 0 1 3 3 x x fingers - 1 2 3 - -}
{define: A#+2 base-fret 7 frets 0 1 3 3 x x fingers - 1 2 3 - -}

2
patacrep/songs/chordpro/test/customchords.source

@ -1,2 +1,4 @@
{define: E4 base-fret 7 frets 0 1 3 3 x x}
{define: E5 base-fret 7 frets 0 1 3 3 x x fingers - 1 2 3 - -}
{define: E5/A* base-fret 7 frets 0 1 3 3 x x fingers - 1 2 3 - -}
{define: A#+2 base-fret 7 frets 0 1 3 3 x x fingers - 1 2 3 - -}

2
patacrep/songs/chordpro/test/customchords.tex

@ -7,6 +7,8 @@
\gtab{E4}{7:0133XX}
\gtab{E5}{7:0133XX:012300}
\gtab{E5/A*}{7:0133XX:012300}
\gtab{A#+2}{7:0133XX:012300}
\endsong

2
patacrep/songs/chordpro/test/invalid_chord.source

@ -1,3 +1,3 @@
This is [H] invalid.
This [A+]too.
This [A@]too.
And [Amm]as well.

Loading…
Cancel
Save