diff --git a/ck2parser.py b/ck2parser.py index 6dbfb74..029282d 100644 --- a/ck2parser.py +++ b/ck2parser.py @@ -62,7 +62,7 @@ def chars(line): ('newline', (r'\r?\n',)), ('op', (r'[={}]',)), ('date', (r'\d*\.\d*\.\d*',)), - ('number', (r'\d+(\.\d+)?',)), + ('number', (r'\d+(\.\d+)?(?!\w)',)), ('quoted_string', (r'"[^"#\r\n]*"',)), ('unquoted_string', (r'[^\s"#={}]+',)) ] @@ -113,6 +113,10 @@ def __iter__(self): def indent(self): return self._indent + @property + def has_pairs(self): + return not self.contents or isinstance(self.contents[0], Pair) + @indent.setter def indent(self, value): self._indent = value @@ -492,7 +496,7 @@ def parse_file(path, encoding='cp1252'): with path.open(encoding=encoding) as f: try: tree = parse(f.read()) - except parser.NoParseError: + except: print(path) raise return tree