3 * ************************** README *******************
5 * If the file format is modified in any way, update
6 * PCB_FILE_VERSION in file.h
8 * ************************** README *******************
15 * PCB, interactive printed circuit board design
16 * Copyright (C) 1994,1995,1996 Thomas Nau
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 * Contact addresses for paper mail and Email:
33 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
34 * Thomas.Nau@rz.uni-ulm.de
38 /* grammar to parse ASCII input of PCB description
45 #define GRIDFIT(x,g) (int)(0.5 + (int)(((x)+(g)/2.)/(g))*(g))
60 #ifdef HAVE_LIBDMALLOC
61 # include <dmalloc.h> /* see http://dmalloc.com */
66 static LayerTypePtr Layer
;
67 static PolygonTypePtr Polygon
;
68 static SymbolTypePtr Symbol
;
70 static LibraryMenuTypePtr Menu
;
71 static Boolean LayerFlag
[MAX_LAYER
+ 2];
73 extern
char *yytext
; /* defined by LEX */
74 extern PCBTypePtr yyPCB
;
75 extern DataTypePtr yyData
;
76 extern ElementTypePtr yyElement
;
77 extern FontTypePtr yyFont
;
78 extern
int yylineno
; /* linenumber */
79 extern
char *yyfilename
; /* in this file */
81 static char *layer_group_string
;
83 static AttributeListTypePtr attr_list
;
85 int yyerror(const char *s
);
87 static int check_file_version
(int);
91 %
union /* define YYSTACK type */
99 %token
<number
> NUMBER CHAR_CONST
/* line thickness, coordinates ... */
100 %token
<floating
> FLOAT
101 %token
<string> STRING
/* element names ... */
103 %token T_FILEVERSION T_PCB T_LAYER T_VIA T_RAT T_LINE T_ARC T_RECTANGLE T_TEXT T_ELEMENTLINE
104 %token T_ELEMENT T_PIN T_PAD T_GRID T_FLAGS T_SYMBOL T_SYMBOLLINE T_CURSOR
105 %token T_ELEMENTARC T_MARK T_GROUPS T_STYLES T_POLYGON T_NETLIST T_NET T_CONN
106 %token T_AREA T_THERMAL T_DRC T_ATTRIBUTE
108 %type
<number
> symbolid
109 %type
<string> opt_string
110 %type
<flagtype
> flags
121 /* %start-doc pcbfile 00pcb
125 A special note about units: Older versions of @code{pcb} used mils
126 (1/1000 inch) as the base unit; a value of 500 in the file meant
127 half an inch. Newer versions uses a "high resolution" syntax,
128 where the base unit is 1/100 of a mil (0.000010 inch); a value of 500 in
129 the file means 5 mils. As a general rule, the variants of each entry
130 listed below which use square brackets are the high resolution formats
131 and use the 1/100 mil units, and the ones with parentheses are the older
132 variants and use 1 mil units. Note that when multiple variants
133 are listed, the most recent (and most preferred) format is the first
136 Symbolic and numeric flags (SFlags and NFlags) are described in
143 /* reset flags for 'used layers';
144 * init font and data pointers
150 Message
("illegal fileformat\n");
153 for
(i
= 0; i
< MAX_LAYER
+ 2; i
++)
154 LayerFlag
[i
] = False
;
155 yyFont
= &yyPCB
->Font
;
156 yyData
= yyPCB
->Data
;
157 yyData
->pcb
= (void *)yyPCB
;
159 layer_group_string
= NULL
;
176 PCBTypePtr pcb_save
= PCB
;
178 if
(layer_group_string
== NULL
)
179 layer_group_string
= Settings.Groups
;
180 CreateNewPCBPost
(yyPCB
, 0);
181 if
(ParseGroupString
(layer_group_string
, &yyPCB
->LayerGroups
, yyData
->LayerN
))
183 Message
("illegal layer-group string\n");
186 /* initialize the polygon clipping now since
187 * we didn't know the layer grouping before.
190 for
(i
= 0; i
< yyData
->LayerN
+2; i
++)
191 for
(j
= 0; j
< yyData
->Layer
[i
].PolygonN
; j
++)
192 InitClip
(yyData
, &yyData
->Layer
[i
], &yyData
->Layer
[i
].Polygon
[j
]);
196 |
{ PreLoadElementPCB
();
197 layer_group_string
= NULL
; }
199 { LayerFlag
[0] = True
;
202 PostLoadElementPCB
();
208 /* reset flags for 'used layers';
209 * init font and data pointers
213 if
(!yyData ||
!yyFont
)
215 Message
("illegal fileformat\n");
218 for
(i
= 0; i
< MAX_LAYER
+ 2; i
++)
219 LayerFlag
[i
] = False
;
233 /* mark all symbols invalid */
238 Message
("illegal fileformat\n");
241 yyFont
->Valid
= False
;
242 for
(i
= 0; i
<= MAX_FONTPOSITION
; i
++)
243 yyFont
->Symbol
[i
].Valid
= False
;
247 yyFont
->Valid
= True
;
252 /* %start-doc pcbfile FileVersion
260 File format version. This version number represents the date when the pcb file
261 format was last changed.
264 Any version of pcb build from sources equal to or newer
265 than this number should be able to read the file. If this line is not present
266 in the input file then file format compatibility is not checked.
273 T_FILEVERSION
'[' NUMBER
']'
275 if
(check_file_version
($3) != 0)
282 /* %start-doc pcbfile Grid
284 /* %start-doc pcbfile PCB
287 PCB ["Name" Width Height]
288 PCB ("Name" Width Height]
294 Name of the PCB project
299 If you don't specify the size of the board, a very large default is
305 : T_PCB
'(' STRING
')'
308 yyPCB
->MaxWidth
= MAX_COORD
;
309 yyPCB
->MaxHeight
= MAX_COORD
;
311 | T_PCB
'(' STRING NUMBER NUMBER
')'
314 yyPCB
->MaxWidth
= $4*100;
315 yyPCB
->MaxHeight
= $5*100;
317 | T_PCB
'[' STRING NUMBER NUMBER
']'
320 yyPCB
->MaxWidth
= $4;
321 yyPCB
->MaxHeight
= $5;
325 /* %start-doc pcbfile Grid
328 Grid [Step OffsetX OffsetY Visible]
329 Grid (Step OffsetX OffsetY Visible)
330 Grid (Step OffsetX OffsetY)
335 Distance from one grid point to adjacent points. This value may be a
336 floating point number for the first two variants.
337 @item OffsetX OffsetY
338 The "origin" of the grid. Normally zero.
340 If non-zero, the grid will be visible on the screen.
352 : T_GRID
'(' NUMBER NUMBER NUMBER
')'
354 yyPCB
->Grid
= $3*100;
355 yyPCB
->GridOffsetX
= $4*100;
356 yyPCB
->GridOffsetY
= $5*100;
360 : T_GRID
'(' NUMBER NUMBER NUMBER NUMBER
')'
362 yyPCB
->Grid
= $3*100;
363 yyPCB
->GridOffsetX
= $4*100;
364 yyPCB
->GridOffsetY
= $5*100;
366 Settings.DrawGrid
= True
;
368 Settings.DrawGrid
= False
;
373 : T_GRID
'(' FLOAT NUMBER NUMBER NUMBER
')'
375 yyPCB
->Grid
= $3*100;
376 yyPCB
->GridOffsetX
= $4*100;
377 yyPCB
->GridOffsetY
= $5*100;
379 Settings.DrawGrid
= True
;
381 Settings.DrawGrid
= False
;
385 : T_GRID
'[' FLOAT NUMBER NUMBER NUMBER
']'
388 yyPCB
->GridOffsetX
= $4;
389 yyPCB
->GridOffsetY
= $5;
391 Settings.DrawGrid
= True
;
393 Settings.DrawGrid
= False
;
397 /* %start-doc pcbfile Cursor
406 Location of the cursor when the board was saved.
408 The current zoom factor. Note that a zoom factor of "0" means 1 mil
409 per screen pixel, N means @math{2^N} mils per screen pixel, etc. The
410 first variant accepts floating point numbers. The special value
411 "1000" means "zoom to fit"
417 : T_CURSOR
'(' NUMBER NUMBER NUMBER
')'
419 yyPCB
->CursorX
= $3*100;
420 yyPCB
->CursorY
= $4*100;
423 | T_CURSOR
'[' NUMBER NUMBER NUMBER
']'
429 | T_CURSOR
'[' NUMBER NUMBER FLOAT
']'
438 /* %start-doc pcbfile PolyArea
446 Minimum area of polygon island to retain. If a polygon has clearances that cause an isolated island to be created, then will only be retained if the area exceeds this minimum area.
453 | T_AREA
'[' FLOAT
']'
455 yyPCB
->IsleArea
= $3;
460 /* %start-doc pcbfile Thermal
468 Relative size of thermal fingers. A value of 1.0 makes the finger
469 width twice the clearance gap width (measured across the gap, not
470 diameter). The normal value is 0.5, which results in a finger width
471 the same as the clearance gap width.
479 | T_THERMAL
'[' FLOAT
']'
481 yyPCB
->ThermScale
= $3;
485 /* %start-doc pcbfile DRC
488 DRC [Bloat Shrink Line Silk Drill Ring]
489 DRC [Bloat Shrink Line Silk]
490 DRC [Bloat Shrink Line]
495 Minimum spacing between copper.
497 Minimum copper overlap to guarantee connectivity.
499 Minimum line thickness.
501 Minimum silk thickness.
505 Minimum width of the annular ring around pins and vias.
518 : T_DRC
'[' NUMBER NUMBER NUMBER
']'
528 : T_DRC
'[' NUMBER NUMBER NUMBER NUMBER
']'
539 : T_DRC
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
']'
545 yyPCB
->minDrill
= $7;
550 /* %start-doc pcbfile Flags
558 A number, whose value is normally given in hex, individual bits of which
559 represent pcb-wide flags as defined in @ref{PCBFlags}.
566 : T_FLAGS
'(' NUMBER
')'
568 yyPCB
->Flags
= MakeFlags
($3 & PCB_FLAGS
);
570 | T_FLAGS
'(' STRING
')'
572 yyPCB
->Flags
= string_to_pcbflags
($3, yyerror);
577 /* %start-doc pcbfile Groups
586 Encodes the layer grouping information. Each group is separated by a
587 colon, each member of each group is separated by a comma. Group
588 members are either numbers from @code{1}..@var{N} for each layer, and
589 the letters @code{c} or @code{s} representing the component side and
590 solder side of the board. Including @code{c} or @code{s} marks that
591 group as being the top or bottom side of the board.
594 Groups("1,2,c:3:4:5,6,s:7,8")
602 : T_GROUPS
'(' STRING
')'
604 layer_group_string
= $3;
609 /* %start-doc pcbfile Styles
618 Encodes the four routing styles @code{pcb} knows about. The four styles
619 are separated by colons. Each style consists of five parameters as follows:
623 The name of the style.
625 Width of lines and arcs.
627 Copper diameter of pins and vias.
629 Drill diameter of pins and vias.
631 Minimum spacing to other nets. If omitted, 10 mils is the default.
638 Styles("Signal,10,40,20:Power,25,60,35:Fat,40,60,35:Skinny,8,36,20")
639 Styles["Logic,1000,3600,2000,1000:Power,2500,6000,3500,1000:
640 @ @ @ Line,4000,6000,3500,1000:Breakout,600,2402,1181,600"]
644 Note that strings in actual files cannot span lines; the above example
645 is split across lines only to make it readable.
650 : T_STYLES
'(' STRING
')'
652 if
(ParseRouteString
($3, &yyPCB
->RouteStyle
[0], 100))
654 Message
("illegal route-style string\n");
658 | T_STYLES
'[' STRING
']'
660 if
(ParseRouteString
($3, &yyPCB
->RouteStyle
[0], 1))
662 Message
("illegal route-style string\n");
676 | pcbdefinitions pcbdefinition
681 |
{ attr_list
= & yyPCB
->Attributes
; } attributes
686 /* clear pointer to force memory allocation by
687 * the appropriate subroutine
703 /* %start-doc pcbfile Via
706 Via [X Y Thickness Clearance Mask Drill "Name" SFlags]
707 Via (X Y Thickness Clearance Mask Drill "Name" NFlags)
708 Via (X Y Thickness Clearance Drill "Name" NFlags)
709 Via (X Y Thickness Drill "Name" NFlags)
710 Via (X Y Thickness "Name" NFlags)
715 coordinates of center
717 outer diameter of copper annulus
719 add to thickness to get clearance diameter
721 diameter of solder mask opening
725 string, name of via (vias have names?)
727 symbolic or numerical flags
735 /* x, y, thickness, clearance, mask, drilling-hole, name, flags */
736 : T_VIA
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING flags
']'
738 CreateNewVia
(yyData
, $3, $4, $5, $6, $7, $8, $9, $10);
744 /* x, y, thickness, clearance, mask, drilling-hole, name, flags */
745 : T_VIA
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER
')'
747 CreateNewVia
(yyData
, $3*100, $4*100, $5*100, $6*100, $7*100, $8*100, $9,
755 /* x, y, thickness, clearance, drilling-hole, name, flags */
756 : T_VIA
'(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER
')'
758 CreateNewVia
(yyData
, $3*100, $4*100, $5*100, $6*100,
759 ($5 + $6)*100, $7*100, $8, OldFlags
($9));
765 /* x, y, thickness, drilling-hole, name, flags */
766 : T_VIA
'(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER
')'
768 CreateNewVia
(yyData
, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME
,
769 ($5 + 2*MASKFRAME
)*100, $6*100, $7, OldFlags
($8));
775 /* old format: x, y, thickness, name, flags */
776 : T_VIA
'(' NUMBER NUMBER NUMBER STRING NUMBER
')'
778 BDimension hole
= ($5 *DEFAULT_DRILLINGHOLE
);
780 /* make sure that there's enough copper left */
781 if
($5 -hole
< MIN_PINORVIACOPPER
&&
782 $5 > MIN_PINORVIACOPPER
)
783 hole
= $5 -MIN_PINORVIACOPPER
;
785 CreateNewVia
(yyData
, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME
,
786 ($5 + 2*MASKFRAME
)*100, hole
, $6, OldFlags
($7));
791 /* %start-doc pcbfile Rat
794 Rat [X1 Y1 Group1 X2 Y2 Group2 SFlags]
795 Rat (X1 Y1 Group1 X2 Y2 Group2 NFlags)
800 The endpoints of the rat line.
802 The layer group each end is connected on.
804 Symbolic or numeric flags.
812 : T_RAT
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags
']'
814 CreateNewRat
(yyData
, $3, $4, $6, $7, $5, $8,
815 Settings.RatThickness
, $9);
817 | T_RAT
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
819 CreateNewRat
(yyData
, $3*100, $4*100, $6*100, $7*100, $5, $8,
820 Settings.RatThickness
, OldFlags
($9));
824 /* %start-doc pcbfile Layer
827 Layer (LayerNum "Name") (
828 @ @ @ @dots{} contents @dots{}
834 The layer number. Layers are numbered sequentially, starting with 1.
835 The last two layers (9 and 10 by default) are solder-side silk and
836 component-side silk, in that order.
840 The contents of the layer, which may include lines, arcs, rectangles,
848 : T_LAYER
'(' NUMBER STRING opt_string
')' '('
850 if
($3 <= 0 ||
$3 > MAX_LAYER
+ 2)
852 yyerror("Layernumber out of range");
857 yyerror("Layernumber used twice");
860 Layer
= &yyData
->Layer
[$3-1];
862 /* memory for name is already allocated */
864 LayerFlag
[$3-1] = True
;
865 if
(yyData
->LayerN
+ 2 < $3)
866 yyData
->LayerN
= $3 - 2;
878 | layerdefinitions layerdefinition
888 /* x1, y1, x2, y2, flags */
889 | T_RECTANGLE
'(' NUMBER NUMBER NUMBER NUMBER NUMBER
')'
891 CreateNewPolygonFromRectangle
(Layer
,
892 $3*100, $4*100, ($3+$5)*100, ($4+$6)*100, OldFlags
($7));
897 /* flags are passed in */
898 | T_POLYGON
'(' flags
')' '('
900 Polygon
= CreateNewPolygon
(Layer
, $3);
905 if
(Polygon
->PointN
>= 3)
907 SetPolygonBoundingBox
(Polygon
);
908 if
(!Layer
->polygon_tree
)
909 Layer
->polygon_tree
= r_create_tree
(NULL
, 0, 0);
910 r_insert_entry
(Layer
->polygon_tree
, (BoxType
*) Polygon
, 0);
914 Message
("WARNING parsing file '%s'\n"
916 " description: 'ignored polygon (< 3 points)'\n",
917 yyfilename
, yylineno
);
918 DestroyObject
(yyData
, POLYGON_TYPE
, Layer
, Polygon
, Polygon
);
923 /* %start-doc pcbfile Line
926 Line [X1 Y1 X2 Y2 Thickness Clearance SFlags]
927 Line (X1 Y1 X2 Y2 Thickness Clearance NFlags)
928 Line (X1 Y1 X2 Y2 Thickness NFlags)
933 The end points of the line
935 The width of the line
937 The amount of space cleared around the line when the line passes
938 through a polygon. The clearance is added to the thickness to get the
939 thickness of the clear; thus the space between the line and the
940 polygon is @math{Clearance/2} wide.
942 Symbolic or numeric flags
950 /* x1, y1, x2, y2, thickness, clearance, flags */
951 : T_LINE
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags
']'
953 CreateNewLineOnLayer
(Layer
, $3, $4, $5, $6, $7, $8, $9);
958 /* x1, y1, x2, y2, thickness, clearance, flags */
959 : T_LINE
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
961 CreateNewLineOnLayer
(Layer
, $3*100, $4*100, $5*100, $6*100,
962 $7*100, $8*100, OldFlags
($9));
967 /* x1, y1, x2, y2, thickness, flags */
968 : T_LINE
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
970 /* eliminate old-style rat-lines */
971 if
(($8 & RATFLAG
) == 0)
972 CreateNewLineOnLayer
(Layer
, $3*100, $4*100, $5*100, $6*100, $7*100,
973 200*GROUNDPLANEFRAME
, OldFlags
($8));
977 /* %start-doc pcbfile Arc
980 Arc [X Y Width Height Thickness Clearance StartAngle DeltaAngle SFlags]
981 Arc (X Y Width Height Thickness Clearance StartAngle DeltaAngle NFlags)
982 Arc (X Y Width Height Thickness StartAngle DeltaAngle NFlags)
987 Coordinates of the center of the arc.
989 The width and height, from the center to the edge. The bounds of the
990 circle of which this arc is a segment, is thus @math{2*Width} by
993 The width of the copper trace which forms the arc.
995 The amount of space cleared around the arc when the line passes
996 through a polygon. The clearance is added to the thickness to get the
997 thickness of the clear; thus the space between the arc and the polygon
998 is @math{Clearance/2} wide.
1000 The angle of one end of the arc, in degrees. In PCB, an angle of zero
1001 points left (negative X direction), and 90 degrees points down
1002 (positive Y direction).
1004 The sweep of the arc. This may be negative. Positive angles sweep
1007 Symbolic or numeric flags.
1015 /* x, y, width, height, thickness, clearance, startangle, delta, flags */
1016 : T_ARC
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags
']'
1018 CreateNewArcOnLayer
(Layer
, $3, $4, $5, $6, $9, $10, $7, $8, $11);
1023 /* x, y, width, height, thickness, clearance, startangle, delta, flags */
1024 : T_ARC
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1026 CreateNewArcOnLayer
(Layer
, $3*100, $4*100, $5*100, $6*100, $9, $10,
1027 $7*100, $8*100, OldFlags
($11));
1032 /* x, y, width, height, thickness, startangle, delta, flags */
1033 : T_ARC
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1035 CreateNewArcOnLayer
(Layer
, $3*100, $4*100, $5*100, $5*100, $8, $9,
1036 $7*100, 200*GROUNDPLANEFRAME
, OldFlags
($10));
1040 /* %start-doc pcbfile Text
1043 Text [X Y Direction Scale "String" SFlags]
1044 Text (X Y Direction Scale "String" NFlags)
1045 Text (X Y Direction "String" NFlags)
1050 The location of the upper left corner of the text.
1052 0 means text is drawn left to right, 1 means up, 2 means right to left
1053 (i.e. upside down), and 3 means down.
1055 Size of the text, as a percentage of the ``default'' size of of the
1056 font (the default font is about 40 mils high). Default is 100 (40
1061 Symbolic or numeric flags.
1069 /* x, y, direction, text, flags */
1070 : T_TEXT
'(' NUMBER NUMBER NUMBER STRING NUMBER
')'
1072 /* use a default scale of 100% */
1073 CreateNewText
(Layer
,yyFont
,$3*100, $4*100, $5, 100, $6, OldFlags
($7));
1079 /* x, y, direction, scale, text, flags */
1080 : T_TEXT
'(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER
')'
1082 if
($8 & ONSILKFLAG
)
1084 LayerTypePtr lay
= &yyData
->Layer
[yyData
->LayerN
+
1085 (($8 & ONSOLDERFLAG
) ? SOLDER_LAYER
: COMPONENT_LAYER
)];
1087 CreateNewText
(lay
,yyFont
, $3*100, $4*100, $5, $6, $7,
1091 CreateNewText
(Layer
, yyFont
, $3*100, $4*100, $5, $6, $7,
1097 /* x, y, direction, scale, text, flags */
1098 : T_TEXT
'[' NUMBER NUMBER NUMBER NUMBER STRING flags
']'
1100 /* FIXME: shouldn't know about .f */
1101 /* I don't think this matters because anything with hi_format
1102 * will have the silk on its own layer in the file rather
1103 * than using the ONSILKFLAG and having it in a copper layer.
1104 * Thus there is no need for anything besides the 'else'
1105 * part of this code.
1107 if
($8.f
& ONSILKFLAG
)
1109 LayerTypePtr lay
= &yyData
->Layer
[yyData
->LayerN
+
1110 (($8.f
& ONSOLDERFLAG
) ? SOLDER_LAYER
: COMPONENT_LAYER
)];
1112 CreateNewText
(lay
, yyFont
, $3, $4, $5, $6, $7, $8);
1115 CreateNewText
(Layer
, yyFont
, $3, $4, $5, $6, $7, $8);
1120 /* %start-doc pcbfile Polygon
1124 @ @ @ @dots{} (X Y) @dots{}
1125 @ @ @ @dots{} [X Y] @dots{}
1131 Symbolic or numeric flags.
1133 Coordinates of each vertex. You must list at least three coordinates.
1140 | polygonpoints polygonpoint
1145 : '(' NUMBER NUMBER
')'
1147 CreateNewPointInPolygon
(Polygon
, $2*100, $3*100);
1149 |
'[' NUMBER NUMBER
']'
1151 CreateNewPointInPolygon
(Polygon
, $2, $3);
1156 /* %start-doc pcbfile Element
1159 Element [SFlags "Desc" "Name" "Value" MX MY TX TY TDir TScale TSFlags] (
1160 Element (NFlags "Desc" "Name" "Value" MX MY TX TY TDir TScale TNFlags) (
1161 Element (NFlags "Desc" "Name" "Value" TX TY TDir TScale TNFlags) (
1162 Element (NFlags "Desc" "Name" TX TY TDir TScale TNFlags) (
1163 Element ("Desc" "Name" TX TY TDir TScale TNFlags) (
1164 @ @ @ @dots{} contents @dots{}
1170 Symbolic or numeric flags, for the element as a whole.
1172 Numeric flags, for the element as a whole.
1174 The description of the element. This is one of the three strings
1175 which can be displayed on the screen.
1177 The name of the element, usually the reference designator.
1179 The value of the element.
1181 The location of the element's mark. This is the reference point
1182 for placing the element and its pins and pads.
1184 The upper left corner of the text (one of the three strings).
1186 The relative direction of the text. 0 means left to right for
1187 an unrotated element, 1 means up, 2 left, 3 down.
1189 Size of the text, as a percentage of the ``default'' size of of the
1190 font (the default font is about 40 mils high). Default is 100 (40
1193 Symbolic or numeric flags, for the text.
1195 Numeric flags, for the text.
1198 Elements may contain pins, pads, element lines, element arcs,
1199 attributes, and (for older elements) an optional mark. Note that
1200 element definitions that have the mark coordinates in the element
1201 line, only support pins and pads which use relative coordinates. The
1202 pin and pad coordinates are relative to the mark. Element definitions
1203 which do not include the mark coordinates in the element line, may
1204 have a Mark definition in their contents, and only use pin and pad
1205 definitions which use absolute coordinates.
1211 | element_1.3
.4_format
1213 | element_1.7_format
1218 /* element_flags, description, pcb-name,
1219 * text_x, text_y, text_direction, text_scale, text_flags
1221 : T_ELEMENT
'(' STRING STRING NUMBER NUMBER NUMBER
')' '('
1223 yyElement
= CreateNewElement
(yyData
, yyElement
, yyFont
, NoFlags
(),
1224 $3, $4, NULL
, $5*100, $6*100, $7, 100, NoFlags
(), False
);
1229 elementdefinitions
')'
1231 SetElementBoundingBox
(yyData
, yyElement
, yyFont
);
1235 element_1.3
.4_format
1236 /* element_flags, description, pcb-name,
1237 * text_x, text_y, text_direction, text_scale, text_flags
1239 : T_ELEMENT
'(' NUMBER STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER
')' '('
1241 yyElement
= CreateNewElement
(yyData
, yyElement
, yyFont
, OldFlags
($3),
1242 $4, $5, NULL
, $6*100, $7*100, $8, $9, OldFlags
($10), False
);
1247 elementdefinitions
')'
1249 SetElementBoundingBox
(yyData
, yyElement
, yyFont
);
1254 /* element_flags, description, pcb-name, value,
1255 * text_x, text_y, text_direction, text_scale, text_flags
1257 : T_ELEMENT
'(' NUMBER STRING STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER
')' '('
1259 yyElement
= CreateNewElement
(yyData
, yyElement
, yyFont
, OldFlags
($3),
1260 $4, $5, $6, $7*100, $8*100, $9, $10, OldFlags
($11), False
);
1266 elementdefinitions
')'
1268 SetElementBoundingBox
(yyData
, yyElement
, yyFont
);
1273 /* element_flags, description, pcb-name, value, mark_x, mark_y,
1274 * text_x, text_y, text_direction, text_scale, text_flags
1276 : T_ELEMENT
'(' NUMBER STRING STRING STRING NUMBER NUMBER
1277 NUMBER NUMBER NUMBER NUMBER NUMBER
')' '('
1279 yyElement
= CreateNewElement
(yyData
, yyElement
, yyFont
, OldFlags
($3),
1280 $4, $5, $6, ($7+$9)*100, ($8+$10)*100, $11, $12, OldFlags
($13), False
);
1281 yyElement
->MarkX
= $7*100;
1282 yyElement
->MarkY
= $8*100;
1289 SetElementBoundingBox
(yyData
, yyElement
, yyFont
);
1294 /* element_flags, description, pcb-name, value, mark_x, mark_y,
1295 * text_x, text_y, text_direction, text_scale, text_flags
1297 : T_ELEMENT
'[' flags STRING STRING STRING NUMBER NUMBER
1298 NUMBER NUMBER NUMBER NUMBER flags
']' '('
1300 yyElement
= CreateNewElement
(yyData
, yyElement
, yyFont
, $3,
1301 $4, $5, $6, ($7+$9), ($8+$10), $11, $12, $13, False
);
1302 yyElement
->MarkX
= $7;
1303 yyElement
->MarkY
= $8;
1310 SetElementBoundingBox
(yyData
, yyElement
, yyFont
);
1314 /* %start-doc pcbfile ElementLine
1317 ElementLine [X1 Y1 X2 Y2 Thickness]
1318 ElementLine (X1 Y1 X2 Y2 Thickness)
1323 Coordinates of the endpoints of the line. These are relative to the
1324 Element's mark point for new element formats, or absolute for older
1327 The width of the silk for this line.
1332 /* %start-doc pcbfile ElementArc
1335 ElementArc [X Y Width Height StartAngle DeltaAngle Thickness]
1336 ElementArc (X Y Width Height StartAngle DeltaAngle Thickness)
1341 Coordinates of the center of the arc. These are relative to the
1342 Element's mark point for new element formats, or absolute for older
1345 The width and height, from the center to the edge. The bounds of the
1346 circle of which this arc is a segment, is thus @math{2*Width} by
1349 The angle of one end of the arc, in degrees. In PCB, an angle of zero
1350 points left (negative X direction), and 90 degrees points down
1351 (positive Y direction).
1353 The sweep of the arc. This may be negative. Positive angles sweep
1356 The width of the silk line which forms the arc.
1361 /* %start-doc pcbfile Mark
1370 Coordinates of the Mark, for older element formats that don't have
1371 the mark as part of the Element line.
1378 | elementdefinitions elementdefinition
1387 /* x1, y1, x2, y2, thickness */
1388 | T_ELEMENTLINE
'[' NUMBER NUMBER NUMBER NUMBER NUMBER
']'
1390 CreateNewLineInElement
(yyElement
, $3, $4, $5, $6, $7);
1392 /* x1, y1, x2, y2, thickness */
1393 | T_ELEMENTLINE
'(' NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1395 CreateNewLineInElement
(yyElement
, $3*100, $4*100, $5*100, $6*100, $7*100);
1397 /* x, y, width, height, startangle, anglediff, thickness */
1398 | T_ELEMENTARC
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
']'
1400 CreateNewArcInElement
(yyElement
, $3, $4, $5, $6, $7, $8, $9);
1402 /* x, y, width, height, startangle, anglediff, thickness */
1403 | T_ELEMENTARC
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1405 CreateNewArcInElement
(yyElement
, $3*100, $4*100, $5*100, $6*100, $7, $8, $9*100);
1408 | T_MARK
'[' NUMBER NUMBER
']'
1410 yyElement
->MarkX
= $3;
1411 yyElement
->MarkY
= $4;
1413 | T_MARK
'(' NUMBER NUMBER
')'
1415 yyElement
->MarkX
= $3*100;
1416 yyElement
->MarkY
= $4*100;
1418 |
{ attr_list
= & yyElement
->Attributes
; } attributes
1423 | relementdefs relementdef
1431 /* x1, y1, x2, y2, thickness */
1432 | T_ELEMENTLINE
'[' NUMBER NUMBER NUMBER NUMBER NUMBER
']'
1434 CreateNewLineInElement
(yyElement
, $3 + yyElement
->MarkX
,
1435 $4 + yyElement
->MarkY
, $5 + yyElement
->MarkX
,
1436 $6 + yyElement
->MarkY
, $7);
1438 | T_ELEMENTLINE
'(' NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1440 CreateNewLineInElement
(yyElement
, $3*100 + yyElement
->MarkX
,
1441 $4*100 + yyElement
->MarkY
, $5*100 + yyElement
->MarkX
,
1442 $6*100 + yyElement
->MarkY
, $7*100);
1444 /* x, y, width, height, startangle, anglediff, thickness */
1445 | T_ELEMENTARC
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
']'
1447 CreateNewArcInElement
(yyElement
, $3 + yyElement
->MarkX
,
1448 $4 + yyElement
->MarkY
, $5, $6, $7, $8, $9);
1450 | T_ELEMENTARC
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1452 CreateNewArcInElement
(yyElement
, $3*100 + yyElement
->MarkX
,
1453 $4*100 + yyElement
->MarkY
, $5*100, $6*100, $7, $8, $9*100);
1455 |
{ attr_list
= & yyElement
->Attributes
; } attributes
1458 /* %start-doc pcbfile Pin
1461 Pin [rX rY Thickness Clearance Mask Drill "Name" "Number" SFlags]
1462 Pin (rX rY Thickness Clearance Mask Drill "Name" "Number" NFlags)
1463 Pin (aX aY Thickness Drill "Name" "Number" NFlags)
1464 Pin (aX aY Thickness Drill "Name" NFlags)
1465 Pin (aX aY Thickness "Name" NFlags)
1470 coordinates of center, relative to the element's mark
1472 absolute coordinates of center.
1474 outer diameter of copper annulus
1476 add to thickness to get clearance diameter
1478 diameter of solder mask opening
1486 symbolic or numerical flags
1488 numerical flags only
1494 /* x, y, thickness, clearance, mask, drilling hole, name,
1496 : T_PIN
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING flags
']'
1498 CreateNewPin
(yyElement
, $3 + yyElement
->MarkX
,
1499 $4 + yyElement
->MarkY
, $5, $6, $7, $8, $9,
1506 /* x, y, thickness, clearance, mask, drilling hole, name,
1508 : T_PIN
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER
')'
1510 CreateNewPin
(yyElement
, $3*100 + yyElement
->MarkX
,
1511 $4*100 + yyElement
->MarkY
, $5*100, $6*100, $7*100, $8*100, $9,
1512 $10, OldFlags
($11));
1519 /* x, y, thickness, drilling hole, name, number, flags */
1520 : T_PIN
'(' NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER
')'
1522 CreateNewPin
(yyElement
, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME
,
1523 ($5 + 2*MASKFRAME
)*100, $6*100, $7, $8, OldFlags
($9));
1530 /* x, y, thickness, drilling hole, name, flags */
1531 : T_PIN
'(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER
')'
1535 sprintf
(p_number
, "%d", pin_num
++);
1536 CreateNewPin
(yyElement
, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME
,
1537 ($5 + 2*MASKFRAME
)*100, $6*100, $7, p_number
, OldFlags
($8));
1544 /* old format: x, y, thickness, name, flags
1545 * drilling hole is 40% of the diameter
1547 : T_PIN
'(' NUMBER NUMBER NUMBER STRING NUMBER
')'
1549 BDimension hole
= ($5 *DEFAULT_DRILLINGHOLE
);
1552 /* make sure that there's enough copper left */
1553 if
($5 -hole
< MIN_PINORVIACOPPER
&&
1554 $5 > MIN_PINORVIACOPPER
)
1555 hole
= $5 -MIN_PINORVIACOPPER
;
1557 sprintf
(p_number
, "%d", pin_num
++);
1558 CreateNewPin
(yyElement
, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME
,
1559 ($5 + 2*MASKFRAME
)*100, hole
, $6, p_number
, OldFlags
($7));
1564 /* %start-doc pcbfile Pad
1567 Pad [rX1 rY1 rX2 rY2 Thickness Clearance Mask "Name" "Number" SFlags]
1568 Pad (rX1 rY1 rX2 rY2 Thickness Clearance Mask "Name" "Number" NFlags)
1569 Pad (aX1 aY1 aX2 aY2 Thickness "Name" "Number" NFlags)
1570 Pad (aX1 aY1 aX2 aY2 Thickness "Name" NFlags)
1574 @item rX1 rY1 rX2 rY2
1575 Coordinates of the endpoints of the pad, relative to the element's
1576 mark. Note that the copper extends beyond these coordinates by half
1577 the thickness. To make a square or round pad, specify the same
1579 @item aX1 aY1 aX2 aY2
1580 Same, but absolute coordinates of the endpoints of the pad.
1584 add to thickness to get clearance width.
1586 width of solder mask opening.
1592 symbolic or numerical flags
1594 numerical flags only
1600 /* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */
1601 : T_PAD
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING flags
']'
1603 CreateNewPad
(yyElement
, $3 + yyElement
->MarkX
,
1604 $4 + yyElement
->MarkY
,
1605 $5 + yyElement
->MarkX
,
1606 $6 + yyElement
->MarkY
, $7, $8, $9,
1614 /* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */
1615 : T_PAD
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER
')'
1617 CreateNewPad
(yyElement
,$3*100 + yyElement
->MarkX
,
1618 $4*100 + yyElement
->MarkY
, $5*100 + yyElement
->MarkX
,
1619 $6*100 + yyElement
->MarkY
, $7*100, $8*100, $9*100,
1620 $10, $11, OldFlags
($12));
1627 /* x1, y1, x2, y2, thickness, name , pad number, flags */
1628 : T_PAD
'(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER
')'
1630 CreateNewPad
(yyElement
,$3*100,$4*100,$5*100,$6*100,$7*100, 200*GROUNDPLANEFRAME
,
1631 ($7 + 2*MASKFRAME
)*100, $8,$9, OldFlags
($10));
1638 /* x1, y1, x2, y2, thickness, name and flags */
1639 : T_PAD
'(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER
')'
1643 sprintf
(p_number
, "%d", pin_num
++);
1644 CreateNewPad
(yyElement
,$3*100,$4*100,$5*100,$6*100,$7*100, 200*GROUNDPLANEFRAME
,
1645 ($7 + 2*MASKFRAME
)*100, $8,p_number
, OldFlags
($9));
1650 flags
: NUMBER
{ $$
= OldFlags
($1); }
1651 | STRING
{ $$
= string_to_flags
($1, yyerror); }
1659 /* %start-doc pcbfile Symbol
1662 Symbol [Char Delta] (
1663 Symbol (Char Delta) (
1664 @ @ @ @dots{} symbol lines @dots{}
1670 The character or numerical character value this symbol represents.
1671 Characters must be in single quotes.
1673 Additional space to allow after this character.
1679 : T_SYMBOL
'[' symbolid NUMBER
']' '('
1681 if
($3 <= 0 ||
$3 > MAX_FONTPOSITION
)
1683 yyerror("fontposition out of range");
1686 Symbol
= &yyFont
->Symbol
[$3];
1689 yyerror("symbol ID used twice");
1692 Symbol
->Valid
= True
;
1696 | T_SYMBOL
'(' symbolid NUMBER
')' '('
1698 if
($3 <= 0 ||
$3 > MAX_FONTPOSITION
)
1700 yyerror("fontposition out of range");
1703 Symbol
= &yyFont
->Symbol
[$3];
1706 yyerror("symbol ID used twice");
1709 Symbol
->Valid
= True
;
1710 Symbol
->Delta
= $4*100;
1722 | symboldata symboldefinitions
1731 /* %start-doc pcbfile SymbolLine
1734 SymbolLine [X1 Y1 X2 Y1 Thickness]
1735 SymbolLine (X1 Y1 X2 Y1 Thickness)
1740 The endpoints of this line.
1742 The width of this line.
1748 /* x1, y1, x2, y2, thickness */
1749 : T_SYMBOLLINE
'(' NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1751 CreateNewLineInSymbol
(Symbol
, $3*100, $4*100, $5*100, $6*100, $7*100);
1755 /* x1, y1, x2, y2, thickness */
1756 : T_SYMBOLLINE
'[' NUMBER NUMBER NUMBER NUMBER NUMBER
']'
1758 CreateNewLineInSymbol
(Symbol
, $3, $4, $5, $6, $7);
1762 /* %start-doc pcbfile Netlist
1766 @ @ @ @dots{} nets @dots{}
1772 pcbnetlist
: pcbnetdef
1776 /* net(...) net(...) ... */
1777 : T_NETLIST
'(' ')' '('
1791 /* %start-doc pcbfile Net
1794 Net ("Name" "Style") (
1795 @ @ @ @dots{} connects @dots{}
1801 The name of this net.
1803 The routing style that should be used when autorouting this net.
1809 /* name style pin pin ... */
1810 : T_NET
'(' STRING STRING
')' '('
1812 Menu
= CreateNewNet
(&yyPCB
->NetlistLib
, $3, $4);
1829 /* %start-doc pcbfile Connect
1837 The name of a pin or pad which is included in this net. Pin and Pad
1838 names are named by the refdes and pin name, like @code{"U14-7"} for
1839 pin 7 of U14, or @code{"T4-E"} for pin E of T4.
1845 : T_CONN
'(' STRING
')'
1847 CreateNewConnection
(Menu
, $3);
1852 /* %start-doc pcbfile Attribute
1855 Attribute ("Name" "Value")
1858 Attributes allow boards and elements to have arbitrary data attached
1859 to them, which is not directly used by PCB itself but may be of use by
1860 other programs or users.
1864 The name of the attribute
1867 The value of the attribute. Values are always stored as strings, even
1868 if the value is interpreted as, for example, a number.
1874 attributes
: attribute
1875 | attributes attribute
1878 : T_ATTRIBUTE
'(' STRING STRING
')'
1880 CreateNewAttribute
(attr_list
, $3, $4);
1886 opt_string
: STRING
{ $$
= $1; }
1887 |
/* empty */ { $$
= 0; }
1892 /* ---------------------------------------------------------------------------
1893 * error routine called by parser library
1898 Message
("ERROR parsing file '%s'\n"
1900 " description: '%s'\n",
1901 yyfilename
, yylineno
, s
);
1912 check_file_version
(int ver
)
1914 if
( ver
> PCB_FILE_VERSION
) {
1915 Message
("ERROR: The file you are attempting to load is in a format\n"
1916 "which is too new for this version of pcb. To load this file\n"
1917 "you need a version of pcb which is >= %d. If you are\n"
1918 "using a version built from cvs sources, the source date\n"
1919 "must be >= %d. This copy of pcb can only read files\n"
1920 "up to file version %d.\n", ver
, ver
, PCB_FILE_VERSION
);