From 443e8509a12b3a2513921021b20bc8390c77f34c Mon Sep 17 00:00:00 2001 From: Louis Date: Sun, 20 Mar 2016 07:38:19 +0100 Subject: [PATCH] [test] Refine tests. Untested draft of fix. --- patacrep/songs/chordpro/lexer.py | 8 ++++++++ test/test_song/latex.csg | 0 test/test_song/latex.csg.source | 9 +++++++++ test/test_song/latex.tsg | 0 .../latex_special_datadir/songs/special.csg | 8 ++++---- 5 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 test/test_song/latex.csg create mode 100644 test/test_song/latex.csg.source create mode 100644 test/test_song/latex.tsg diff --git a/patacrep/songs/chordpro/lexer.py b/patacrep/songs/chordpro/lexer.py index 7674c22f..ad9c4d20 100644 --- a/patacrep/songs/chordpro/lexer.py +++ b/patacrep/songs/chordpro/lexer.py @@ -30,6 +30,8 @@ tokens = ( 'EE', ) +literals = [ '{', '}', "\\", ' ' ] + class ChordProLexer: """ChordPro Lexer class""" # pylint: disable=too-many-public-methods @@ -150,6 +152,12 @@ class ChordProLexer: self.lexer.push_state('directiveargument') return token + @staticmethod + def t_literal(token): + r'\[{} \]' + t.type = t.type[1] + return t + def error(self, token, more=""): """Display error message, and skip illegal token.""" message = "Illegal character '{char}'{more}.".format( diff --git a/test/test_song/latex.csg b/test/test_song/latex.csg new file mode 100644 index 00000000..e69de29b diff --git a/test/test_song/latex.csg.source b/test/test_song/latex.csg.source new file mode 100644 index 00000000..c00062f6 --- /dev/null +++ b/test/test_song/latex.csg.source @@ -0,0 +1,9 @@ +{title: & $ % # _ \} \{ ~ ^ \\} +{artist: & $ % # _ \} \{ ~ ^ \\} +{album: & $ % # _ \} \{ ~ ^ \\} + +& $ % # _ \} \{ ~ ^ \\ + +{start_of_chorus} +& $ % # _ \} \{ ~ ^ \\ +{end_of_chorus} diff --git a/test/test_song/latex.tsg b/test/test_song/latex.tsg new file mode 100644 index 00000000..e69de29b diff --git a/test/test_songbook/latex_special_datadir/songs/special.csg b/test/test_songbook/latex_special_datadir/songs/special.csg index 7740b6df..0f058af6 100644 --- a/test/test_songbook/latex_special_datadir/songs/special.csg +++ b/test/test_songbook/latex_special_datadir/songs/special.csg @@ -1,8 +1,8 @@ -{title : & % $ # _ } { ~ ^ \ } -{by: & % $ # _ } { ~ ^ \ } +{title : & % $ # _ \} \{ ~ ^ \\ } +{by: & % $ # _ }\ \{ ~ ^ \\ } -& % $ # _ } { ~ ^ \ +& % $ # _ }\ \{ ~ ^ \\ {soc} - & % $ # _ } { ~ ^ \ + & % $ # _ }\ \{ ~ ^ \\ {eoc}