Skip to content

Commit

Permalink
parser
Browse files Browse the repository at this point in the history
  • Loading branch information
escalonn committed Aug 16, 2015
1 parent a8b3279 commit 9ff20ec
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ck2parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"#={}]+',))
]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 9ff20ec

Please sign in to comment.