summaryrefslogtreecommitdiff
path: root/gerber/parser.py
diff options
context:
space:
mode:
authorPaulo Henrique Silva <ph.silva@gmail.com>2014-10-25 12:52:13 -0200
committerPaulo Henrique Silva <ph.silva@gmail.com>2014-10-25 12:52:13 -0200
commitd0eedf3dd7ee4fbf19f51de319e48dd964b93561 (patch)
treebde6b623ba472d9542c4534366b0f7e20b1b72c3 /gerber/parser.py
parent5c4705fcee7786dc82d57cd09afeeca6abfcbb1b (diff)
downloadgerbonara-d0eedf3dd7ee4fbf19f51de319e48dd964b93561.tar.gz
gerbonara-d0eedf3dd7ee4fbf19f51de319e48dd964b93561.tar.bz2
gerbonara-d0eedf3dd7ee4fbf19f51de319e48dd964b93561.zip
Support for zero size C apertures and fix parsing of ADDNN<macro-name>
Diffstat (limited to 'gerber/parser.py')
-rw-r--r--gerber/parser.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/gerber/parser.py b/gerber/parser.py
index 4900cb1..67893af 100644
--- a/gerber/parser.py
+++ b/gerber/parser.py
@@ -98,7 +98,10 @@ class ADParamStmt(ParamStmt):
ParamStmt.__init__(self, param)
self.d = d
self.shape = shape
- self.modifiers = [[x for x in m.split("X")] for m in modifiers.split(",")]
+ if modifiers is not None:
+ self.modifiers = [[x for x in m.split("X")] for m in modifiers.split(",")]
+ else:
+ self.modifiers = []
def to_gerber(self):
return '%ADD{0}{1},{2}*%'.format(self.d, self.shape,
@@ -191,7 +194,7 @@ class GerberParser(object):
NUMBER = r"[\+-]?\d+"
DECIMAL = r"[\+-]?\d+([.]?\d+)?"
STRING = r"[a-zA-Z0-9_+\-/!?<>”’(){}.\|&@# :]+"
- NAME = "[a-zA-Z_$][a-zA-Z_$0-9]+"
+ NAME = r"[a-zA-Z_$][a-zA-Z_$0-9]+"
FUNCTION = r"G\d{2}"
COORD_OP = r"D[0]?[123]"
@@ -201,10 +204,10 @@ class GerberParser(object):
IP = r"(?P<param>IP)(?P<ip>(POS|NEG))"
LP = r"(?P<param>LP)(?P<lp>(D|C))"
AD_CIRCLE = r"(?P<param>AD)D(?P<d>\d+)(?P<shape>C)[,](?P<modifiers>[^,]*)"
- AD_RECT = r"(?P<param>AD)D(?P<d>\d+)(?P<shape>R)[,](?P<modifiers>[^,]*)"
+ AD_RECT = r"(?P<param>AD)D(?P<d>\d+)(?P<shape>R)[,]?(?P<modifiers>[^,]+)?"
AD_OBROUND = r"(?P<param>AD)D(?P<d>\d+)(?P<shape>O)[,](?P<modifiers>[^,]*)"
AD_POLY = r"(?P<param>AD)D(?P<d>\d+)(?P<shape>P)[,](?P<modifiers>[^,]*)"
- AD_MACRO = r"(?P<param>AD)D(?P<d>\d+)+(?P<shape>{name})[,](?P<modifiers>[^,]*)".format(name=NAME)
+ AD_MACRO = r"(?P<param>AD)D(?P<d>\d+)(?P<shape>{name})[,]?(?P<modifiers>[^,]+)?".format(name=NAME)
AM = r"(?P<param>AM)(?P<name>{name})\*(?P<macro>.*)".format(name=NAME)
# begin deprecated
@@ -213,7 +216,7 @@ class GerberParser(object):
LN = r"(?P<param>LN)(?P<name>.*)"
# end deprecated
- PARAMS = (FS, MO, IP, LP, AD_CIRCLE, AD_RECT, AD_OBROUND, AD_MACRO, AD_POLY, AM, OF, IN, LN)
+ PARAMS = (FS, MO, IP, LP, AD_CIRCLE, AD_RECT, AD_OBROUND, AD_POLY, AD_MACRO, AM, OF, IN, LN)
PARAM_STMT = [re.compile(r"%{0}\*%".format(p)) for p in PARAMS]
COORD_STMT = re.compile((