From e981c70bc6b202bb36451ed337a62ff91372cbdd Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 6 Nov 2015 10:35:27 +0100 Subject: [PATCH] Support CRLF, LF and CR line endings --- patacrep/songs/chordpro/lexer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/patacrep/songs/chordpro/lexer.py b/patacrep/songs/chordpro/lexer.py index a0b57826..9554f8bf 100644 --- a/patacrep/songs/chordpro/lexer.py +++ b/patacrep/songs/chordpro/lexer.py @@ -80,8 +80,8 @@ class ChordProLexer: r'[ \t]+' return token - t_tablature_TEXT = r'[^\n]+' - t_tablature_ENDOFLINE = r'\n' + t_tablature_TEXT = r'[^\n\r]+' + t_tablature_ENDOFLINE = r'(\r\n)|\r|\n' def __init__(self, *, filename=None): self.__class__.lexer = lex.lex(module=self) @@ -90,7 +90,7 @@ class ChordProLexer: # Define a rule so we can track line numbers @staticmethod def t_ENDOFLINE(token): - r'[\n\r]' + r'(\r\n)|\r|\n' token.lexer.lineno += 1 return token @@ -101,7 +101,7 @@ class ChordProLexer: @staticmethod def t_WORD(token): - r'[^{}\n\][\t ]+' + r'[^{}\r\n\][\t ]+' return token def t_LBRACKET(self, __token):