Browse Source

Fix bug: line number appeard twice in error message

pull/176/head
Louis 9 years ago
parent
commit
e596013ed3
  1. 7
      patacrep/songs/chordpro/lexer.py

7
patacrep/songs/chordpro/lexer.py

@ -140,8 +140,7 @@ class ChordProLexer:
def error(self, token, more=""): def error(self, token, more=""):
"""Display error message, and skip illegal token.""" """Display error message, and skip illegal token."""
message = "Line {line}: Illegal character '{char}'{more}.".format( message = "Illegal character '{char}'{more}.".format(
line=token.lexer.lineno,
char=token.value[0], char=token.value[0],
more=more, more=more,
) )
@ -151,7 +150,9 @@ class ChordProLexer:
message=message, message=message,
)) ))
if self.filename is not None: if self.filename is not None:
message = "File {}: {}".format(self.filename, message) message = "File {}, line {}: {}".format(self.filename, token.lexer.lineno, message)
else:
message = "Line {}: {}".format(token.lexer.lineno, message)
LOGGER.warning(message) LOGGER.warning(message)
token.lexer.skip(1) token.lexer.skip(1)

Loading…
Cancel
Save