[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: pcb.git: branch: master updated (750a1c57d85dbb82d704f9443055a783b5dca8eb)
The branch, master has been updated
via 750a1c57d85dbb82d704f9443055a783b5dca8eb (commit)
from 074f68e08ef5a70b6c99d5a08080727326197bc0 (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
=========
src/file.h | 2 +-
src/parse_l.l | 58 +++++------
src/parse_y.y | 318 +++++++++++++++++++++++++++++----------------------------
3 files changed, 188 insertions(+), 190 deletions(-)
=================
Commit Messages
=================
commit 750a1c57d85dbb82d704f9443055a783b5dca8eb
Author: Andrew Poelstra <asp11@xxxxxx>
Commit: Andrew Poelstra <asp11@xxxxxx>
Add support for reading unit suffixes in parser
Bumped PCB_FILE_VERSION up to 20110703.
Removed old unit-reading code from parse_l.l since
it was missing several units that we plan to support,
and the scaling was backward for non-base units.
Also, we now read all numbers as doubles, except those
that need integers (array indices and flags, mainly).
All measurements are round()ed to ints, after scaling,
since that's what BDimension is and we don't want
anomalies.
The old NUMBER and FLOAT terminals in parse_y have been
replaced by:
1. INTEGER - an integer, unscaled
2. number - floating or integer, unscaled
3. measure - a (possibly suffixed) measurement, with
non-suffixed measurements read in cmils
4. oldmeasue - non-suffixed measurement, read in mils
One exception is the PolyArea[] field. This is still
read in cmil^2 until we figure out what to do with it.
This way the parser works independently of PCB's internal
base units, and supports umil, cmil, mil, in, nm, um, mm,
m and km unit suffixes. The parsing code should also be
clearer now since not everything is NUMBER, with scale
factors handled after-the-fact with /100's or in the lexer.
Additionally, we now allow floating-point values for all
measurements (even old-style mil fields), and pcb will
allow spaces between measurements and their suffixes.
Actually using these ``features'' will probably break
tools that read .pcb files, though.
:100644 100644 d36fdfa... a2f7859... M src/file.h
:100644 100644 0898abf... 9ebb8e2... M src/parse_l.l
:100644 100644 5290b53... 05f0a49... M src/parse_y.y
=========
Changes
=========
commit 750a1c57d85dbb82d704f9443055a783b5dca8eb
Author: Andrew Poelstra <asp11@xxxxxx>
Commit: Andrew Poelstra <asp11@xxxxxx>
Add support for reading unit suffixes in parser
Bumped PCB_FILE_VERSION up to 20110703.
Removed old unit-reading code from parse_l.l since
it was missing several units that we plan to support,
and the scaling was backward for non-base units.
Also, we now read all numbers as doubles, except those
that need integers (array indices and flags, mainly).
All measurements are round()ed to ints, after scaling,
since that's what BDimension is and we don't want
anomalies.
The old NUMBER and FLOAT terminals in parse_y have been
replaced by:
1. INTEGER - an integer, unscaled
2. number - floating or integer, unscaled
3. measure - a (possibly suffixed) measurement, with
non-suffixed measurements read in cmils
4. oldmeasue - non-suffixed measurement, read in mils
One exception is the PolyArea[] field. This is still
read in cmil^2 until we figure out what to do with it.
This way the parser works independently of PCB's internal
base units, and supports umil, cmil, mil, in, nm, um, mm,
m and km unit suffixes. The parsing code should also be
clearer now since not everything is NUMBER, with scale
factors handled after-the-fact with /100's or in the lexer.
Additionally, we now allow floating-point values for all
measurements (even old-style mil fields), and pcb will
allow spaces between measurements and their suffixes.
Actually using these ``features'' will probably break
tools that read .pcb files, though.
diff --git a/src/file.h b/src/file.h
index d36fdfa..a2f7859 100644
--- a/src/file.h
+++ b/src/file.h
@@ -61,7 +61,7 @@ void sort_netlist (void);
int PCBFileVersionNeeded (void);
/* This is the version we support. */
-#define PCB_FILE_VERSION 20100606
+#define PCB_FILE_VERSION 20110603
#ifndef HAS_ATEXIT
diff --git a/src/parse_l.l b/src/parse_l.l
index 0898abf..9ebb8e2 100644
--- a/src/parse_l.l
+++ b/src/parse_l.l
@@ -79,7 +79,7 @@ DataTypePtr yyData;
ElementTypePtr yyElement;
FontTypePtr yyFont;
-static int parse_number (double);
+static int parse_number (void);
/* ---------------------------------------------------------------------------
* an external prototypes
@@ -94,13 +94,8 @@ static int Parse(char *, char *, char *, char *);
%}
HEX 0x[0-9a-fA-F]+
-DECIMAL -?[1-9][0-9]*|0
-FLOATING [+-]?[0-9]*("."[0-9]*)?
-FLOATINGMM {FLOATING}mm
-FLOATINGUM {FLOATING}um
-FLOATINGIN {FLOATING}in
-FLOATINGMIL {FLOATING}mil
-CARDINAL [1-9][0-9]*|0
+INTEGER [+-]?([1-9][0-9]*|0)
+FLOATING {INTEGER}"."[0-9]*
STRINGCHAR ([^"\n\r\\]|\\.)
%option yylineno
@@ -139,23 +134,27 @@ Net { return(T_NET); }
Connect { return(T_CONN); }
Attribute { return(T_ATTRIBUTE); }
+nm { return T_NM; }
+um { return T_UM; }
+mm { return T_MM; }
+m { return T_M; }
+km { return T_KM; }
+umil { return T_UMIL; }
+cmil { return T_CMIL; }
+mil { return T_MIL; }
+in { return T_IN; }
+
\'.\' {
- yylval.number = (unsigned) *(yytext+1);
+ yylval.integer = (unsigned) *(yytext+1);
return(CHAR_CONST);
}
-{FLOATINGMM} { return parse_number(MM_TO_COORD(1)); }
-{FLOATINGUM} { return parse_number(MM_TO_COORD(1) * 1000); }
-{FLOATINGIN} { return parse_number(INCH_TO_COORD(1)); }
-{FLOATINGMIL} { return parse_number(MIL_TO_COORD(1)); }
-{DECIMAL} { return parse_number(1.0); }
-
-{HEX} {
- sscanf((char *) yytext, "%x", &yylval.number);
- return(NUMBER);
- }
-{FLOATING} {
- yylval.floating = c_strtod (yytext);
- return(FLOAT);
+{FLOATING} { return parse_number(); }
+{INTEGER} { yylval.integer = round (g_ascii_strtod (yytext, NULL)); return INTEGER; }
+
+{HEX} { unsigned n;
+ sscanf((char *) yytext, "%x", &n);
+ yylval.integer = n;
+ return INTEGER;
}
\"{STRINGCHAR}*\" {
char *p1, *p2;
@@ -368,16 +367,9 @@ int ParseFont(FontTypePtr Ptr, char *Filename)
}
static int
-parse_number (double scale)
+parse_number ()
{
- double val;
- sscanf ((char *) yytext, "%lf", &val);
- val *= scale;
- /* Round towards nearest means we have to check the sign first. */
- if (val < 0)
- val -= 0.49;
- else
- val += 0.49;
- yylval.number = (int)(val);
- return NUMBER;
+ yylval.number = g_ascii_strtod ((gchar *) yytext, NULL);
+ return FLOATING;
}
+
diff --git a/src/parse_y.y b/src/parse_y.y
index 5290b53..05f0a49 100644
--- a/src/parse_y.y
+++ b/src/parse_y.y
@@ -90,23 +90,27 @@ static int check_file_version (int);
%union /* define YYSTACK type */
{
- int number;
- float floating;
+ int integer;
+ double number;
char *string;
FlagType flagtype;
}
-%token <number> NUMBER CHAR_CONST /* line thickness, coordinates ... */
-%token <floating> FLOAT
-%token <string> STRING /* element names ... */
+%token <number> FLOATING /* line thickness, coordinates ... */
+%token <integer> INTEGER CHAR_CONST /* flags ... */
+%token <string> STRING /* element names ... */
%token T_FILEVERSION T_PCB T_LAYER T_VIA T_RAT T_LINE T_ARC T_RECTANGLE T_TEXT T_ELEMENTLINE
%token T_ELEMENT T_PIN T_PAD T_GRID T_FLAGS T_SYMBOL T_SYMBOLLINE T_CURSOR
%token T_ELEMENTARC T_MARK T_GROUPS T_STYLES T_POLYGON T_POLYGON_HOLE T_NETLIST T_NET T_CONN
%token T_AREA T_THERMAL T_DRC T_ATTRIBUTE
-%type <number> symbolid
+%token T_UMIL T_CMIL T_MIL T_IN T_NM T_UM T_MM T_M T_KM
+%type <integer> symbolid
%type <string> opt_string
%type <flagtype> flags
+%type <number> number
+%type <number> measure
+%type <number> oldmeasure
%%
@@ -270,7 +274,7 @@ in the input file then file format compatibility is not checked.
pcbfileversion
: |
-T_FILEVERSION '[' NUMBER ']'
+T_FILEVERSION '[' INTEGER ']'
{
if (check_file_version ($3) != 0)
{
@@ -306,13 +310,13 @@ pcbname
yyPCB->MaxWidth = MAX_COORD;
yyPCB->MaxHeight = MAX_COORD;
}
- | T_PCB '(' STRING NUMBER NUMBER ')'
+ | T_PCB '(' STRING oldmeasure oldmeasure ')'
{
yyPCB->Name = $3;
- yyPCB->MaxWidth = $4*100;
- yyPCB->MaxHeight = $5*100;
+ yyPCB->MaxWidth = $4;
+ yyPCB->MaxHeight = $5;
}
- | T_PCB '[' STRING NUMBER NUMBER ']'
+ | T_PCB '[' STRING measure measure ']'
{
yyPCB->Name = $3;
yyPCB->MaxWidth = $4;
@@ -343,23 +347,22 @@ If non-zero, the grid will be visible on the screen.
pcbgrid
: pcbgridold
| pcbgridnew
- | pcb2grid
| pcbhigrid
;
pcbgridold
- : T_GRID '(' NUMBER NUMBER NUMBER ')'
+ : T_GRID '(' oldmeasure oldmeasure oldmeasure ')'
{
- yyPCB->Grid = $3*100;
- yyPCB->GridOffsetX = $4*100;
- yyPCB->GridOffsetY = $5*100;
+ yyPCB->Grid = $3;
+ yyPCB->GridOffsetX = $4;
+ yyPCB->GridOffsetY = $5;
}
;
pcbgridnew
- : T_GRID '(' NUMBER NUMBER NUMBER NUMBER ')'
+ : T_GRID '(' oldmeasure oldmeasure oldmeasure INTEGER ')'
{
- yyPCB->Grid = $3*100;
- yyPCB->GridOffsetX = $4*100;
- yyPCB->GridOffsetY = $5*100;
+ yyPCB->Grid = $3;
+ yyPCB->GridOffsetX = $4;
+ yyPCB->GridOffsetY = $5;
if ($6)
Settings.DrawGrid = true;
else
@@ -367,20 +370,8 @@ pcbgridnew
}
;
-pcb2grid
- : T_GRID '(' FLOAT NUMBER NUMBER NUMBER ')'
- {
- yyPCB->Grid = $3*100;
- yyPCB->GridOffsetX = $4*100;
- yyPCB->GridOffsetY = $5*100;
- if ($6)
- Settings.DrawGrid = true;
- else
- Settings.DrawGrid = false;
- }
- ;
pcbhigrid
- : T_GRID '[' FLOAT NUMBER NUMBER NUMBER ']'
+ : T_GRID '[' measure measure measure INTEGER ']'
{
yyPCB->Grid = $3;
yyPCB->GridOffsetX = $4;
@@ -412,19 +403,13 @@ first variant accepts floating point numbers. The special value
%end-doc */
pcbcursor
- : T_CURSOR '(' NUMBER NUMBER NUMBER ')'
- {
- yyPCB->CursorX = $3*100;
- yyPCB->CursorY = $4*100;
- yyPCB->Zoom = $5*2;
- }
- | T_CURSOR '[' NUMBER NUMBER NUMBER ']'
+ : T_CURSOR '(' oldmeasure oldmeasure number ')'
{
yyPCB->CursorX = $3;
yyPCB->CursorY = $4;
- yyPCB->Zoom = $5;
+ yyPCB->Zoom = $5*2;
}
- | T_CURSOR '[' NUMBER NUMBER FLOAT ']'
+ | T_CURSOR '[' measure measure number ']'
{
yyPCB->CursorX = $3;
yyPCB->CursorY = $4;
@@ -448,9 +433,10 @@ Minimum area of polygon island to retain. If a polygon has clearances that cause
polyarea
:
- | T_AREA '[' FLOAT ']'
+ | T_AREA '[' number ']'
{
- yyPCB->IsleArea = $3;
+ /* Read in cmil^2 for now; in future this should be a noop. */
+ yyPCB->IsleArea = MIL_TO_COORD (MIL_TO_COORD ($3) / 100.0) / 100.0;
}
;
@@ -474,7 +460,7 @@ the same as the clearance gap width.
pcbthermal
:
- | T_THERMAL '[' FLOAT ']'
+ | T_THERMAL '[' number ']'
{
yyPCB->ThermScale = $3;
}
@@ -513,7 +499,7 @@ pcbdrc
;
pcbdrc1
- : T_DRC '[' NUMBER NUMBER NUMBER ']'
+ : T_DRC '[' measure measure measure ']'
{
yyPCB->Bloat = $3;
yyPCB->Shrink = $4;
@@ -523,7 +509,7 @@ pcbdrc1
;
pcbdrc2
- : T_DRC '[' NUMBER NUMBER NUMBER NUMBER ']'
+ : T_DRC '[' measure measure measure measure ']'
{
yyPCB->Bloat = $3;
yyPCB->Shrink = $4;
@@ -534,7 +520,7 @@ pcbdrc2
;
pcbdrc3
- : T_DRC '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ']'
+ : T_DRC '[' measure measure measure measure measure measure ']'
{
yyPCB->Bloat = $3;
yyPCB->Shrink = $4;
@@ -561,7 +547,7 @@ represent pcb-wide flags as defined in @ref{PCBFlags}.
%end-doc */
pcbflags
- : T_FLAGS '(' NUMBER ')'
+ : T_FLAGS '(' INTEGER ')'
{
yyPCB->Flags = MakeFlags ($3 & PCB_FLAGS);
}
@@ -731,7 +717,7 @@ numerical flags only
via_hi_format
/* x, y, thickness, clearance, mask, drilling-hole, name, flags */
- : T_VIA '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING flags ']'
+ : T_VIA '[' measure measure measure measure measure measure STRING flags ']'
{
CreateNewVia(yyData, $3, $4, $5, $6, $7, $8, $9, $10);
free ($9);
@@ -740,10 +726,9 @@ via_hi_format
via_2.0_format
/* x, y, thickness, clearance, mask, drilling-hole, name, flags */
- : T_VIA '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
+ : T_VIA '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure STRING INTEGER ')'
{
- CreateNewVia(yyData, $3*100, $4*100, $5*100, $6*100, $7*100, $8*100, $9,
- OldFlags($10));
+ CreateNewVia(yyData, $3, $4, $5, $6, $7, $8, $9, OldFlags($10));
free ($9);
}
;
@@ -751,27 +736,27 @@ via_2.0_format
via_1.7_format
/* x, y, thickness, clearance, drilling-hole, name, flags */
- : T_VIA '(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
+ : T_VIA '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure STRING INTEGER ')'
{
- CreateNewVia(yyData, $3*100, $4*100, $5*100, $6*100,
- ($5 + $6)*100, $7*100, $8, OldFlags($9));
+ CreateNewVia(yyData, $3, $4, $5, $6,
+ ($5 + $6), $7, $8, OldFlags($9));
free ($8);
}
;
via_newformat
/* x, y, thickness, drilling-hole, name, flags */
- : T_VIA '(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
+ : T_VIA '(' oldmeasure oldmeasure oldmeasure oldmeasure STRING INTEGER ')'
{
- CreateNewVia(yyData, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
- ($5 + 2*MASKFRAME)*100, $6*100, $7, OldFlags($8));
+ CreateNewVia(yyData, $3, $4, $5, 200*GROUNDPLANEFRAME,
+ $5 + 200*MASKFRAME, $6, $7, OldFlags($8));
free ($7);
}
;
via_oldformat
/* old format: x, y, thickness, name, flags */
- : T_VIA '(' NUMBER NUMBER NUMBER STRING NUMBER ')'
+ : T_VIA '(' oldmeasure oldmeasure oldmeasure STRING INTEGER ')'
{
BDimension hole = ($5 *DEFAULT_DRILLINGHOLE);
@@ -780,8 +765,8 @@ via_oldformat
$5 > MIN_PINORVIACOPPER)
hole = $5 -MIN_PINORVIACOPPER;
- CreateNewVia(yyData, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
- ($5 + 2*MASKFRAME)*100, hole, $6, OldFlags($7));
+ CreateNewVia(yyData, $3, $4, $5, 200*GROUNDPLANEFRAME,
+ $5 + 200*MASKFRAME, hole, $6, OldFlags($7));
free ($6);
}
;
@@ -807,14 +792,14 @@ Numeric flags.
%end-doc */
rats
- : T_RAT '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags ']'
+ : T_RAT '[' measure measure INTEGER measure measure INTEGER flags ']'
{
CreateNewRat(yyData, $3, $4, $6, $7, $5, $8,
Settings.RatThickness, $9);
}
- | T_RAT '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
+ | T_RAT '(' oldmeasure oldmeasure INTEGER oldmeasure oldmeasure INTEGER INTEGER ')'
{
- CreateNewRat(yyData, $3*100, $4*100, $6*100, $7*100, $5, $8,
+ CreateNewRat(yyData, $3, $4, $6, $7, $5, $8,
Settings.RatThickness, OldFlags($9));
}
;
@@ -843,7 +828,7 @@ text, and polygons.
layer
/* name */
- : T_LAYER '(' NUMBER STRING opt_string ')' '('
+ : T_LAYER '(' INTEGER STRING opt_string ')' '('
{
if ($3 <= 0 || $3 > MAX_LAYER + 2)
{
@@ -884,10 +869,10 @@ layerdefinition
| arc_1.7_format
| arc_oldformat
/* x1, y1, x2, y2, flags */
- | T_RECTANGLE '(' NUMBER NUMBER NUMBER NUMBER NUMBER ')'
+ | T_RECTANGLE '(' oldmeasure oldmeasure oldmeasure oldmeasure INTEGER ')'
{
CreateNewPolygonFromRectangle(Layer,
- $3*100, $4*100, ($3+$5)*100, ($4+$6)*100, OldFlags($7));
+ $3, $4, ($3+$5), ($4+$6), OldFlags($7));
}
| text_hi_format
| text_newformat
@@ -923,7 +908,7 @@ Numeric flags.
line_hi_format
/* x1, y1, x2, y2, thickness, clearance, flags */
- : T_LINE '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags ']'
+ : T_LINE '[' measure measure measure measure measure measure flags ']'
{
CreateNewLineOnLayer(Layer, $3, $4, $5, $6, $7, $8, $9);
}
@@ -931,20 +916,20 @@ line_hi_format
line_1.7_format
/* x1, y1, x2, y2, thickness, clearance, flags */
- : T_LINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
+ : T_LINE '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure INTEGER ')'
{
- CreateNewLineOnLayer(Layer, $3*100, $4*100, $5*100, $6*100,
- $7*100, $8*100, OldFlags($9));
+ CreateNewLineOnLayer(Layer, $3, $4, $5, $6,
+ $7, $8, OldFlags($9));
}
;
line_oldformat
/* x1, y1, x2, y2, thickness, flags */
- : T_LINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
+ : T_LINE '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure INTEGER ')'
{
/* eliminate old-style rat-lines */
if (($8 & RATFLAG) == 0)
- CreateNewLineOnLayer(Layer, $3*100, $4*100, $5*100, $6*100, $7*100,
+ CreateNewLineOnLayer(Layer, $3, $4, $5, $6, $7,
200*GROUNDPLANEFRAME, OldFlags($8));
}
;
@@ -988,7 +973,7 @@ Numeric flags.
arc_hi_format
/* x, y, width, height, thickness, clearance, startangle, delta, flags */
- : T_ARC '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags ']'
+ : T_ARC '[' measure measure measure measure measure measure number number flags ']'
{
CreateNewArcOnLayer(Layer, $3, $4, $5, $6, $9, $10, $7, $8, $11);
}
@@ -996,19 +981,19 @@ arc_hi_format
arc_1.7_format
/* x, y, width, height, thickness, clearance, startangle, delta, flags */
- : T_ARC '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
+ : T_ARC '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure number number INTEGER ')'
{
- CreateNewArcOnLayer(Layer, $3*100, $4*100, $5*100, $6*100, $9, $10,
- $7*100, $8*100, OldFlags($11));
+ CreateNewArcOnLayer(Layer, $3, $4, $5, $6, $9, $10,
+ $7, $8, OldFlags($11));
}
;
arc_oldformat
/* x, y, width, height, thickness, startangle, delta, flags */
- : T_ARC '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
+ : T_ARC '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure number number INTEGER ')'
{
- CreateNewArcOnLayer(Layer, $3*100, $4*100, $5*100, $5*100, $8, $9,
- $7*100, 200*GROUNDPLANEFRAME, OldFlags($10));
+ CreateNewArcOnLayer(Layer, $3, $4, $5, $5, $8, $9,
+ $7, 200*GROUNDPLANEFRAME, OldFlags($10));
}
;
@@ -1042,35 +1027,33 @@ Numeric flags.
text_oldformat
/* x, y, direction, text, flags */
- : T_TEXT '(' NUMBER NUMBER NUMBER STRING NUMBER ')'
+ : T_TEXT '(' oldmeasure oldmeasure number STRING INTEGER ')'
{
/* use a default scale of 100% */
- CreateNewText(Layer,yyFont,$3*100, $4*100, $5, 100, $6, OldFlags($7));
+ CreateNewText(Layer,yyFont,$3, $4, $5, 100, $6, OldFlags($7));
free ($6);
}
;
text_newformat
/* x, y, direction, scale, text, flags */
- : T_TEXT '(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
+ : T_TEXT '(' oldmeasure oldmeasure number number STRING INTEGER ')'
{
if ($8 & ONSILKFLAG)
{
LayerTypePtr lay = &yyData->Layer[yyData->LayerN +
(($8 & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)];
- CreateNewText(lay ,yyFont, $3*100, $4*100, $5, $6, $7,
- OldFlags($8));
+ CreateNewText(lay ,yyFont, $3, $4, $5, $6, $7, OldFlags($8));
}
else
- CreateNewText(Layer, yyFont, $3*100, $4*100, $5, $6, $7,
- OldFlags($8));
+ CreateNewText(Layer, yyFont, $3, $4, $5, $6, $7, OldFlags($8));
free ($7);
}
;
text_hi_format
/* x, y, direction, scale, text, flags */
- : T_TEXT '[' NUMBER NUMBER NUMBER NUMBER STRING flags ']'
+ : T_TEXT '[' measure measure number number STRING flags ']'
{
/* FIXME: shouldn't know about .f */
/* I don't think this matters because anything with hi_format
@@ -1179,11 +1162,11 @@ polygonpoints
polygonpoint
/* xcoord ycoord */
- : '(' NUMBER NUMBER ')'
+ : '(' oldmeasure oldmeasure ')'
{
- CreateNewPointInPolygon(Polygon, $2*100, $3*100);
+ CreateNewPointInPolygon(Polygon, $2, $3);
}
- | '[' NUMBER NUMBER ']'
+ | '[' measure measure ']'
{
CreateNewPointInPolygon(Polygon, $2, $3);
}
@@ -1255,10 +1238,10 @@ element_oldformat
/* element_flags, description, pcb-name,
* text_x, text_y, text_direction, text_scale, text_flags
*/
- : T_ELEMENT '(' STRING STRING NUMBER NUMBER NUMBER ')' '('
+ : T_ELEMENT '(' STRING STRING oldmeasure oldmeasure INTEGER ')' '('
{
yyElement = CreateNewElement(yyData, yyElement, yyFont, NoFlags(),
- $3, $4, NULL, $5*100, $6*100, $7, 100, NoFlags(), false);
+ $3, $4, NULL, $5, $6, $7, 100, NoFlags(), false);
free ($3);
free ($4);
pin_num = 1;
@@ -1273,10 +1256,10 @@ element_1.3.4_format
/* element_flags, description, pcb-name,
* text_x, text_y, text_direction, text_scale, text_flags
*/
- : T_ELEMENT '(' NUMBER STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER ')' '('
+ : T_ELEMENT '(' INTEGER STRING STRING oldmeasure oldmeasure number number INTEGER ')' '('
{
yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3),
- $4, $5, NULL, $6*100, $7*100, $8, $9, OldFlags($10), false);
+ $4, $5, NULL, $6, $7, $8, $9, OldFlags($10), false);
free ($4);
free ($5);
pin_num = 1;
@@ -1291,10 +1274,10 @@ element_newformat
/* element_flags, description, pcb-name, value,
* text_x, text_y, text_direction, text_scale, text_flags
*/
- : T_ELEMENT '(' NUMBER STRING STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER ')' '('
+ : T_ELEMENT '(' INTEGER STRING STRING STRING oldmeasure oldmeasure number number INTEGER ')' '('
{
yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3),
- $4, $5, $6, $7*100, $8*100, $9, $10, OldFlags($11), false);
+ $4, $5, $6, $7, $8, $9, $10, OldFlags($11), false);
free ($4);
free ($5);
free ($6);
@@ -1310,13 +1293,13 @@ 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 '(' NUMBER STRING STRING STRING NUMBER NUMBER
- NUMBER NUMBER NUMBER NUMBER NUMBER ')' '('
+ : T_ELEMENT '(' INTEGER STRING STRING STRING oldmeasure oldmeasure
+ oldmeasure oldmeasure number number INTEGER ')' '('
{
yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3),
- $4, $5, $6, ($7+$9)*100, ($8+$10)*100, $11, $12, OldFlags($13), false);
- yyElement->MarkX = $7*100;
- yyElement->MarkY = $8*100;
+ $4, $5, $6, ($7+$9), ($8+$10), $11, $12, OldFlags($13), false);
+ yyElement->MarkX = $7;
+ yyElement->MarkY = $8;
free ($4);
free ($5);
free ($6);
@@ -1331,8 +1314,8 @@ element_hi_format
/* element_flags, description, pcb-name, value, mark_x, mark_y,
* text_x, text_y, text_direction, text_scale, text_flags
*/
- : T_ELEMENT '[' flags STRING STRING STRING NUMBER NUMBER
- NUMBER NUMBER NUMBER NUMBER flags ']' '('
+ : T_ELEMENT '[' flags STRING STRING STRING measure measure
+ measure measure number number flags ']' '('
{
yyElement = CreateNewElement(yyData, yyElement, yyFont, $3,
$4, $5, $6, ($7+$9), ($8+$10), $11, $12, $13, false);
@@ -1422,35 +1405,35 @@ elementdefinition
| pad_newformat
| pad
/* x1, y1, x2, y2, thickness */
- | T_ELEMENTLINE '[' NUMBER NUMBER NUMBER NUMBER NUMBER ']'
+ | T_ELEMENTLINE '[' measure measure measure measure measure ']'
{
CreateNewLineInElement(yyElement, $3, $4, $5, $6, $7);
}
/* x1, y1, x2, y2, thickness */
- | T_ELEMENTLINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER ')'
+ | T_ELEMENTLINE '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure ')'
{
- CreateNewLineInElement(yyElement, $3*100, $4*100, $5*100, $6*100, $7*100);
+ CreateNewLineInElement(yyElement, $3, $4, $5, $6, $7);
}
/* x, y, width, height, startangle, anglediff, thickness */
- | T_ELEMENTARC '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ']'
+ | T_ELEMENTARC '[' measure measure measure measure number number measure ']'
{
CreateNewArcInElement(yyElement, $3, $4, $5, $6, $7, $8, $9);
}
/* x, y, width, height, startangle, anglediff, thickness */
- | T_ELEMENTARC '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
+ | T_ELEMENTARC '(' oldmeasure oldmeasure oldmeasure oldmeasure number number oldmeasure ')'
{
- CreateNewArcInElement(yyElement, $3*100, $4*100, $5*100, $6*100, $7, $8, $9*100);
+ CreateNewArcInElement(yyElement, $3, $4, $5, $6, $7, $8, $9);
}
/* x, y position */
- | T_MARK '[' NUMBER NUMBER ']'
+ | T_MARK '[' measure measure ']'
{
yyElement->MarkX = $3;
yyElement->MarkY = $4;
}
- | T_MARK '(' NUMBER NUMBER ')'
+ | T_MARK '(' oldmeasure oldmeasure ')'
{
- yyElement->MarkX = $3*100;
- yyElement->MarkY = $4*100;
+ yyElement->MarkX = $3;
+ yyElement->MarkY = $4;
}
| { attr_list = & yyElement->Attributes; } attributes
;
@@ -1466,28 +1449,28 @@ relementdef
| pad_1.7_format
| pad_hi_format
/* x1, y1, x2, y2, thickness */
- | T_ELEMENTLINE '[' NUMBER NUMBER NUMBER NUMBER NUMBER ']'
+ | T_ELEMENTLINE '[' measure measure measure measure measure ']'
{
CreateNewLineInElement(yyElement, $3 + yyElement->MarkX,
$4 + yyElement->MarkY, $5 + yyElement->MarkX,
$6 + yyElement->MarkY, $7);
}
- | T_ELEMENTLINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER ')'
+ | T_ELEMENTLINE '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure ')'
{
- CreateNewLineInElement(yyElement, $3*100 + yyElement->MarkX,
- $4*100 + yyElement->MarkY, $5*100 + yyElement->MarkX,
- $6*100 + yyElement->MarkY, $7*100);
+ CreateNewLineInElement(yyElement, $3 + yyElement->MarkX,
+ $4 + yyElement->MarkY, $5 + yyElement->MarkX,
+ $6 + yyElement->MarkY, $7);
}
/* x, y, width, height, startangle, anglediff, thickness */
- | T_ELEMENTARC '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ']'
+ | T_ELEMENTARC '[' measure measure measure measure number number measure ']'
{
CreateNewArcInElement(yyElement, $3 + yyElement->MarkX,
$4 + yyElement->MarkY, $5, $6, $7, $8, $9);
}
- | T_ELEMENTARC '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
+ | T_ELEMENTARC '(' oldmeasure oldmeasure oldmeasure oldmeasure number number oldmeasure ')'
{
- CreateNewArcInElement(yyElement, $3*100 + yyElement->MarkX,
- $4*100 + yyElement->MarkY, $5*100, $6*100, $7, $8, $9*100);
+ CreateNewArcInElement(yyElement, $3 + yyElement->MarkX,
+ $4 + yyElement->MarkY, $5, $6, $7, $8, $9);
}
| { attr_list = & yyElement->Attributes; } attributes
;
@@ -1530,7 +1513,7 @@ numerical flags only
pin_hi_format
/* x, y, thickness, clearance, mask, drilling hole, name,
number, flags */
- : T_PIN '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING 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,
@@ -1542,10 +1525,10 @@ pin_hi_format
pin_1.7_format
/* x, y, thickness, clearance, mask, drilling hole, name,
number, flags */
- : T_PIN '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER ')'
+ : T_PIN '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure STRING STRING INTEGER ')'
{
- CreateNewPin(yyElement, $3*100 + yyElement->MarkX,
- $4*100 + yyElement->MarkY, $5*100, $6*100, $7*100, $8*100, $9,
+ CreateNewPin(yyElement, $3 + yyElement->MarkX,
+ $4 + yyElement->MarkY, $5, $6, $7, $8, $9,
$10, OldFlags($11));
free ($9);
free ($10);
@@ -1554,10 +1537,10 @@ pin_1.7_format
pin_1.6.3_format
/* x, y, thickness, drilling hole, name, number, flags */
- : T_PIN '(' NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER ')'
+ : T_PIN '(' oldmeasure oldmeasure oldmeasure oldmeasure STRING STRING INTEGER ')'
{
- CreateNewPin(yyElement, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
- ($5 + 2*MASKFRAME)*100, $6*100, $7, $8, OldFlags($9));
+ CreateNewPin(yyElement, $3, $4, $5, 200*GROUNDPLANEFRAME,
+ $5 + 200*MASKFRAME, $6, $7, $8, OldFlags($9));
free ($7);
free ($8);
}
@@ -1565,13 +1548,13 @@ pin_1.6.3_format
pin_newformat
/* x, y, thickness, drilling hole, name, flags */
- : T_PIN '(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
+ : T_PIN '(' oldmeasure oldmeasure oldmeasure oldmeasure STRING INTEGER ')'
{
char p_number[8];
sprintf(p_number, "%d", pin_num++);
- CreateNewPin(yyElement, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
- ($5 + 2*MASKFRAME)*100, $6*100, $7, p_number, OldFlags($8));
+ CreateNewPin(yyElement, $3, $4, $5, 200*GROUNDPLANEFRAME,
+ $5 + 200*MASKFRAME, $6, $7, p_number, OldFlags($8));
free ($7);
}
@@ -1581,7 +1564,7 @@ pin_oldformat
/* old format: x, y, thickness, name, flags
* drilling hole is 40% of the diameter
*/
- : T_PIN '(' NUMBER NUMBER NUMBER STRING NUMBER ')'
+ : T_PIN '(' oldmeasure oldmeasure oldmeasure STRING INTEGER ')'
{
BDimension hole = ($5 *DEFAULT_DRILLINGHOLE);
char p_number[8];
@@ -1592,8 +1575,8 @@ pin_oldformat
hole = $5 -MIN_PINORVIACOPPER;
sprintf(p_number, "%d", pin_num++);
- CreateNewPin(yyElement, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
- ($5 + 2*MASKFRAME)*100, hole, $6, p_number, OldFlags($7));
+ CreateNewPin(yyElement, $3, $4, $5, 200*GROUNDPLANEFRAME,
+ $5 + 200*MASKFRAME, hole, $6, p_number, OldFlags($7));
free ($6);
}
;
@@ -1635,7 +1618,7 @@ numerical flags only
pad_hi_format
/* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */
- : T_PAD '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING flags ']'
+ : T_PAD '[' measure measure measure measure measure measure measure STRING STRING flags ']'
{
CreateNewPad(yyElement, $3 + yyElement->MarkX,
$4 + yyElement->MarkY,
@@ -1649,11 +1632,11 @@ pad_hi_format
pad_1.7_format
/* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */
- : T_PAD '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER ')'
+ : T_PAD '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure STRING STRING INTEGER ')'
{
- CreateNewPad(yyElement,$3*100 + yyElement->MarkX,
- $4*100 + yyElement->MarkY, $5*100 + yyElement->MarkX,
- $6*100 + yyElement->MarkY, $7*100, $8*100, $9*100,
+ CreateNewPad(yyElement,$3 + yyElement->MarkX,
+ $4 + yyElement->MarkY, $5 + yyElement->MarkX,
+ $6 + yyElement->MarkY, $7, $8, $9,
$10, $11, OldFlags($12));
free ($10);
free ($11);
@@ -1662,10 +1645,10 @@ pad_1.7_format
pad_newformat
/* x1, y1, x2, y2, thickness, name , pad number, flags */
- : T_PAD '(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER ')'
+ : T_PAD '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure STRING STRING INTEGER ')'
{
- CreateNewPad(yyElement,$3*100,$4*100,$5*100,$6*100,$7*100, 200*GROUNDPLANEFRAME,
- ($7 + 2*MASKFRAME)*100, $8,$9, OldFlags($10));
+ CreateNewPad(yyElement,$3,$4,$5,$6,$7, 200*GROUNDPLANEFRAME,
+ $7 + 200*MASKFRAME, $8,$9, OldFlags($10));
free ($8);
free ($9);
}
@@ -1673,18 +1656,18 @@ pad_newformat
pad
/* x1, y1, x2, y2, thickness, name and flags */
- : T_PAD '(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
+ : T_PAD '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure STRING INTEGER ')'
{
char p_number[8];
sprintf(p_number, "%d", pin_num++);
- CreateNewPad(yyElement,$3*100,$4*100,$5*100,$6*100,$7*100, 200*GROUNDPLANEFRAME,
- ($7 + 2*MASKFRAME)*100, $8,p_number, OldFlags($9));
+ CreateNewPad(yyElement,$3,$4,$5,$6,$7, 200*GROUNDPLANEFRAME,
+ $7 + 200*MASKFRAME, $8,p_number, OldFlags($9));
free ($8);
}
;
-flags : NUMBER { $$ = OldFlags($1); }
+flags : INTEGER { $$ = OldFlags($1); }
| STRING { $$ = string_to_flags ($1, yyerror); }
;
@@ -1713,7 +1696,7 @@ Additional space to allow after this character.
%end-doc */
symbol
- : T_SYMBOL '[' symbolid NUMBER ']' '('
+ : T_SYMBOL '[' symbolid measure ']' '('
{
if ($3 <= 0 || $3 > MAX_FONTPOSITION)
{
@@ -1730,7 +1713,7 @@ symbol
Symbol->Delta = $4;
}
symboldata ')'
- | T_SYMBOL '(' symbolid NUMBER ')' '('
+ | T_SYMBOL '(' symbolid oldmeasure ')' '('
{
if ($3 <= 0 || $3 > MAX_FONTPOSITION)
{
@@ -1744,13 +1727,13 @@ symbol
YYABORT;
}
Symbol->Valid = true;
- Symbol->Delta = $4*100;
+ Symbol->Delta = $4;
}
symboldata ')'
;
symbolid
- : NUMBER
+ : INTEGER
| CHAR_CONST
;
@@ -1783,14 +1766,14 @@ The width of this line.
symboldefinition
/* x1, y1, x2, y2, thickness */
- : T_SYMBOLLINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER ')'
+ : T_SYMBOLLINE '(' oldmeasure oldmeasure oldmeasure oldmeasure oldmeasure ')'
{
- CreateNewLineInSymbol(Symbol, $3*100, $4*100, $5*100, $6*100, $7*100);
+ CreateNewLineInSymbol(Symbol, $3, $4, $5, $6, $7);
}
;
hiressymbol
/* x1, y1, x2, y2, thickness */
- : T_SYMBOLLINE '[' NUMBER NUMBER NUMBER NUMBER NUMBER ']'
+ : T_SYMBOLLINE '[' measure measure measure measure measure ']'
{
CreateNewLineInSymbol(Symbol, $3, $4, $5, $6, $7);
}
@@ -1924,6 +1907,29 @@ opt_string : STRING { $$ = $1; }
| /* empty */ { $$ = 0; }
;
+number
+ : FLOATING { $$ = $1; }
+ | INTEGER { $$ = $1; }
+ ;
+
+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)); }
+
%%
/* ---------------------------------------------------------------------------
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs