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 attributes, 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 |
{ attr_list
= & Layer
->Attributes
; } attributes
898 /* flags are passed in */
899 | T_POLYGON
'(' flags
')' '('
901 Polygon
= CreateNewPolygon
(Layer
, $3);
906 if
(Polygon
->PointN
>= 3)
908 SetPolygonBoundingBox
(Polygon
);
909 if
(!Layer
->polygon_tree
)
910 Layer
->polygon_tree
= r_create_tree
(NULL
, 0, 0);
911 r_insert_entry
(Layer
->polygon_tree
, (BoxType
*) Polygon
, 0);
915 Message
("WARNING parsing file '%s'\n"
917 " description: 'ignored polygon (< 3 points)'\n",
918 yyfilename
, yylineno
);
919 DestroyObject
(yyData
, POLYGON_TYPE
, Layer
, Polygon
, Polygon
);
924 /* %start-doc pcbfile Line
927 Line [X1 Y1 X2 Y2 Thickness Clearance SFlags]
928 Line (X1 Y1 X2 Y2 Thickness Clearance NFlags)
929 Line (X1 Y1 X2 Y2 Thickness NFlags)
934 The end points of the line
936 The width of the line
938 The amount of space cleared around the line when the line passes
939 through a polygon. The clearance is added to the thickness to get the
940 thickness of the clear; thus the space between the line and the
941 polygon is @math{Clearance/2} wide.
943 Symbolic or numeric flags
951 /* x1, y1, x2, y2, thickness, clearance, flags */
952 : T_LINE
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags
']'
954 CreateNewLineOnLayer
(Layer
, $3, $4, $5, $6, $7, $8, $9);
959 /* x1, y1, x2, y2, thickness, clearance, flags */
960 : T_LINE
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
962 CreateNewLineOnLayer
(Layer
, $3*100, $4*100, $5*100, $6*100,
963 $7*100, $8*100, OldFlags
($9));
968 /* x1, y1, x2, y2, thickness, flags */
969 : T_LINE
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
971 /* eliminate old-style rat-lines */
972 if
(($8 & RATFLAG
) == 0)
973 CreateNewLineOnLayer
(Layer
, $3*100, $4*100, $5*100, $6*100, $7*100,
974 200*GROUNDPLANEFRAME
, OldFlags
($8));
978 /* %start-doc pcbfile Arc
981 Arc [X Y Width Height Thickness Clearance StartAngle DeltaAngle SFlags]
982 Arc (X Y Width Height Thickness Clearance StartAngle DeltaAngle NFlags)
983 Arc (X Y Width Height Thickness StartAngle DeltaAngle NFlags)
988 Coordinates of the center of the arc.
990 The width and height, from the center to the edge. The bounds of the
991 circle of which this arc is a segment, is thus @math{2*Width} by
994 The width of the copper trace which forms the arc.
996 The amount of space cleared around the arc when the line passes
997 through a polygon. The clearance is added to the thickness to get the
998 thickness of the clear; thus the space between the arc and the polygon
999 is @math{Clearance/2} wide.
1001 The angle of one end of the arc, in degrees. In PCB, an angle of zero
1002 points left (negative X direction), and 90 degrees points down
1003 (positive Y direction).
1005 The sweep of the arc. This may be negative. Positive angles sweep
1008 Symbolic or numeric flags.
1016 /* x, y, width, height, thickness, clearance, startangle, delta, flags */
1017 : T_ARC
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags
']'
1019 CreateNewArcOnLayer
(Layer
, $3, $4, $5, $6, $9, $10, $7, $8, $11);
1024 /* x, y, width, height, thickness, clearance, startangle, delta, flags */
1025 : T_ARC
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1027 CreateNewArcOnLayer
(Layer
, $3*100, $4*100, $5*100, $6*100, $9, $10,
1028 $7*100, $8*100, OldFlags
($11));
1033 /* x, y, width, height, thickness, startangle, delta, flags */
1034 : T_ARC
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1036 CreateNewArcOnLayer
(Layer
, $3*100, $4*100, $5*100, $5*100, $8, $9,
1037 $7*100, 200*GROUNDPLANEFRAME
, OldFlags
($10));
1041 /* %start-doc pcbfile Text
1044 Text [X Y Direction Scale "String" SFlags]
1045 Text (X Y Direction Scale "String" NFlags)
1046 Text (X Y Direction "String" NFlags)
1051 The location of the upper left corner of the text.
1053 0 means text is drawn left to right, 1 means up, 2 means right to left
1054 (i.e. upside down), and 3 means down.
1056 Size of the text, as a percentage of the ``default'' size of of the
1057 font (the default font is about 40 mils high). Default is 100 (40
1062 Symbolic or numeric flags.
1070 /* x, y, direction, text, flags */
1071 : T_TEXT
'(' NUMBER NUMBER NUMBER STRING NUMBER
')'
1073 /* use a default scale of 100% */
1074 CreateNewText
(Layer
,yyFont
,$3*100, $4*100, $5, 100, $6, OldFlags
($7));
1080 /* x, y, direction, scale, text, flags */
1081 : T_TEXT
'(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER
')'
1083 if
($8 & ONSILKFLAG
)
1085 LayerTypePtr lay
= &yyData
->Layer
[yyData
->LayerN
+
1086 (($8 & ONSOLDERFLAG
) ? SOLDER_LAYER
: COMPONENT_LAYER
)];
1088 CreateNewText
(lay
,yyFont
, $3*100, $4*100, $5, $6, $7,
1092 CreateNewText
(Layer
, yyFont
, $3*100, $4*100, $5, $6, $7,
1098 /* x, y, direction, scale, text, flags */
1099 : T_TEXT
'[' NUMBER NUMBER NUMBER NUMBER STRING flags
']'
1101 /* FIXME: shouldn't know about .f */
1102 /* I don't think this matters because anything with hi_format
1103 * will have the silk on its own layer in the file rather
1104 * than using the ONSILKFLAG and having it in a copper layer.
1105 * Thus there is no need for anything besides the 'else'
1106 * part of this code.
1108 if
($8.f
& ONSILKFLAG
)
1110 LayerTypePtr lay
= &yyData
->Layer
[yyData
->LayerN
+
1111 (($8.f
& ONSOLDERFLAG
) ? SOLDER_LAYER
: COMPONENT_LAYER
)];
1113 CreateNewText
(lay
, yyFont
, $3, $4, $5, $6, $7, $8);
1116 CreateNewText
(Layer
, yyFont
, $3, $4, $5, $6, $7, $8);
1121 /* %start-doc pcbfile Polygon
1125 @ @ @ @dots{} (X Y) @dots{}
1126 @ @ @ @dots{} [X Y] @dots{}
1132 Symbolic or numeric flags.
1134 Coordinates of each vertex. You must list at least three coordinates.
1141 | polygonpoints polygonpoint
1146 : '(' NUMBER NUMBER
')'
1148 CreateNewPointInPolygon
(Polygon
, $2*100, $3*100);
1150 |
'[' NUMBER NUMBER
']'
1152 CreateNewPointInPolygon
(Polygon
, $2, $3);
1157 /* %start-doc pcbfile Element
1160 Element [SFlags "Desc" "Name" "Value" MX MY TX TY TDir TScale TSFlags] (
1161 Element (NFlags "Desc" "Name" "Value" MX MY TX TY TDir TScale TNFlags) (
1162 Element (NFlags "Desc" "Name" "Value" TX TY TDir TScale TNFlags) (
1163 Element (NFlags "Desc" "Name" TX TY TDir TScale TNFlags) (
1164 Element ("Desc" "Name" TX TY TDir TScale TNFlags) (
1165 @ @ @ @dots{} contents @dots{}
1171 Symbolic or numeric flags, for the element as a whole.
1173 Numeric flags, for the element as a whole.
1175 The description of the element. This is one of the three strings
1176 which can be displayed on the screen.
1178 The name of the element, usually the reference designator.
1180 The value of the element.
1182 The location of the element's mark. This is the reference point
1183 for placing the element and its pins and pads.
1185 The upper left corner of the text (one of the three strings).
1187 The relative direction of the text. 0 means left to right for
1188 an unrotated element, 1 means up, 2 left, 3 down.
1190 Size of the text, as a percentage of the ``default'' size of of the
1191 font (the default font is about 40 mils high). Default is 100 (40
1194 Symbolic or numeric flags, for the text.
1196 Numeric flags, for the text.
1199 Elements may contain pins, pads, element lines, element arcs,
1200 attributes, and (for older elements) an optional mark. Note that
1201 element definitions that have the mark coordinates in the element
1202 line, only support pins and pads which use relative coordinates. The
1203 pin and pad coordinates are relative to the mark. Element definitions
1204 which do not include the mark coordinates in the element line, may
1205 have a Mark definition in their contents, and only use pin and pad
1206 definitions which use absolute coordinates.
1212 | element_1.3
.4_format
1214 | element_1.7_format
1219 /* element_flags, description, pcb-name,
1220 * text_x, text_y, text_direction, text_scale, text_flags
1222 : T_ELEMENT
'(' STRING STRING NUMBER NUMBER NUMBER
')' '('
1224 yyElement
= CreateNewElement
(yyData
, yyElement
, yyFont
, NoFlags
(),
1225 $3, $4, NULL
, $5*100, $6*100, $7, 100, NoFlags
(), False
);
1230 elementdefinitions
')'
1232 SetElementBoundingBox
(yyData
, yyElement
, yyFont
);
1236 element_1.3
.4_format
1237 /* element_flags, description, pcb-name,
1238 * text_x, text_y, text_direction, text_scale, text_flags
1240 : T_ELEMENT
'(' NUMBER STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER
')' '('
1242 yyElement
= CreateNewElement
(yyData
, yyElement
, yyFont
, OldFlags
($3),
1243 $4, $5, NULL
, $6*100, $7*100, $8, $9, OldFlags
($10), False
);
1248 elementdefinitions
')'
1250 SetElementBoundingBox
(yyData
, yyElement
, yyFont
);
1255 /* element_flags, description, pcb-name, value,
1256 * text_x, text_y, text_direction, text_scale, text_flags
1258 : T_ELEMENT
'(' NUMBER STRING STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER
')' '('
1260 yyElement
= CreateNewElement
(yyData
, yyElement
, yyFont
, OldFlags
($3),
1261 $4, $5, $6, $7*100, $8*100, $9, $10, OldFlags
($11), False
);
1267 elementdefinitions
')'
1269 SetElementBoundingBox
(yyData
, yyElement
, yyFont
);
1274 /* element_flags, description, pcb-name, value, mark_x, mark_y,
1275 * text_x, text_y, text_direction, text_scale, text_flags
1277 : T_ELEMENT
'(' NUMBER STRING STRING STRING NUMBER NUMBER
1278 NUMBER NUMBER NUMBER NUMBER NUMBER
')' '('
1280 yyElement
= CreateNewElement
(yyData
, yyElement
, yyFont
, OldFlags
($3),
1281 $4, $5, $6, ($7+$9)*100, ($8+$10)*100, $11, $12, OldFlags
($13), False
);
1282 yyElement
->MarkX
= $7*100;
1283 yyElement
->MarkY
= $8*100;
1290 SetElementBoundingBox
(yyData
, yyElement
, yyFont
);
1295 /* element_flags, description, pcb-name, value, mark_x, mark_y,
1296 * text_x, text_y, text_direction, text_scale, text_flags
1298 : T_ELEMENT
'[' flags STRING STRING STRING NUMBER NUMBER
1299 NUMBER NUMBER NUMBER NUMBER flags
']' '('
1301 yyElement
= CreateNewElement
(yyData
, yyElement
, yyFont
, $3,
1302 $4, $5, $6, ($7+$9), ($8+$10), $11, $12, $13, False
);
1303 yyElement
->MarkX
= $7;
1304 yyElement
->MarkY
= $8;
1311 SetElementBoundingBox
(yyData
, yyElement
, yyFont
);
1315 /* %start-doc pcbfile ElementLine
1318 ElementLine [X1 Y1 X2 Y2 Thickness]
1319 ElementLine (X1 Y1 X2 Y2 Thickness)
1324 Coordinates of the endpoints of the line. These are relative to the
1325 Element's mark point for new element formats, or absolute for older
1328 The width of the silk for this line.
1333 /* %start-doc pcbfile ElementArc
1336 ElementArc [X Y Width Height StartAngle DeltaAngle Thickness]
1337 ElementArc (X Y Width Height StartAngle DeltaAngle Thickness)
1342 Coordinates of the center of the arc. These are relative to the
1343 Element's mark point for new element formats, or absolute for older
1346 The width and height, from the center to the edge. The bounds of the
1347 circle of which this arc is a segment, is thus @math{2*Width} by
1350 The angle of one end of the arc, in degrees. In PCB, an angle of zero
1351 points left (negative X direction), and 90 degrees points down
1352 (positive Y direction).
1354 The sweep of the arc. This may be negative. Positive angles sweep
1357 The width of the silk line which forms the arc.
1362 /* %start-doc pcbfile Mark
1371 Coordinates of the Mark, for older element formats that don't have
1372 the mark as part of the Element line.
1379 | elementdefinitions elementdefinition
1388 /* x1, y1, x2, y2, thickness */
1389 | T_ELEMENTLINE
'[' NUMBER NUMBER NUMBER NUMBER NUMBER
']'
1391 CreateNewLineInElement
(yyElement
, $3, $4, $5, $6, $7);
1393 /* x1, y1, x2, y2, thickness */
1394 | T_ELEMENTLINE
'(' NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1396 CreateNewLineInElement
(yyElement
, $3*100, $4*100, $5*100, $6*100, $7*100);
1398 /* x, y, width, height, startangle, anglediff, thickness */
1399 | T_ELEMENTARC
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
']'
1401 CreateNewArcInElement
(yyElement
, $3, $4, $5, $6, $7, $8, $9);
1403 /* x, y, width, height, startangle, anglediff, thickness */
1404 | T_ELEMENTARC
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1406 CreateNewArcInElement
(yyElement
, $3*100, $4*100, $5*100, $6*100, $7, $8, $9*100);
1409 | T_MARK
'[' NUMBER NUMBER
']'
1411 yyElement
->MarkX
= $3;
1412 yyElement
->MarkY
= $4;
1414 | T_MARK
'(' NUMBER NUMBER
')'
1416 yyElement
->MarkX
= $3*100;
1417 yyElement
->MarkY
= $4*100;
1419 |
{ attr_list
= & yyElement
->Attributes
; } attributes
1424 | relementdefs relementdef
1432 /* x1, y1, x2, y2, thickness */
1433 | T_ELEMENTLINE
'[' NUMBER NUMBER NUMBER NUMBER NUMBER
']'
1435 CreateNewLineInElement
(yyElement
, $3 + yyElement
->MarkX
,
1436 $4 + yyElement
->MarkY
, $5 + yyElement
->MarkX
,
1437 $6 + yyElement
->MarkY
, $7);
1439 | T_ELEMENTLINE
'(' NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1441 CreateNewLineInElement
(yyElement
, $3*100 + yyElement
->MarkX
,
1442 $4*100 + yyElement
->MarkY
, $5*100 + yyElement
->MarkX
,
1443 $6*100 + yyElement
->MarkY
, $7*100);
1445 /* x, y, width, height, startangle, anglediff, thickness */
1446 | T_ELEMENTARC
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
']'
1448 CreateNewArcInElement
(yyElement
, $3 + yyElement
->MarkX
,
1449 $4 + yyElement
->MarkY
, $5, $6, $7, $8, $9);
1451 | T_ELEMENTARC
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1453 CreateNewArcInElement
(yyElement
, $3*100 + yyElement
->MarkX
,
1454 $4*100 + yyElement
->MarkY
, $5*100, $6*100, $7, $8, $9*100);
1456 |
{ attr_list
= & yyElement
->Attributes
; } attributes
1459 /* %start-doc pcbfile Pin
1462 Pin [rX rY Thickness Clearance Mask Drill "Name" "Number" SFlags]
1463 Pin (rX rY Thickness Clearance Mask Drill "Name" "Number" NFlags)
1464 Pin (aX aY Thickness Drill "Name" "Number" NFlags)
1465 Pin (aX aY Thickness Drill "Name" NFlags)
1466 Pin (aX aY Thickness "Name" NFlags)
1471 coordinates of center, relative to the element's mark
1473 absolute coordinates of center.
1475 outer diameter of copper annulus
1477 add to thickness to get clearance diameter
1479 diameter of solder mask opening
1487 symbolic or numerical flags
1489 numerical flags only
1495 /* x, y, thickness, clearance, mask, drilling hole, name,
1497 : T_PIN
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING flags
']'
1499 CreateNewPin
(yyElement
, $3 + yyElement
->MarkX
,
1500 $4 + yyElement
->MarkY
, $5, $6, $7, $8, $9,
1507 /* x, y, thickness, clearance, mask, drilling hole, name,
1509 : T_PIN
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER
')'
1511 CreateNewPin
(yyElement
, $3*100 + yyElement
->MarkX
,
1512 $4*100 + yyElement
->MarkY
, $5*100, $6*100, $7*100, $8*100, $9,
1513 $10, OldFlags
($11));
1520 /* x, y, thickness, drilling hole, name, number, flags */
1521 : T_PIN
'(' NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER
')'
1523 CreateNewPin
(yyElement
, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME
,
1524 ($5 + 2*MASKFRAME
)*100, $6*100, $7, $8, OldFlags
($9));
1531 /* x, y, thickness, drilling hole, name, flags */
1532 : T_PIN
'(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER
')'
1536 sprintf
(p_number
, "%d", pin_num
++);
1537 CreateNewPin
(yyElement
, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME
,
1538 ($5 + 2*MASKFRAME
)*100, $6*100, $7, p_number
, OldFlags
($8));
1545 /* old format: x, y, thickness, name, flags
1546 * drilling hole is 40% of the diameter
1548 : T_PIN
'(' NUMBER NUMBER NUMBER STRING NUMBER
')'
1550 BDimension hole
= ($5 *DEFAULT_DRILLINGHOLE
);
1553 /* make sure that there's enough copper left */
1554 if
($5 -hole
< MIN_PINORVIACOPPER
&&
1555 $5 > MIN_PINORVIACOPPER
)
1556 hole
= $5 -MIN_PINORVIACOPPER
;
1558 sprintf
(p_number
, "%d", pin_num
++);
1559 CreateNewPin
(yyElement
, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME
,
1560 ($5 + 2*MASKFRAME
)*100, hole
, $6, p_number
, OldFlags
($7));
1565 /* %start-doc pcbfile Pad
1568 Pad [rX1 rY1 rX2 rY2 Thickness Clearance Mask "Name" "Number" SFlags]
1569 Pad (rX1 rY1 rX2 rY2 Thickness Clearance Mask "Name" "Number" NFlags)
1570 Pad (aX1 aY1 aX2 aY2 Thickness "Name" "Number" NFlags)
1571 Pad (aX1 aY1 aX2 aY2 Thickness "Name" NFlags)
1575 @item rX1 rY1 rX2 rY2
1576 Coordinates of the endpoints of the pad, relative to the element's
1577 mark. Note that the copper extends beyond these coordinates by half
1578 the thickness. To make a square or round pad, specify the same
1580 @item aX1 aY1 aX2 aY2
1581 Same, but absolute coordinates of the endpoints of the pad.
1585 add to thickness to get clearance width.
1587 width of solder mask opening.
1593 symbolic or numerical flags
1595 numerical flags only
1601 /* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */
1602 : T_PAD
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING flags
']'
1604 CreateNewPad
(yyElement
, $3 + yyElement
->MarkX
,
1605 $4 + yyElement
->MarkY
,
1606 $5 + yyElement
->MarkX
,
1607 $6 + yyElement
->MarkY
, $7, $8, $9,
1615 /* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */
1616 : T_PAD
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER
')'
1618 CreateNewPad
(yyElement
,$3*100 + yyElement
->MarkX
,
1619 $4*100 + yyElement
->MarkY
, $5*100 + yyElement
->MarkX
,
1620 $6*100 + yyElement
->MarkY
, $7*100, $8*100, $9*100,
1621 $10, $11, OldFlags
($12));
1628 /* x1, y1, x2, y2, thickness, name , pad number, flags */
1629 : T_PAD
'(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER
')'
1631 CreateNewPad
(yyElement
,$3*100,$4*100,$5*100,$6*100,$7*100, 200*GROUNDPLANEFRAME
,
1632 ($7 + 2*MASKFRAME
)*100, $8,$9, OldFlags
($10));
1639 /* x1, y1, x2, y2, thickness, name and flags */
1640 : T_PAD
'(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER
')'
1644 sprintf
(p_number
, "%d", pin_num
++);
1645 CreateNewPad
(yyElement
,$3*100,$4*100,$5*100,$6*100,$7*100, 200*GROUNDPLANEFRAME
,
1646 ($7 + 2*MASKFRAME
)*100, $8,p_number
, OldFlags
($9));
1651 flags
: NUMBER
{ $$
= OldFlags
($1); }
1652 | STRING
{ $$
= string_to_flags
($1, yyerror); }
1660 /* %start-doc pcbfile Symbol
1663 Symbol [Char Delta] (
1664 Symbol (Char Delta) (
1665 @ @ @ @dots{} symbol lines @dots{}
1671 The character or numerical character value this symbol represents.
1672 Characters must be in single quotes.
1674 Additional space to allow after this character.
1680 : T_SYMBOL
'[' symbolid NUMBER
']' '('
1682 if
($3 <= 0 ||
$3 > MAX_FONTPOSITION
)
1684 yyerror("fontposition out of range");
1687 Symbol
= &yyFont
->Symbol
[$3];
1690 yyerror("symbol ID used twice");
1693 Symbol
->Valid
= True
;
1697 | T_SYMBOL
'(' symbolid NUMBER
')' '('
1699 if
($3 <= 0 ||
$3 > MAX_FONTPOSITION
)
1701 yyerror("fontposition out of range");
1704 Symbol
= &yyFont
->Symbol
[$3];
1707 yyerror("symbol ID used twice");
1710 Symbol
->Valid
= True
;
1711 Symbol
->Delta
= $4*100;
1723 | symboldata symboldefinitions
1732 /* %start-doc pcbfile SymbolLine
1735 SymbolLine [X1 Y1 X2 Y1 Thickness]
1736 SymbolLine (X1 Y1 X2 Y1 Thickness)
1741 The endpoints of this line.
1743 The width of this line.
1749 /* x1, y1, x2, y2, thickness */
1750 : T_SYMBOLLINE
'(' NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1752 CreateNewLineInSymbol
(Symbol
, $3*100, $4*100, $5*100, $6*100, $7*100);
1756 /* x1, y1, x2, y2, thickness */
1757 : T_SYMBOLLINE
'[' NUMBER NUMBER NUMBER NUMBER NUMBER
']'
1759 CreateNewLineInSymbol
(Symbol
, $3, $4, $5, $6, $7);
1763 /* %start-doc pcbfile Netlist
1767 @ @ @ @dots{} nets @dots{}
1773 pcbnetlist
: pcbnetdef
1777 /* net(...) net(...) ... */
1778 : T_NETLIST
'(' ')' '('
1792 /* %start-doc pcbfile Net
1795 Net ("Name" "Style") (
1796 @ @ @ @dots{} connects @dots{}
1802 The name of this net.
1804 The routing style that should be used when autorouting this net.
1810 /* name style pin pin ... */
1811 : T_NET
'(' STRING STRING
')' '('
1813 Menu
= CreateNewNet
(&yyPCB
->NetlistLib
, $3, $4);
1830 /* %start-doc pcbfile Connect
1838 The name of a pin or pad which is included in this net. Pin and Pad
1839 names are named by the refdes and pin name, like @code{"U14-7"} for
1840 pin 7 of U14, or @code{"T4-E"} for pin E of T4.
1846 : T_CONN
'(' STRING
')'
1848 CreateNewConnection
(Menu
, $3);
1853 /* %start-doc pcbfile Attribute
1856 Attribute ("Name" "Value")
1859 Attributes allow boards and elements to have arbitrary data attached
1860 to them, which is not directly used by PCB itself but may be of use by
1861 other programs or users.
1865 The name of the attribute
1868 The value of the attribute. Values are always stored as strings, even
1869 if the value is interpreted as, for example, a number.
1875 attributes
: attribute
1876 | attributes attribute
1879 : T_ATTRIBUTE
'(' STRING STRING
')'
1881 CreateNewAttribute
(attr_list
, $3, $4);
1887 opt_string
: STRING
{ $$
= $1; }
1888 |
/* empty */ { $$
= 0; }
1893 /* ---------------------------------------------------------------------------
1894 * error routine called by parser library
1899 Message
("ERROR parsing file '%s'\n"
1901 " description: '%s'\n",
1902 yyfilename
, yylineno
, s
);
1913 check_file_version
(int ver
)
1915 if
( ver
> PCB_FILE_VERSION
) {
1916 Message
("ERROR: The file you are attempting to load is in a format\n"
1917 "which is too new for this version of pcb. To load this file\n"
1918 "you need a version of pcb which is >= %d. If you are\n"
1919 "using a version built from cvs sources, the source date\n"
1920 "must be >= %d. This copy of pcb can only read files\n"
1921 "up to file version %d.\n", ver
, ver
, PCB_FILE_VERSION
);