diff -r c73432653fd9 -r d98502ae1f33 header.py --- a/header.py Sun Jun 23 00:55:21 2019 +0300 +++ b/header.py Sun Jun 23 12:09:20 2019 +0300 @@ -42,13 +42,6 @@ def valid(self): return False -geometrical_types = [ - linetypes.LineSegment, - linetypes.Triangle, - linetypes.Quadrilateral, - linetypes.ConditionalLine, -] - def is_invertnext(entry): return isinstance(entry, linetypes.MetaCommand) \ and entry.text == "BFC INVERTNEXT" @@ -60,7 +53,11 @@ return not any( isinstance(entry, linetype) for linetype in [ - *geometrical_types, + linetypes.SubfileReference, + linetypes.LineSegment, + linetypes.Triangle, + linetypes.Quadrilateral, + linetypes.ConditionalLine, linetypes.Comment, linetypes.Error, ] @@ -166,7 +163,8 @@ 'cmdline'): result.cmdline = self.groups[0] else: - self.parse_error("couldn't understand header syntax: " + repr(header_entry.text)) + self.cursor -= 1 + break if not result.filetype: self.parse_error('LDRAW_ORG line is missing') return { @@ -176,15 +174,16 @@ def parse_error(self, message): raise HeaderError(index = self.cursor, reason = message) def get_more_header_stuff(self): - while True: - self.cursor += 1 - if self.cursor >= len(self.model_body): - break - entry = self.model_body[self.cursor] + self.cursor += 1 + new_cursor = self.cursor + while new_cursor < len(self.model_body): + entry = self.model_body[new_cursor] if not is_suitable_header_object(entry): break if isinstance(entry, linetypes.MetaCommand): + self.cursor = new_cursor yield entry + new_cursor += 1 def skip_to_next(self, *, spaces_expected = 0): while True: if self.cursor + 1 >= len(self.model_body):