1. Juha Komulainen
  2. sgfproc

Commits

Juha Komulainen  committed 97e412e

Include line/column info in ParseError.

  • Participants
  • Parent commits e6255e1
  • Branches default

Comments (0)

Files changed (1)

File sgfparser.py

View file
  • Ignore whitespace
         return PropertyValue(''.join(chars))
 
     def parse_error(self, message):
-        return ParseError("%d:%d: %s" % (self.line, self.column, message))
+        return ParseError(self.line, self.column, message)
         
     def expect(self, expected):
         ch = self.read_token()
             raise ParseError("foo")
             
 class ParseError(Exception):
-    def __init__(self, msg):
+    def __init__(self, line, column, msg):
+        self.line = line
+        self.column = column
         self.msg = msg
         
     def __str__(self):
-        return self.msg
+        return "[%d:%d] %s" % (self.line, self.column, self.msg)
 
 def strip_comments(sgf):
     collection = SgfParser(sgf).parse_collection()