From d1c74317c8df83da5d9f01b74c28be2b467fa300 Mon Sep 17 00:00:00 2001 From: Paulo Henrique Silva Date: Tue, 7 Apr 2015 18:26:33 -0300 Subject: Add some deprecated but still found statements --- gerber/rs274x.py | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'gerber/rs274x.py') diff --git a/gerber/rs274x.py b/gerber/rs274x.py index 07fce17..fbedc77 100644 --- a/gerber/rs274x.py +++ b/gerber/rs274x.py @@ -160,23 +160,28 @@ class GerberParser(object): OF = r"(?POF)(A(?P{decimal}))?(B(?P{decimal}))?".format(decimal=DECIMAL) SF = r"(?PSF)(?P.*)" LN = r"(?PLN)(?P.*)" + DEPRECATED_UNIT = re.compile(r'(?PG7[01])\*') + DEPRECATED_FORMAT = re.compile(r'(?PG9[01])\*') # end deprecated PARAMS = (FS, MO, LP, AD_CIRCLE, AD_RECT, AD_OBROUND, AD_POLY, AD_MACRO, AM, AS, IN, IP, IR, MI, OF, SF, LN) + PARAM_STMT = [re.compile(r"%?{0}\*%?".format(p)) for p in PARAMS] + COORD_FUNCTION = r"G0?[123]" + COORD_OP = r"D0?[123]" + COORD_STMT = re.compile(( r"(?P{function})?" r"(X(?P{number}))?(Y(?P{number}))?" r"(I(?P{number}))?(J(?P{number}))?" - r"(?P{op})?\*".format(number=NUMBER, function=FUNCTION, op=COORD_OP))) - - APERTURE_STMT = re.compile(r"(?P(G54)|G55)?D(?P\d+)\*") + r"(?P{op})?\*".format(number=NUMBER, function=COORD_FUNCTION, op=COORD_OP))) + APERTURE_STMT = re.compile(r"(?P(G54)|(G55))?D(?P\d+)\*") - COMMENT_STMT = re.compile(r"G04(?P[^*]*)(\*)?") + COMMENT_STMT = re.compile(r"G0?4(?P[^*]*)(\*)?") - EOF_STMT = re.compile(r"(?PM02)\*") + EOF_STMT = re.compile(r"(?PM[0]?[012])\*") REGION_MODE_STMT = re.compile(r'(?PG3[67])\*') QUAD_MODE_STMT = re.compile(r'(?PG7[45])\*') @@ -330,6 +335,21 @@ class GerberParser(object): line = r continue + # deprecated codes (parsed but ignored) + (deprecated_unit, r) = _match_one(self.DEPRECATED_UNIT, line) + if deprecated_unit: + yield DeprecatedStmt.from_gerber(line) + line = r + did_something = True + continue + + (deprecated_format, r) = _match_one(self.DEPRECATED_FORMAT, line) + if deprecated_format: + yield DeprecatedStmt.from_gerber(line) + line = r + did_something = True + continue + # eof (eof, r) = _match_one(self.EOF_STMT, line) if eof: @@ -370,7 +390,7 @@ class GerberParser(object): elif isinstance(stmt, (RegionModeStmt, QuadrantModeStmt)): self._evaluate_mode(stmt) - elif isinstance(stmt, (CommentStmt, UnknownStmt, EofStmt)): + elif isinstance(stmt, (CommentStmt, UnknownStmt, DeprecatedStmt, EofStmt)): return else: -- cgit