From 263617ca754fc7b3fc550a33934fcbcbe5ef8acf Mon Sep 17 00:00:00 2001 From: jaseg Date: Sun, 6 Feb 2022 01:10:17 +0100 Subject: Add Zuken tests and fix parsing --- gerbonara/rs274x.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'gerbonara/rs274x.py') diff --git a/gerbonara/rs274x.py b/gerbonara/rs274x.py index 51a5e19..5c1ecc6 100644 --- a/gerbonara/rs274x.py +++ b/gerbonara/rs274x.py @@ -522,7 +522,7 @@ class GerberParser: STATEMENT_REGEXES = { 'region_start': r'G36$', 'region_end': r'G37$', - 'coord': fr"(?PG0?[123]|G74|G75)?(X(?P{NUMBER}))?(Y(?P{NUMBER}))?" \ + 'coord': fr"(?PG0?[123]|G74|G75|G54|G55)?(X(?P{NUMBER}))?(Y(?P{NUMBER}))?" \ fr"(I(?P{NUMBER}))?(J(?P{NUMBER}))?" \ fr"(?PD0?[123])?$", 'aperture': r"(G54|G55)?D(?P\d+)", @@ -669,6 +669,10 @@ class GerberParser: self.multi_quadrant_mode = True # used only for syntax checking elif match['interpolation'] == 'G75': self.multi_quadrant_mode = False + elif match['interpolation'] == 'G54': + pass # ignore. + elif match['interpolation'] == 'G55': + self.generator_hints.append('zuken') has_coord = (match['x'] or match['y'] or match['i'] or match['j']) if match['interpolation'] in ('G74', 'G75') and has_coord: @@ -745,7 +749,11 @@ class GerberParser: raise SyntaxError(f'Invalid aperture number {number}: Aperture number must be >= 10.') if number not in self.aperture_map: - raise SyntaxError(f'Tried to access undefined aperture {number}') + if number == 10 and 'zuken' in self.generator_hints: + self.warn(f'Tried to access undefined aperture D10. This looks like a Zuken CR-8000 file. For these ' + 'files, it is normal that an undefined aperture is used for region specifications.') + else: + raise SyntaxError(f'Tried to access undefined aperture {number}') self.graphics_state.aperture = self.aperture_map[number] @@ -969,9 +977,12 @@ class GerberParser: if 'EAGLE' in self.file_attrs.get('.GenerationSoftware', []) or match['eagle_garbage']: self.generator_hints.append('eagle') - def _parse_eof(self, _match): + def _parse_eof(self, match): self.eof_found = True + if match[0] == 'M00': + self.generator_hints.append('zuken') + def _parse_ignored(self, match): pass -- cgit