summaryrefslogtreecommitdiff
path: root/gerber/gerber.py
diff options
context:
space:
mode:
authorHamilton Kibbe <hamilton.kibbe@gmail.com>2014-10-09 09:51:29 -0400
committerHamilton Kibbe <hamilton.kibbe@gmail.com>2014-10-09 09:51:29 -0400
commit84bfd34e918251ff82f4b3818bc6268feab72efe (patch)
tree4362bed2208efa281817635bf2a5d8ba1c5d9aac /gerber/gerber.py
parentbcb6cbc50dea975954b8a3864690f68ab5e984b7 (diff)
downloadgerbonara-84bfd34e918251ff82f4b3818bc6268feab72efe.tar.gz
gerbonara-84bfd34e918251ff82f4b3818bc6268feab72efe.tar.bz2
gerbonara-84bfd34e918251ff82f4b3818bc6268feab72efe.zip
Add mode statement parsing
Diffstat (limited to 'gerber/gerber.py')
-rw-r--r--gerber/gerber.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/gerber/gerber.py b/gerber/gerber.py
index 07ecd78..c59d871 100644
--- a/gerber/gerber.py
+++ b/gerber/gerber.py
@@ -164,6 +164,9 @@ class GerberParser(object):
EOF_STMT = re.compile(r"(?P<eof>M02)\*")
+ REGION_MODE_STMT = re.compile(r'(?P<mode>G3[67])\*')
+ QUAD_MODE_STMT = re.compile(r'(?P<mode>G7[45])\*')
+
def __init__(self):
self.settings = FileSettings()
self.statements = []
@@ -206,12 +209,21 @@ class GerberParser(object):
while did_something and len(line) > 0:
did_something = False
- # region mode
- #if 'G36' in line or 'G37' in line:
- # yield RegionModeStmt.from_gerber(line)
- # did_something = True
- # line = ''
- # continue
+ # Region Mode
+ (mode, r) = self._match_one(self.REGION_MODE_STMT, line)
+ if mode:
+ yield RegionModeStmt.from_gerber(line)
+ line = r
+ did_something = True
+ continue
+
+ # Quadrant Mode
+ (mode, r) = self._match_one(self.QUAD_MODE_STMT, line)
+ if mode:
+ yield QuadrantModeStmt.from_gerber(line)
+ line = r
+ did_something = True
+ continue
# coord
(coord, r) = self._match_one(self.COORD_STMT, line)