[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: pcb.git: branch: master updated (fce9e501a4bbfbed10c92b395296440169575955)
The branch, master has been updated
via fce9e501a4bbfbed10c92b395296440169575955 (commit)
from d30d31425fa318390e4632d5063e6bb655b01793 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
=========
Summary
=========
globalconst.h | 4 +-
src/buffer.c | 2 +-
src/global.h | 7 +
src/parse_y.y | 440 +++++++++++++++++++++++++++++++--------------------------
4 files changed, 252 insertions(+), 201 deletions(-)
=================
Commit Messages
=================
commit fce9e501a4bbfbed10c92b395296440169575955
Author: DJ Delorie <dj@xxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>
Fix shift/reduce conflicts
Closes-bug: lp-794743
I moved the interpretation of what "measurement" means even further up
the heirarchy, by storing the original integer part as well as the units
in a structure, and applying the new/old/unitless meanings where they're
used. This way, there's no conflicts between a number which is a
measurement, and a number which is a flag or mask, for the old formats
that differ only in the number of parameters.
I also cleaned up the parser rules for "zero or more" type lists,
to remove most of the remaining conflicts. There's still one at the
toplevel because we try to parse different types of files with the same
parser.
Lastly, the symbol rules were combined into a "symbol head" rule with a
common "symbol body" rule.
As a side effect, we can now reliably use units on old-style formats
again, since the *100 scale factor is only applied if the units are not
specified.
:100755 100755 428135d... 605d909... M globalconst.h
:100644 100644 2e63af5... 6ff6132... M src/buffer.c
:100644 100644 498e3f8... daa82a9... M src/global.h
:100644 100644 05f0a49... 8eaba94... M src/parse_y.y
=========
Changes
=========
commit fce9e501a4bbfbed10c92b395296440169575955
Author: DJ Delorie <dj@xxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>
Fix shift/reduce conflicts
Closes-bug: lp-794743
I moved the interpretation of what "measurement" means even further up
the heirarchy, by storing the original integer part as well as the units
in a structure, and applying the new/old/unitless meanings where they're
used. This way, there's no conflicts between a number which is a
measurement, and a number which is a flag or mask, for the old formats
that differ only in the number of parameters.
I also cleaned up the parser rules for "zero or more" type lists,
to remove most of the remaining conflicts. There's still one at the
toplevel because we try to parse different types of files with the same
parser.
Lastly, the symbol rules were combined into a "symbol head" rule with a
common "symbol body" rule.
As a side effect, we can now reliably use units on old-style formats
again, since the *100 scale factor is only applied if the units are not
specified.
diff --git a/globalconst.h b/globalconst.h
index 428135d..605d909 100755
--- a/globalconst.h
+++ b/globalconst.h
@@ -54,8 +54,8 @@
/* ---------------------------------------------------------------------------
* frame between the groundplane and the copper
*/
-#define GROUNDPLANEFRAME 15 /* unit == mil */
-#define MASKFRAME 3 /* unit == mil */
+#define GROUNDPLANEFRAME MIL_TO_COORD(15)
+#define MASKFRAME MIL_TO_COORD(3)
/* ---------------------------------------------------------------------------
* some limit specifications
diff --git a/src/buffer.c b/src/buffer.c
index 2e63af5..6ff6132 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1004,7 +1004,7 @@ ConvertBufferToElement (BufferTypePtr Buffer)
{
char num[8];
if (via->Mask < via->Thickness)
- via->Mask = via->Thickness + 2 * MIL_TO_COORD(MASKFRAME); /* MASKFRAME is in mils */
+ via->Mask = via->Thickness + 2 * MASKFRAME;
if (via->Name)
CreateNewPin (Element, via->X, via->Y, via->Thickness,
via->Clearance, via->Mask, via->DrillingHole,
diff --git a/src/global.h b/src/global.h
index 498e3f8..daa82a9 100644
--- a/src/global.h
+++ b/src/global.h
@@ -86,6 +86,13 @@ typedef struct AttributeListType AttributeListType, *AttributeListTypePtr;
typedef int LocationType;
typedef int BDimension; /* big dimension */
+/* This is used by the lexer/parser */
+typedef struct {
+ int ival;
+ BDimension bval;
+ double dval;
+ char has_units;
+} PLMeasure;
#ifndef XtSpecificationRelease
typedef unsigned int Cardinal;
diff --git a/src/parse_y.y b/src/parse_y.y
index 05f0a49..8eaba94 100644
--- a/src/parse_y.y
+++ b/src/parse_y.y
@@ -86,14 +86,35 @@ int yyerror(const char *s);
int yylex();
static int check_file_version (int);
+static void do_measure (PLMeasure *m, int i, double d, int u);
+#define M(r,f,d) do_measure (&(r), f, d, 1)
+
+/* Macros for interpreting what "measure" means - integer value only,
+ old units (mil), or new units (cmil). */
+#define IV(m) integer_value (m)
+#define OU(m) old_units (m)
+#define NU(m) new_units (m)
+
+static int integer_value (PLMeasure m);
+static BDimension old_units (PLMeasure m);
+static BDimension new_units (PLMeasure m);
+
+#define YYDEBUG 1
+#define YYERROR_VERBOSE 1
+
+#include "parse_y.h"
+
%}
+%verbose
+
%union /* define YYSTACK type */
{
int integer;
double number;
char *string;
FlagType flagtype;
+ PLMeasure measure;
}
%token <number> FLOATING /* line thickness, coordinates ... */
@@ -109,8 +130,7 @@ static int check_file_version (int);
%type <string> opt_string
%type <flagtype> flags
%type <number> number
-%type <number> measure
-%type <number> oldmeasure
+%type <measure> measure
%%
@@ -310,17 +330,17 @@ pcbname
yyPCB->MaxWidth = MAX_COORD;
yyPCB->MaxHeight = MAX_COORD;
}
- | T_PCB '(' STRING oldmeasure oldmeasure ')'
+ | T_PCB '(' STRING measure measure ')'
{
yyPCB->Name = $3;
- yyPCB->MaxWidth = $4;
- yyPCB->MaxHeight = $5;
+ yyPCB->MaxWidth = OU ($4);
+ yyPCB->MaxHeight = OU ($5);
}
| T_PCB '[' STRING measure measure ']'
{
yyPCB->Name = $3;
- yyPCB->MaxWidth = $4;
- yyPCB->MaxHeight = $5;
+ yyPCB->MaxWidth = NU ($4);
+ yyPCB->MaxHeight = NU ($5);
}
;
@@ -350,19 +370,19 @@ pcbgrid
| pcbhigrid
;
pcbgridold
- : T_GRID '(' oldmeasure oldmeasure oldmeasure ')'
+ : T_GRID '(' measure measure measure ')'
{
- yyPCB->Grid = $3;
- yyPCB->GridOffsetX = $4;
- yyPCB->GridOffsetY = $5;
+ yyPCB->Grid = OU ($3);
+ yyPCB->GridOffsetX = OU ($4);
+ yyPCB->GridOffsetY = OU ($5);
}
;
pcbgridnew
- : T_GRID '(' oldmeasure oldmeasure oldmeasure INTEGER ')'
+ : T_GRID '(' measure measure measure INTEGER ')'
{
- yyPCB->Grid = $3;
- yyPCB->GridOffsetX = $4;
- yyPCB->GridOffsetY = $5;
+ yyPCB->Grid = OU ($3);
+ yyPCB->GridOffsetX = OU ($4);
+ yyPCB->GridOffsetY = OU ($5);
if ($6)
Settings.DrawGrid = true;
else
@@ -373,9 +393,9 @@ pcbgridnew
pcbhigrid
: T_GRID '[' measure measure measure INTEGER ']'
{
- yyPCB->Grid = $3;
- yyPCB->GridOffsetX = $4;
- yyPCB->GridOffsetY = $5;
+ yyPCB->Grid = NU ($3);
+ yyPCB->GridOffsetX = NU ($4);
+ yyPCB->GridOffsetY = NU ($5);
if ($6)
Settings.DrawGrid = true;
else
@@ -403,16 +423,16 @@ first variant accepts floating point numbers. The special value
%end-doc */
pcbcursor
- : T_CURSOR '(' oldmeasure oldmeasure number ')'
+ : T_CURSOR '(' measure measure number ')'
{
- yyPCB->CursorX = $3;
- yyPCB->CursorY = $4;
+ yyPCB->CursorX = OU ($3);
+ yyPCB->CursorY = OU ($4);
yyPCB->Zoom = $5*2;
}
| T_CURSOR '[' measure measure number ']'
{
- yyPCB->CursorX = $3;
- yyPCB->CursorY = $4;
+ yyPCB->CursorX = NU ($3);
+ yyPCB->CursorY = NU ($4);
yyPCB->Zoom = $5;
}
|
@@ -501,33 +521,33 @@ pcbdrc
pcbdrc1
: T_DRC '[' measure measure measure ']'
{
- yyPCB->Bloat = $3;
- yyPCB->Shrink = $4;
- yyPCB->minWid = $5;
- yyPCB->minRing = $5;
+ yyPCB->Bloat = NU ($3);
+ yyPCB->Shrink = NU ($4);
+ yyPCB->minWid = NU ($5);
+ yyPCB->minRing = NU ($5);
}
;
pcbdrc2
: T_DRC '[' measure measure measure measure ']'
{
- yyPCB->Bloat = $3;
- yyPCB->Shrink = $4;
- yyPCB->minWid = $5;
- yyPCB->minSlk = $6;
- yyPCB->minRing = $5;
+ yyPCB->Bloat = NU ($3);
+ yyPCB->Shrink = NU ($4);
+ yyPCB->minWid = NU ($5);
+ yyPCB->minSlk = NU ($6);
+ yyPCB->minRing = NU ($5);
}
;
pcbdrc3
: T_DRC '[' measure measure measure measure measure measure ']'
{
- yyPCB->Bloat = $3;
- yyPCB->Shrink = $4;
- yyPCB->minWid = $5;
- yyPCB->minSlk = $6;
- yyPCB->minDrill = $7;
- yyPCB->minRing = $8;
+ yyPCB->Bloat = NU ($3);
+ yyPCB->Shrink = NU ($4);
+ yyPCB->minWid = NU ($5);
+ yyPCB->minSlk = NU ($6);
+ yyPCB->minDrill = NU ($7);
+ yyPCB->minRing = NU ($8);
}
;
@@ -662,7 +682,7 @@ pcbdefinitions
pcbdefinition
: via
- | { attr_list = & yyPCB->Attributes; } attributes
+ | { attr_list = & yyPCB->Attributes; } attribute
| rats
| layer
|
@@ -719,16 +739,18 @@ via_hi_format
/* x, y, thickness, clearance, mask, drilling-hole, name, flags */
: T_VIA '[' measure measure measure measure measure measure STRING flags ']'
{
- CreateNewVia(yyData, $3, $4, $5, $6, $7, $8, $9, $10);
+ CreateNewVia(yyData, NU ($3), NU ($4), NU ($5), NU ($6), NU ($7),
+ NU ($8), $9, $10);
free ($9);
}
;
via_2.0_format
/* x, y, thickness, clearance, mask, drilling-hole, name, flags */
- : T_VIA '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure STRING INTEGER ')'
+ : T_VIA '(' measure measure measure measure measure measure STRING INTEGER ')'
{
- CreateNewVia(yyData, $3, $4, $5, $6, $7, $8, $9, OldFlags($10));
+ CreateNewVia(yyData, OU ($3), OU ($4), OU ($5), OU ($6), OU ($7), OU ($8), $9,
+ OldFlags($10));
free ($9);
}
;
@@ -736,37 +758,37 @@ via_2.0_format
via_1.7_format
/* x, y, thickness, clearance, drilling-hole, name, flags */
- : T_VIA '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure STRING INTEGER ')'
+ : T_VIA '(' measure measure measure measure measure STRING INTEGER ')'
{
- CreateNewVia(yyData, $3, $4, $5, $6,
- ($5 + $6), $7, $8, OldFlags($9));
+ CreateNewVia(yyData, OU ($3), OU ($4), OU ($5), OU ($6),
+ OU ($5) + OU($6), OU ($7), $8, OldFlags($9));
free ($8);
}
;
via_newformat
/* x, y, thickness, drilling-hole, name, flags */
- : T_VIA '(' oldmeasure oldmeasure oldmeasure oldmeasure STRING INTEGER ')'
+ : T_VIA '(' measure measure measure measure STRING INTEGER ')'
{
- CreateNewVia(yyData, $3, $4, $5, 200*GROUNDPLANEFRAME,
- $5 + 200*MASKFRAME, $6, $7, OldFlags($8));
+ CreateNewVia(yyData, OU ($3), OU ($4), OU ($5), 2*GROUNDPLANEFRAME,
+ OU($5) + 2*MASKFRAME, OU ($6), $7, OldFlags($8));
free ($7);
}
;
via_oldformat
/* old format: x, y, thickness, name, flags */
- : T_VIA '(' oldmeasure oldmeasure oldmeasure STRING INTEGER ')'
+ : T_VIA '(' measure measure measure STRING INTEGER ')'
{
- BDimension hole = ($5 *DEFAULT_DRILLINGHOLE);
+ BDimension hole = (OU($5) * DEFAULT_DRILLINGHOLE);
/* make sure that there's enough copper left */
- if ($5 -hole < MIN_PINORVIACOPPER &&
- $5 > MIN_PINORVIACOPPER)
- hole = $5 -MIN_PINORVIACOPPER;
+ if (OU($5) - hole < MIN_PINORVIACOPPER &&
+ OU($5) > MIN_PINORVIACOPPER)
+ hole = OU($5) - MIN_PINORVIACOPPER;
- CreateNewVia(yyData, $3, $4, $5, 200*GROUNDPLANEFRAME,
- $5 + 200*MASKFRAME, hole, $6, OldFlags($7));
+ CreateNewVia(yyData, OU ($3), OU ($4), OU ($5), 2*GROUNDPLANEFRAME,
+ OU($5) + 2*MASKFRAME, hole, $6, OldFlags($7));
free ($6);
}
;
@@ -794,12 +816,12 @@ Numeric flags.
rats
: T_RAT '[' measure measure INTEGER measure measure INTEGER flags ']'
{
- CreateNewRat(yyData, $3, $4, $6, $7, $5, $8,
+ CreateNewRat(yyData, NU ($3), NU ($4), NU ($6), NU ($7), $5, $8,
Settings.RatThickness, $9);
}
- | T_RAT '(' oldmeasure oldmeasure INTEGER oldmeasure oldmeasure INTEGER INTEGER ')'
+ | T_RAT '(' measure measure INTEGER measure measure INTEGER INTEGER ')'
{
- CreateNewRat(yyData, $3, $4, $6, $7, $5, $8,
+ CreateNewRat(yyData, OU ($3), OU ($4), OU ($6), OU ($7), $5, $8,
Settings.RatThickness, OldFlags($9));
}
;
@@ -869,15 +891,15 @@ layerdefinition
| arc_1.7_format
| arc_oldformat
/* x1, y1, x2, y2, flags */
- | T_RECTANGLE '(' oldmeasure oldmeasure oldmeasure oldmeasure INTEGER ')'
+ | T_RECTANGLE '(' measure measure measure measure INTEGER ')'
{
CreateNewPolygonFromRectangle(Layer,
- $3, $4, ($3+$5), ($4+$6), OldFlags($7));
+ OU ($3), OU ($4), OU ($3) + OU ($5), OU ($4) + OU ($6), OldFlags($7));
}
| text_hi_format
| text_newformat
| text_oldformat
- | { attr_list = & Layer->Attributes; } attributes
+ | { attr_list = & Layer->Attributes; } attribute
| polygon_format
/* %start-doc pcbfile Line
@@ -910,27 +932,28 @@ line_hi_format
/* x1, y1, x2, y2, thickness, clearance, flags */
: T_LINE '[' measure measure measure measure measure measure flags ']'
{
- CreateNewLineOnLayer(Layer, $3, $4, $5, $6, $7, $8, $9);
+ CreateNewLineOnLayer(Layer, NU ($3), NU ($4), NU ($5), NU ($6),
+ NU ($7), NU ($8), $9);
}
;
line_1.7_format
/* x1, y1, x2, y2, thickness, clearance, flags */
- : T_LINE '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure INTEGER ')'
+ : T_LINE '(' measure measure measure measure measure measure INTEGER ')'
{
- CreateNewLineOnLayer(Layer, $3, $4, $5, $6,
- $7, $8, OldFlags($9));
+ CreateNewLineOnLayer(Layer, OU ($3), OU ($4), OU ($5), OU ($6),
+ OU ($7), OU ($8), OldFlags($9));
}
;
line_oldformat
/* x1, y1, x2, y2, thickness, flags */
- : T_LINE '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure INTEGER ')'
+ : T_LINE '(' measure measure measure measure measure measure ')'
{
/* eliminate old-style rat-lines */
- if (($8 & RATFLAG) == 0)
- CreateNewLineOnLayer(Layer, $3, $4, $5, $6, $7,
- 200*GROUNDPLANEFRAME, OldFlags($8));
+ if ((IV ($8) & RATFLAG) == 0)
+ CreateNewLineOnLayer(Layer, OU ($3), OU ($4), OU ($5), OU ($6), OU ($7),
+ 200*GROUNDPLANEFRAME, OldFlags(IV ($8)));
}
;
@@ -975,25 +998,26 @@ arc_hi_format
/* x, y, width, height, thickness, clearance, startangle, delta, flags */
: T_ARC '[' measure measure measure measure measure measure number number flags ']'
{
- CreateNewArcOnLayer(Layer, $3, $4, $5, $6, $9, $10, $7, $8, $11);
+ CreateNewArcOnLayer(Layer, NU ($3), NU ($4), NU ($5), NU ($6), $9, $10,
+ NU ($7), NU ($8), $11);
}
;
arc_1.7_format
/* x, y, width, height, thickness, clearance, startangle, delta, flags */
- : T_ARC '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure number number INTEGER ')'
+ : T_ARC '(' measure measure measure measure measure measure number number INTEGER ')'
{
- CreateNewArcOnLayer(Layer, $3, $4, $5, $6, $9, $10,
- $7, $8, OldFlags($11));
+ CreateNewArcOnLayer(Layer, OU ($3), OU ($4), OU ($5), OU ($6), $9, $10,
+ OU ($7), OU ($8), OldFlags($11));
}
;
arc_oldformat
/* x, y, width, height, thickness, startangle, delta, flags */
- : T_ARC '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure number number INTEGER ')'
+ : T_ARC '(' measure measure measure measure measure measure number INTEGER ')'
{
- CreateNewArcOnLayer(Layer, $3, $4, $5, $5, $8, $9,
- $7, 200*GROUNDPLANEFRAME, OldFlags($10));
+ CreateNewArcOnLayer(Layer, OU ($3), OU ($4), OU ($5), OU ($5), IV ($8), $9,
+ OU ($7), 200*GROUNDPLANEFRAME, OldFlags($10));
}
;
@@ -1027,27 +1051,29 @@ Numeric flags.
text_oldformat
/* x, y, direction, text, flags */
- : T_TEXT '(' oldmeasure oldmeasure number STRING INTEGER ')'
+ : T_TEXT '(' measure measure number STRING INTEGER ')'
{
/* use a default scale of 100% */
- CreateNewText(Layer,yyFont,$3, $4, $5, 100, $6, OldFlags($7));
+ CreateNewText(Layer,yyFont,OU ($3), OU ($4), $5, 100, $6, OldFlags($7));
free ($6);
}
;
text_newformat
/* x, y, direction, scale, text, flags */
- : T_TEXT '(' oldmeasure oldmeasure number number STRING INTEGER ')'
+ : T_TEXT '(' measure measure number number STRING INTEGER ')'
{
if ($8 & ONSILKFLAG)
{
LayerTypePtr lay = &yyData->Layer[yyData->LayerN +
(($8 & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)];
- CreateNewText(lay ,yyFont, $3, $4, $5, $6, $7, OldFlags($8));
+ CreateNewText(lay ,yyFont, OU ($3), OU ($4), $5, $6, $7,
+ OldFlags($8));
}
else
- CreateNewText(Layer, yyFont, $3, $4, $5, $6, $7, OldFlags($8));
+ CreateNewText(Layer, yyFont, OU ($3), OU ($4), $5, $6, $7,
+ OldFlags($8));
free ($7);
}
;
@@ -1067,10 +1093,10 @@ text_hi_format
LayerTypePtr lay = &yyData->Layer[yyData->LayerN +
(($8.f & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)];
- CreateNewText(lay, yyFont, $3, $4, $5, $6, $7, $8);
+ CreateNewText(lay, yyFont, NU ($3), NU ($4), $5, $6, $7, $8);
}
else
- CreateNewText(Layer, yyFont, $3, $4, $5, $6, $7, $8);
+ CreateNewText(Layer, yyFont, NU ($3), NU ($4), $5, $6, $7, $8);
free ($7);
}
;
@@ -1143,7 +1169,6 @@ polygon_format
polygonholes
: /* empty */
- | polygonhole
| polygonholes polygonhole
;
@@ -1156,21 +1181,20 @@ polygonhole
;
polygonpoints
- : polygonpoint
- | polygonpoints polygonpoint
+ : /* empty */
+ | polygonpoint polygonpoints
;
polygonpoint
/* xcoord ycoord */
- : '(' oldmeasure oldmeasure ')'
+ : '(' measure measure ')'
{
- CreateNewPointInPolygon(Polygon, $2, $3);
+ CreateNewPointInPolygon(Polygon, OU ($2), OU ($3));
}
| '[' measure measure ']'
{
- CreateNewPointInPolygon(Polygon, $2, $3);
+ CreateNewPointInPolygon(Polygon, NU ($2), NU ($3));
}
- |
;
/* %start-doc pcbfile Element
@@ -1238,10 +1262,10 @@ element_oldformat
/* element_flags, description, pcb-name,
* text_x, text_y, text_direction, text_scale, text_flags
*/
- : T_ELEMENT '(' STRING STRING oldmeasure oldmeasure INTEGER ')' '('
+ : T_ELEMENT '(' STRING STRING measure measure INTEGER ')' '('
{
yyElement = CreateNewElement(yyData, yyElement, yyFont, NoFlags(),
- $3, $4, NULL, $5, $6, $7, 100, NoFlags(), false);
+ $3, $4, NULL, OU ($5), OU ($6), $7, 100, NoFlags(), false);
free ($3);
free ($4);
pin_num = 1;
@@ -1256,10 +1280,10 @@ element_1.3.4_format
/* element_flags, description, pcb-name,
* text_x, text_y, text_direction, text_scale, text_flags
*/
- : T_ELEMENT '(' INTEGER STRING STRING oldmeasure oldmeasure number number INTEGER ')' '('
+ : T_ELEMENT '(' INTEGER STRING STRING measure measure measure measure INTEGER ')' '('
{
yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3),
- $4, $5, NULL, $6, $7, $8, $9, OldFlags($10), false);
+ $4, $5, NULL, OU ($6), OU ($7), IV ($8), IV ($9), OldFlags($10), false);
free ($4);
free ($5);
pin_num = 1;
@@ -1274,10 +1298,10 @@ element_newformat
/* element_flags, description, pcb-name, value,
* text_x, text_y, text_direction, text_scale, text_flags
*/
- : T_ELEMENT '(' INTEGER STRING STRING STRING oldmeasure oldmeasure number number INTEGER ')' '('
+ : T_ELEMENT '(' INTEGER STRING STRING STRING measure measure measure measure INTEGER ')' '('
{
yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3),
- $4, $5, $6, $7, $8, $9, $10, OldFlags($11), false);
+ $4, $5, $6, OU ($7), OU ($8), IV ($9), IV ($10), OldFlags($11), false);
free ($4);
free ($5);
free ($6);
@@ -1293,13 +1317,14 @@ element_1.7_format
/* element_flags, description, pcb-name, value, mark_x, mark_y,
* text_x, text_y, text_direction, text_scale, text_flags
*/
- : T_ELEMENT '(' INTEGER STRING STRING STRING oldmeasure oldmeasure
- oldmeasure oldmeasure number number INTEGER ')' '('
+ : T_ELEMENT '(' INTEGER STRING STRING STRING measure measure
+ measure measure number number INTEGER ')' '('
{
yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3),
- $4, $5, $6, ($7+$9), ($8+$10), $11, $12, OldFlags($13), false);
- yyElement->MarkX = $7;
- yyElement->MarkY = $8;
+ $4, $5, $6, OU ($7) + OU ($9), OU ($8) + OU ($10),
+ $11, $12, OldFlags($13), false);
+ yyElement->MarkX = OU ($7);
+ yyElement->MarkY = OU ($8);
free ($4);
free ($5);
free ($6);
@@ -1318,9 +1343,10 @@ element_hi_format
measure measure number number flags ']' '('
{
yyElement = CreateNewElement(yyData, yyElement, yyFont, $3,
- $4, $5, $6, ($7+$9), ($8+$10), $11, $12, $13, false);
- yyElement->MarkX = $7;
- yyElement->MarkY = $8;
+ $4, $5, $6, NU ($7) + NU ($9), NU ($8) + NU ($10),
+ $11, $12, $13, false);
+ yyElement->MarkX = NU ($7);
+ yyElement->MarkY = NU ($8);
free ($4);
free ($5);
free ($6);
@@ -1407,35 +1433,35 @@ elementdefinition
/* x1, y1, x2, y2, thickness */
| T_ELEMENTLINE '[' measure measure measure measure measure ']'
{
- CreateNewLineInElement(yyElement, $3, $4, $5, $6, $7);
+ CreateNewLineInElement(yyElement, NU ($3), NU ($4), NU ($5), NU ($6), NU ($7));
}
/* x1, y1, x2, y2, thickness */
- | T_ELEMENTLINE '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure ')'
+ | T_ELEMENTLINE '(' measure measure measure measure measure ')'
{
- CreateNewLineInElement(yyElement, $3, $4, $5, $6, $7);
+ CreateNewLineInElement(yyElement, OU ($3), OU ($4), OU ($5), OU ($6), OU ($7));
}
/* x, y, width, height, startangle, anglediff, thickness */
| T_ELEMENTARC '[' measure measure measure measure number number measure ']'
{
- CreateNewArcInElement(yyElement, $3, $4, $5, $6, $7, $8, $9);
+ CreateNewArcInElement(yyElement, NU ($3), NU ($4), NU ($5), NU ($6), $7, $8, NU ($9));
}
/* x, y, width, height, startangle, anglediff, thickness */
- | T_ELEMENTARC '(' oldmeasure oldmeasure oldmeasure oldmeasure number number oldmeasure ')'
+ | T_ELEMENTARC '(' measure measure measure measure number number measure ')'
{
- CreateNewArcInElement(yyElement, $3, $4, $5, $6, $7, $8, $9);
+ CreateNewArcInElement(yyElement, OU ($3), OU ($4), OU ($5), OU ($6), $7, $8, OU ($9));
}
/* x, y position */
| T_MARK '[' measure measure ']'
{
- yyElement->MarkX = $3;
- yyElement->MarkY = $4;
+ yyElement->MarkX = NU ($3);
+ yyElement->MarkY = NU ($4);
}
- | T_MARK '(' oldmeasure oldmeasure ')'
+ | T_MARK '(' measure measure ')'
{
- yyElement->MarkX = $3;
- yyElement->MarkY = $4;
+ yyElement->MarkX = OU ($3);
+ yyElement->MarkY = OU ($4);
}
- | { attr_list = & yyElement->Attributes; } attributes
+ | { attr_list = & yyElement->Attributes; } attribute
;
relementdefs
@@ -1451,28 +1477,28 @@ relementdef
/* x1, y1, x2, y2, thickness */
| T_ELEMENTLINE '[' measure measure measure measure measure ']'
{
- CreateNewLineInElement(yyElement, $3 + yyElement->MarkX,
- $4 + yyElement->MarkY, $5 + yyElement->MarkX,
- $6 + yyElement->MarkY, $7);
+ CreateNewLineInElement(yyElement, NU ($3) + yyElement->MarkX,
+ NU ($4) + yyElement->MarkY, NU ($5) + yyElement->MarkX,
+ NU ($6) + yyElement->MarkY, NU ($7));
}
- | T_ELEMENTLINE '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure ')'
+ | T_ELEMENTLINE '(' measure measure measure measure measure ')'
{
- CreateNewLineInElement(yyElement, $3 + yyElement->MarkX,
- $4 + yyElement->MarkY, $5 + yyElement->MarkX,
- $6 + yyElement->MarkY, $7);
+ CreateNewLineInElement(yyElement, OU ($3) + yyElement->MarkX,
+ OU ($4) + yyElement->MarkY, OU ($5) + yyElement->MarkX,
+ OU ($6) + yyElement->MarkY, OU ($7));
}
/* x, y, width, height, startangle, anglediff, thickness */
| T_ELEMENTARC '[' measure measure measure measure number number measure ']'
{
- CreateNewArcInElement(yyElement, $3 + yyElement->MarkX,
- $4 + yyElement->MarkY, $5, $6, $7, $8, $9);
+ CreateNewArcInElement(yyElement, NU ($3) + yyElement->MarkX,
+ NU ($4) + yyElement->MarkY, NU ($5), NU ($6), $7, $8, NU ($9));
}
- | T_ELEMENTARC '(' oldmeasure oldmeasure oldmeasure oldmeasure number number oldmeasure ')'
+ | T_ELEMENTARC '(' measure measure measure measure number number measure ')'
{
- CreateNewArcInElement(yyElement, $3 + yyElement->MarkX,
- $4 + yyElement->MarkY, $5, $6, $7, $8, $9);
+ CreateNewArcInElement(yyElement, OU ($3) + yyElement->MarkX,
+ OU ($4) + yyElement->MarkY, OU ($5), OU ($6), $7, $8, OU ($9));
}
- | { attr_list = & yyElement->Attributes; } attributes
+ | { attr_list = & yyElement->Attributes; } attribute
;
/* %start-doc pcbfile Pin
@@ -1515,8 +1541,8 @@ pin_hi_format
number, flags */
: T_PIN '[' measure measure measure measure measure measure STRING STRING flags ']'
{
- CreateNewPin(yyElement, $3 + yyElement->MarkX,
- $4 + yyElement->MarkY, $5, $6, $7, $8, $9,
+ CreateNewPin(yyElement, NU ($3) + yyElement->MarkX,
+ NU ($4) + yyElement->MarkY, NU ($5), NU ($6), NU ($7), NU ($8), $9,
$10, $11);
free ($9);
free ($10);
@@ -1525,10 +1551,10 @@ pin_hi_format
pin_1.7_format
/* x, y, thickness, clearance, mask, drilling hole, name,
number, flags */
- : T_PIN '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure STRING STRING INTEGER ')'
+ : T_PIN '(' measure measure measure measure measure measure STRING STRING INTEGER ')'
{
- CreateNewPin(yyElement, $3 + yyElement->MarkX,
- $4 + yyElement->MarkY, $5, $6, $7, $8, $9,
+ CreateNewPin(yyElement, OU ($3) + yyElement->MarkX,
+ OU ($4) + yyElement->MarkY, OU ($5), OU ($6), OU ($7), OU ($8), $9,
$10, OldFlags($11));
free ($9);
free ($10);
@@ -1537,10 +1563,10 @@ pin_1.7_format
pin_1.6.3_format
/* x, y, thickness, drilling hole, name, number, flags */
- : T_PIN '(' oldmeasure oldmeasure oldmeasure oldmeasure STRING STRING INTEGER ')'
+ : T_PIN '(' measure measure measure measure STRING STRING INTEGER ')'
{
- CreateNewPin(yyElement, $3, $4, $5, 200*GROUNDPLANEFRAME,
- $5 + 200*MASKFRAME, $6, $7, $8, OldFlags($9));
+ CreateNewPin(yyElement, OU ($3), OU ($4), OU ($5), 2*GROUNDPLANEFRAME,
+ OU ($5) + 2*MASKFRAME, OU ($6), $7, $8, OldFlags($9));
free ($7);
free ($8);
}
@@ -1548,13 +1574,13 @@ pin_1.6.3_format
pin_newformat
/* x, y, thickness, drilling hole, name, flags */
- : T_PIN '(' oldmeasure oldmeasure oldmeasure oldmeasure STRING INTEGER ')'
+ : T_PIN '(' measure measure measure measure STRING INTEGER ')'
{
char p_number[8];
sprintf(p_number, "%d", pin_num++);
- CreateNewPin(yyElement, $3, $4, $5, 200*GROUNDPLANEFRAME,
- $5 + 200*MASKFRAME, $6, $7, p_number, OldFlags($8));
+ CreateNewPin(yyElement, OU ($3), OU ($4), OU ($5), 2*GROUNDPLANEFRAME,
+ OU ($5) + 2*MASKFRAME, OU ($6), $7, p_number, OldFlags($8));
free ($7);
}
@@ -1564,19 +1590,19 @@ pin_oldformat
/* old format: x, y, thickness, name, flags
* drilling hole is 40% of the diameter
*/
- : T_PIN '(' oldmeasure oldmeasure oldmeasure STRING INTEGER ')'
+ : T_PIN '(' measure measure measure STRING INTEGER ')'
{
- BDimension hole = ($5 *DEFAULT_DRILLINGHOLE);
+ BDimension hole = OU ($5) * DEFAULT_DRILLINGHOLE;
char p_number[8];
/* make sure that there's enough copper left */
- if ($5 -hole < MIN_PINORVIACOPPER &&
- $5 > MIN_PINORVIACOPPER)
- hole = $5 -MIN_PINORVIACOPPER;
+ if (OU ($5) - hole < MIN_PINORVIACOPPER &&
+ OU ($5) > MIN_PINORVIACOPPER)
+ hole = OU ($5) - MIN_PINORVIACOPPER;
sprintf(p_number, "%d", pin_num++);
- CreateNewPin(yyElement, $3, $4, $5, 200*GROUNDPLANEFRAME,
- $5 + 200*MASKFRAME, hole, $6, p_number, OldFlags($7));
+ CreateNewPin(yyElement, OU ($3), OU ($4), OU ($5), 2*GROUNDPLANEFRAME,
+ OU ($5) + 2*MASKFRAME, hole, $6, p_number, OldFlags($7));
free ($6);
}
;
@@ -1620,10 +1646,10 @@ pad_hi_format
/* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */
: T_PAD '[' measure measure measure measure measure measure measure STRING STRING flags ']'
{
- CreateNewPad(yyElement, $3 + yyElement->MarkX,
- $4 + yyElement->MarkY,
- $5 + yyElement->MarkX,
- $6 + yyElement->MarkY, $7, $8, $9,
+ CreateNewPad(yyElement, NU ($3) + yyElement->MarkX,
+ NU ($4) + yyElement->MarkY,
+ NU ($5) + yyElement->MarkX,
+ NU ($6) + yyElement->MarkY, NU ($7), NU ($8), NU ($9),
$10, $11, $12);
free ($10);
free ($11);
@@ -1632,11 +1658,11 @@ pad_hi_format
pad_1.7_format
/* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */
- : T_PAD '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure STRING STRING INTEGER ')'
+ : T_PAD '(' measure measure measure measure measure measure measure STRING STRING INTEGER ')'
{
- CreateNewPad(yyElement,$3 + yyElement->MarkX,
- $4 + yyElement->MarkY, $5 + yyElement->MarkX,
- $6 + yyElement->MarkY, $7, $8, $9,
+ CreateNewPad(yyElement,OU ($3) + yyElement->MarkX,
+ OU ($4) + yyElement->MarkY, OU ($5) + yyElement->MarkX,
+ OU ($6) + yyElement->MarkY, OU ($7), OU ($8), OU ($9),
$10, $11, OldFlags($12));
free ($10);
free ($11);
@@ -1645,10 +1671,10 @@ pad_1.7_format
pad_newformat
/* x1, y1, x2, y2, thickness, name , pad number, flags */
- : T_PAD '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure STRING STRING INTEGER ')'
+ : T_PAD '(' measure measure measure measure measure STRING STRING INTEGER ')'
{
- CreateNewPad(yyElement,$3,$4,$5,$6,$7, 200*GROUNDPLANEFRAME,
- $7 + 200*MASKFRAME, $8,$9, OldFlags($10));
+ CreateNewPad(yyElement,OU ($3),OU ($4),OU ($5),OU ($6),OU ($7), 2*GROUNDPLANEFRAME,
+ OU ($7) + 2*MASKFRAME, $8, $9, OldFlags($10));
free ($8);
free ($9);
}
@@ -1656,13 +1682,13 @@ pad_newformat
pad
/* x1, y1, x2, y2, thickness, name and flags */
- : T_PAD '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure STRING INTEGER ')'
+ : T_PAD '(' measure measure measure measure measure STRING INTEGER ')'
{
char p_number[8];
sprintf(p_number, "%d", pin_num++);
- CreateNewPad(yyElement,$3,$4,$5,$6,$7, 200*GROUNDPLANEFRAME,
- $7 + 200*MASKFRAME, $8,p_number, OldFlags($9));
+ CreateNewPad(yyElement,OU ($3),OU ($4),OU ($5),OU ($6),OU ($7), 2*GROUNDPLANEFRAME,
+ OU ($7) + 2*MASKFRAME, $8,p_number, OldFlags($9));
free ($8);
}
;
@@ -1695,8 +1721,9 @@ Additional space to allow after this character.
%end-doc */
-symbol
- : T_SYMBOL '[' symbolid measure ']' '('
+symbol : symbolhead symboldata ')'
+
+symbolhead : T_SYMBOL '[' symbolid measure ']' '('
{
if ($3 <= 0 || $3 > MAX_FONTPOSITION)
{
@@ -1710,10 +1737,9 @@ symbol
YYABORT;
}
Symbol->Valid = true;
- Symbol->Delta = $4;
+ Symbol->Delta = NU ($4);
}
- symboldata ')'
- | T_SYMBOL '(' symbolid oldmeasure ')' '('
+ | T_SYMBOL '(' symbolid measure ')' '('
{
if ($3 <= 0 || $3 > MAX_FONTPOSITION)
{
@@ -1727,9 +1753,8 @@ symbol
YYABORT;
}
Symbol->Valid = true;
- Symbol->Delta = $4;
+ Symbol->Delta = OU ($4);
}
- symboldata ')'
;
symbolid
@@ -1738,14 +1763,9 @@ symbolid
;
symboldata
- : symboldefinitions
- | symboldata symboldefinitions
- ;
-
-symboldefinitions
- : symboldefinition
- | hiressymbol
- |
+ : /* empty */
+ | symboldata symboldefinition
+ | symboldata hiressymbol
;
/* %start-doc pcbfile SymbolLine
@@ -1766,16 +1786,16 @@ The width of this line.
symboldefinition
/* x1, y1, x2, y2, thickness */
- : T_SYMBOLLINE '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure ')'
+ : T_SYMBOLLINE '(' measure measure measure measure measure ')'
{
- CreateNewLineInSymbol(Symbol, $3, $4, $5, $6, $7);
+ CreateNewLineInSymbol(Symbol, OU ($3), OU ($4), OU ($5), OU ($6), OU ($7));
}
;
hiressymbol
/* x1, y1, x2, y2, thickness */
: T_SYMBOLLINE '[' measure measure measure measure measure ']'
{
- CreateNewLineInSymbol(Symbol, $3, $4, $5, $6, $7);
+ CreateNewLineInSymbol(Symbol, NU ($3), NU ($4), NU ($5), NU ($6), NU ($7));
}
;
@@ -1891,9 +1911,6 @@ if the value is interpreted as, for example, a number.
%end-doc */
-attributes : attribute
- | attributes attribute
- ;
attribute
: T_ATTRIBUTE '(' STRING STRING ')'
{
@@ -1914,21 +1931,17 @@ number
measure
/* Default unit (no suffix) is cmil */
- : number { $$ = round (MIL_TO_COORD ($1) / 100.0); }
- | number T_UMIL { $$ = round (MIL_TO_COORD ($1) / 100000.0); }
- | number T_CMIL { $$ = round (MIL_TO_COORD ($1) / 100.0); }
- | number T_MIL { $$ = round (MIL_TO_COORD ($1)); }
- | number T_IN { $$ = round (INCH_TO_COORD ($1)); }
- | number T_NM { $$ = round (MM_TO_COORD ($1) / 1000000.0); }
- | number T_UM { $$ = round (MM_TO_COORD ($1) / 1000.0); }
- | number T_MM { $$ = round (MM_TO_COORD ($1)); }
- | number T_M { $$ = round (MM_TO_COORD ($1) * 1000.0); }
- | number T_KM { $$ = round (MM_TO_COORD ($1) * 1000000.0); }
- ;
-
-oldmeasure
- /* ``Obsolete'' default unit is mil */
- : number { $$ = round (MIL_TO_COORD ($1)); }
+ : number { do_measure(&$$, $1, MIL_TO_COORD ($1) / 100.0, 0); }
+ | number T_UMIL { M ($$, $1, MIL_TO_COORD ($1) / 100000.0); }
+ | number T_CMIL { M ($$, $1, MIL_TO_COORD ($1) / 100.0); }
+ | number T_MIL { M ($$, $1, MIL_TO_COORD ($1)); }
+ | number T_IN { M ($$, $1, INCH_TO_COORD ($1)); }
+ | number T_NM { M ($$, $1, MM_TO_COORD ($1) / 1000000.0); }
+ | number T_UM { M ($$, $1, MM_TO_COORD ($1) / 1000.0); }
+ | number T_MM { M ($$, $1, MM_TO_COORD ($1)); }
+ | number T_M { M ($$, $1, MM_TO_COORD ($1) * 1000.0); }
+ | number T_KM { M ($$, $1, MM_TO_COORD ($1) * 1000000.0); }
+ ;
%%
@@ -1949,7 +1962,6 @@ int yywrap()
return 1;
}
-
static int
check_file_version (int ver)
{
@@ -1966,3 +1978,35 @@ check_file_version (int ver)
return 0;
}
+static void
+do_measure (PLMeasure *m, BDimension i, double d, int u)
+{
+ m->ival = i;
+ m->bval = round (d);
+ m->dval = d;
+ m->has_units = u;
+}
+
+static int
+integer_value (PLMeasure m)
+{
+ if (m.has_units)
+ yyerror("units ignored here");
+ return m.ival;
+}
+
+static BDimension
+old_units (PLMeasure m)
+{
+ if (m.has_units)
+ return m.bval;
+ return round (MIL_TO_COORD (m.ival));
+}
+
+static BDimension
+new_units (PLMeasure m)
+{
+ if (m.has_units)
+ return m.bval;
+ return round (MIL_TO_COORD (m.ival) / 100.0);
+}
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs