small bugfixes

This commit is contained in:
Julian Daube 2019-07-02 14:45:15 +02:00
parent 167c40c9e5
commit 4eb3dc8407
3 changed files with 21 additions and 34 deletions

View File

@ -37,7 +37,6 @@ class Library(object):
count = Progress(self) count = Progress(self)
for key, value in self.structures.items(): for key, value in self.structures.items():
for element in value.references: for element in value.references:
if isinstance(element.structure, str): if isinstance(element.structure, str):
# try to resolve link # try to resolve link

View File

@ -122,6 +122,7 @@ class Parser(Reader):
def parse_structure(self): def parse_structure(self):
self.structure = Structure() self.structure = Structure()
print(self.structure.references)
if self.token.ident != Records.BGNSTR: if self.token.ident != Records.BGNSTR:
return False return False
@ -166,15 +167,17 @@ class Parser(Reader):
element.plex = self.read_int() element.plex = self.read_int()
self.next_token(True) self.next_token(True)
def parse_boundary(self): def parse_layer(self, element):
element = Boundary() if self.token.ident != Records.LAYER:
if not self.next_token():
raise ParserError(errors.EXPECTED_LAYER) raise ParserError(errors.EXPECTED_LAYER)
self.parse_element(element) element.layer = self.read_ushort()
if self.token.ident == Records.LAYER: def parse_boundary(self):
element.layer = self.read_short() element = Boundary()
self.next_token(True)
self.parse_element(element)
self.parse_layer(element)
if not self.next_token() or self.token.ident != Records.DATATYPE: if not self.next_token() or self.token.ident != Records.DATATYPE:
raise ParserError(errors.EXPECTED_DATATYPE) raise ParserError(errors.EXPECTED_DATATYPE)
@ -193,15 +196,9 @@ class Parser(Reader):
def parse_path(self): def parse_path(self):
element = Path() element = Path()
if not self.next_token(): self.next_token(True)
raise ParserError(errors.EXPECTED_LAYER)
self.parse_element(element) self.parse_element(element)
self.parse_layer(element)
if self.token.ident != Records.LAYER:
raise ParserError(errors.EXPECTED_LAYER)
element.layer = self.read_short()
if not self.next_token() or self.token.ident != Records.DATATYPE: if not self.next_token() or self.token.ident != Records.DATATYPE:
raise ParserError(errors.EXPECTED_DATATYPE) raise ParserError(errors.EXPECTED_DATATYPE)
@ -246,15 +243,9 @@ class Parser(Reader):
def parse_text(self): def parse_text(self):
element = Text() element = Text()
if not self.next_token(): self.next_token(True)
raise ParserError(errors.EXPECTED_LAYER)
self.parse_element(element) self.parse_element(element)
self.parse_layer(element)
if not self.token.ident == Records.LAYER:
raise ParserError(errors.EXPECTED_LAYER)
element.layer = self.read_short()
if not self.next_token() or self.token.ident != Records.TEXTTYPE: if not self.next_token() or self.token.ident != Records.TEXTTYPE:
raise ParserError(errors.EXPECTED_TEXTTYPE) raise ParserError(errors.EXPECTED_TEXTTYPE)
@ -299,11 +290,12 @@ class Parser(Reader):
self.structure.elements.append(element) self.structure.elements.append(element)
def parse_strans(self, trans:Transformation): def parse_strans(self, trans:Transformation):
if self.token.ident != Records.STRANS: if self.token.ident != Records.STRANS:
return return
flags = self.read_short() flags = self.read_ushort()
if flags & 0x01: if flags & 0x01:
trans.mirror_x = True trans.mirror_x = True
@ -325,15 +317,9 @@ class Parser(Reader):
def parse_box(self): def parse_box(self):
element = Box() element = Box()
if not self.next_token(): self.next_token(True)
raise ParserError(errors.EXPECTED_LAYER)
self.parse_element(element) self.parse_element(element)
self.parse_layer(element)
if self.token.ident != Records.LAYER:
raise ParserError(errors.EXPECTED_LAYER)
element.layer = self.read_short()
if not self.next_token() or self.token.ident != Records.BOXTYPE: if not self.next_token() or self.token.ident != Records.BOXTYPE:
raise ParserError(errors.EXPECTED_BOXTYPE) raise ParserError(errors.EXPECTED_BOXTYPE)
@ -393,6 +379,7 @@ class Parser(Reader):
element.structure = self.read_ascii(self.token.len) element.structure = self.read_ascii(self.token.len)
self.next_token(True) self.next_token(True)
self.parse_strans(element.transformation) self.parse_strans(element.transformation)
if self.token.ident != Records.COLROW: if self.token.ident != Records.COLROW:

View File

@ -8,5 +8,6 @@ class Structure(object):
# contains all the low level elements # contains all the low level elements
elements = [] elements = []
# contains all sref and aref elements # contains all sref and aref elements
references = [] references = []