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 bool 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_POLYGON_HOLE T_NETLIST T_NET T_CONN
106 %token T_AREA T_THERMAL T_DRC T_ATTRIBUTE
107 %type
<number
> symbolid
108 %type
<string> opt_string
109 %type
<flagtype
> flags
120 /* %start-doc pcbfile 00pcb
124 A special note about units: Older versions of @code{pcb} used mils
125 (1/1000 inch) as the base unit; a value of 500 in the file meant
126 half an inch. Newer versions uses a "high resolution" syntax,
127 where the base unit is 1/100 of a mil (0.000010 inch); a value of 500 in
128 the file means 5 mils. As a general rule, the variants of each entry
129 listed below which use square brackets are the high resolution formats
130 and use the 1/100 mil units, and the ones with parentheses are the older
131 variants and use 1 mil units. Note that when multiple variants
132 are listed, the most recent (and most preferred) format is the first
135 Symbolic and numeric flags (SFlags and NFlags) are described in
142 /* reset flags for 'used layers';
143 * init font and data pointers
149 Message
("illegal fileformat\n");
152 for
(i
= 0; i
< MAX_LAYER
+ 2; i
++)
153 LayerFlag
[i
] = false
;
154 yyFont
= &yyPCB
->Font
;
155 yyData
= yyPCB
->Data
;
156 yyData
->pcb
= (void *)yyPCB
;
158 layer_group_string
= NULL
;
175 PCBTypePtr pcb_save
= PCB
;
177 if
(layer_group_string
== NULL
)
178 layer_group_string
= Settings.Groups
;
179 CreateNewPCBPost
(yyPCB
, 0);
180 if
(ParseGroupString
(layer_group_string
, &yyPCB
->LayerGroups
, yyData
->LayerN
))
182 Message
("illegal layer-group string\n");
185 /* initialize the polygon clipping now since
186 * we didn't know the layer grouping before.
189 for
(i
= 0; i
< yyData
->LayerN
+2; i
++)
190 for
(j
= 0; j
< yyData
->Layer
[i
].PolygonN
; j
++)
191 InitClip
(yyData
, &yyData
->Layer
[i
], &yyData
->Layer
[i
].Polygon
[j
]);
195 |
{ PreLoadElementPCB
();
196 layer_group_string
= NULL
; }
198 { LayerFlag
[0] = true
;
201 PostLoadElementPCB
();
207 /* reset flags for 'used layers';
208 * init font and data pointers
212 if
(!yyData ||
!yyFont
)
214 Message
("illegal fileformat\n");
217 for
(i
= 0; i
< MAX_LAYER
+ 2; i
++)
218 LayerFlag
[i
] = false
;
232 /* mark all symbols invalid */
237 Message
("illegal fileformat\n");
240 yyFont
->Valid
= false
;
241 for
(i
= 0; i
<= MAX_FONTPOSITION
; i
++)
242 yyFont
->Symbol
[i
].Valid
= false
;
246 yyFont
->Valid
= true
;
251 /* %start-doc pcbfile FileVersion
259 File format version. This version number represents the date when the pcb file
260 format was last changed.
263 Any version of pcb build from sources equal to or newer
264 than this number should be able to read the file. If this line is not present
265 in the input file then file format compatibility is not checked.
272 T_FILEVERSION
'[' NUMBER
']'
274 if
(check_file_version
($3) != 0)
281 /* %start-doc pcbfile PCB
284 PCB ["Name" Width Height]
285 PCB ("Name" Width Height]
291 Name of the PCB project
296 If you don't specify the size of the board, a very large default is
302 : T_PCB
'(' STRING
')'
305 yyPCB
->MaxWidth
= MAX_COORD
;
306 yyPCB
->MaxHeight
= MAX_COORD
;
308 | T_PCB
'(' STRING NUMBER NUMBER
')'
311 yyPCB
->MaxWidth
= $4*100;
312 yyPCB
->MaxHeight
= $5*100;
314 | T_PCB
'[' STRING NUMBER NUMBER
']'
317 yyPCB
->MaxWidth
= $4;
318 yyPCB
->MaxHeight
= $5;
322 /* %start-doc pcbfile Grid
325 Grid [Step OffsetX OffsetY Visible]
326 Grid (Step OffsetX OffsetY Visible)
327 Grid (Step OffsetX OffsetY)
332 Distance from one grid point to adjacent points. This value may be a
333 floating point number for the first two variants.
334 @item OffsetX OffsetY
335 The "origin" of the grid. Normally zero.
337 If non-zero, the grid will be visible on the screen.
349 : T_GRID
'(' NUMBER NUMBER NUMBER
')'
351 yyPCB
->Grid
= $3*100;
352 yyPCB
->GridOffsetX
= $4*100;
353 yyPCB
->GridOffsetY
= $5*100;
357 : T_GRID
'(' NUMBER NUMBER NUMBER NUMBER
')'
359 yyPCB
->Grid
= $3*100;
360 yyPCB
->GridOffsetX
= $4*100;
361 yyPCB
->GridOffsetY
= $5*100;
363 Settings.DrawGrid
= true
;
365 Settings.DrawGrid
= false
;
370 : T_GRID
'(' FLOAT NUMBER NUMBER NUMBER
')'
372 yyPCB
->Grid
= $3*100;
373 yyPCB
->GridOffsetX
= $4*100;
374 yyPCB
->GridOffsetY
= $5*100;
376 Settings.DrawGrid
= true
;
378 Settings.DrawGrid
= false
;
382 : T_GRID
'[' FLOAT NUMBER NUMBER NUMBER
']'
385 yyPCB
->GridOffsetX
= $4;
386 yyPCB
->GridOffsetY
= $5;
388 Settings.DrawGrid
= true
;
390 Settings.DrawGrid
= false
;
394 /* %start-doc pcbfile Cursor
403 Location of the cursor when the board was saved.
405 The current zoom factor. Note that a zoom factor of "0" means 1 mil
406 per screen pixel, N means @math{2^N} mils per screen pixel, etc. The
407 first variant accepts floating point numbers. The special value
408 "1000" means "zoom to fit"
414 : T_CURSOR
'(' NUMBER NUMBER NUMBER
')'
416 yyPCB
->CursorX
= $3*100;
417 yyPCB
->CursorY
= $4*100;
420 | T_CURSOR
'[' NUMBER NUMBER NUMBER
']'
426 | T_CURSOR
'[' NUMBER NUMBER FLOAT
']'
435 /* %start-doc pcbfile PolyArea
443 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.
450 | T_AREA
'[' FLOAT
']'
452 yyPCB
->IsleArea
= $3;
457 /* %start-doc pcbfile Thermal
465 Relative size of thermal fingers. A value of 1.0 makes the finger
466 width twice the clearance gap width (measured across the gap, not
467 diameter). The normal value is 0.5, which results in a finger width
468 the same as the clearance gap width.
476 | T_THERMAL
'[' FLOAT
']'
478 yyPCB
->ThermScale
= $3;
482 /* %start-doc pcbfile DRC
485 DRC [Bloat Shrink Line Silk Drill Ring]
486 DRC [Bloat Shrink Line Silk]
487 DRC [Bloat Shrink Line]
492 Minimum spacing between copper.
494 Minimum copper overlap to guarantee connectivity.
496 Minimum line thickness.
498 Minimum silk thickness.
502 Minimum width of the annular ring around pins and vias.
515 : T_DRC
'[' NUMBER NUMBER NUMBER
']'
525 : T_DRC
'[' NUMBER NUMBER NUMBER NUMBER
']'
536 : T_DRC
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
']'
542 yyPCB
->minDrill
= $7;
547 /* %start-doc pcbfile Flags
555 A number, whose value is normally given in hex, individual bits of which
556 represent pcb-wide flags as defined in @ref{PCBFlags}.
563 : T_FLAGS
'(' NUMBER
')'
565 yyPCB
->Flags
= MakeFlags
($3 & PCB_FLAGS
);
567 | T_FLAGS
'(' STRING
')'
569 yyPCB
->Flags
= string_to_pcbflags
($3, yyerror);
574 /* %start-doc pcbfile Groups
583 Encodes the layer grouping information. Each group is separated by a
584 colon, each member of each group is separated by a comma. Group
585 members are either numbers from @code{1}..@var{N} for each layer, and
586 the letters @code{c} or @code{s} representing the component side and
587 solder side of the board. Including @code{c} or @code{s} marks that
588 group as being the top or bottom side of the board.
591 Groups("1,2,c:3:4:5,6,s:7,8")
599 : T_GROUPS
'(' STRING
')'
601 layer_group_string
= $3;
606 /* %start-doc pcbfile Styles
615 Encodes the four routing styles @code{pcb} knows about. The four styles
616 are separated by colons. Each style consists of five parameters as follows:
620 The name of the style.
622 Width of lines and arcs.
624 Copper diameter of pins and vias.
626 Drill diameter of pins and vias.
628 Minimum spacing to other nets. If omitted, 10 mils is the default.
635 Styles("Signal,10,40,20:Power,25,60,35:Fat,40,60,35:Skinny,8,36,20")
636 Styles["Logic,1000,3600,2000,1000:Power,2500,6000,3500,1000:
637 @ @ @ Line,4000,6000,3500,1000:Breakout,600,2402,1181,600"]
641 Note that strings in actual files cannot span lines; the above example
642 is split across lines only to make it readable.
647 : T_STYLES
'(' STRING
')'
649 if
(ParseRouteString
($3, &yyPCB
->RouteStyle
[0], 100))
651 Message
("illegal route-style string\n");
655 | T_STYLES
'[' STRING
']'
657 if
(ParseRouteString
($3, &yyPCB
->RouteStyle
[0], 1))
659 Message
("illegal route-style string\n");
673 | pcbdefinitions pcbdefinition
678 |
{ attr_list
= & yyPCB
->Attributes
; } attributes
683 /* clear pointer to force memory allocation by
684 * the appropriate subroutine
700 /* %start-doc pcbfile Via
703 Via [X Y Thickness Clearance Mask Drill "Name" SFlags]
704 Via (X Y Thickness Clearance Mask Drill "Name" NFlags)
705 Via (X Y Thickness Clearance Drill "Name" NFlags)
706 Via (X Y Thickness Drill "Name" NFlags)
707 Via (X Y Thickness "Name" NFlags)
712 coordinates of center
714 outer diameter of copper annulus
716 add to thickness to get clearance diameter
718 diameter of solder mask opening
722 string, name of via (vias have names?)
724 symbolic or numerical flags
732 /* x, y, thickness, clearance, mask, drilling-hole, name, flags */
733 : T_VIA
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING flags
']'
735 CreateNewVia
(yyData
, $3, $4, $5, $6, $7, $8, $9, $10);
741 /* x, y, thickness, clearance, mask, drilling-hole, name, flags */
742 : T_VIA
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER
')'
744 CreateNewVia
(yyData
, $3*100, $4*100, $5*100, $6*100, $7*100, $8*100, $9,
752 /* x, y, thickness, clearance, drilling-hole, name, flags */
753 : T_VIA
'(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER
')'
755 CreateNewVia
(yyData
, $3*100, $4*100, $5*100, $6*100,
756 ($5 + $6)*100, $7*100, $8, OldFlags
($9));
762 /* x, y, thickness, drilling-hole, name, flags */
763 : T_VIA
'(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER
')'
765 CreateNewVia
(yyData
, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME
,
766 ($5 + 2*MASKFRAME
)*100, $6*100, $7, OldFlags
($8));
772 /* old format: x, y, thickness, name, flags */
773 : T_VIA
'(' NUMBER NUMBER NUMBER STRING NUMBER
')'
775 BDimension hole
= ($5 *DEFAULT_DRILLINGHOLE
);
777 /* make sure that there's enough copper left */
778 if
($5 -hole
< MIN_PINORVIACOPPER
&&
779 $5 > MIN_PINORVIACOPPER
)
780 hole
= $5 -MIN_PINORVIACOPPER
;
782 CreateNewVia
(yyData
, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME
,
783 ($5 + 2*MASKFRAME
)*100, hole
, $6, OldFlags
($7));
788 /* %start-doc pcbfile Rat
791 Rat [X1 Y1 Group1 X2 Y2 Group2 SFlags]
792 Rat (X1 Y1 Group1 X2 Y2 Group2 NFlags)
797 The endpoints of the rat line.
799 The layer group each end is connected on.
801 Symbolic or numeric flags.
809 : T_RAT
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags
']'
811 CreateNewRat
(yyData
, $3, $4, $6, $7, $5, $8,
812 Settings.RatThickness
, $9);
814 | T_RAT
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
816 CreateNewRat
(yyData
, $3*100, $4*100, $6*100, $7*100, $5, $8,
817 Settings.RatThickness
, OldFlags
($9));
821 /* %start-doc pcbfile Layer
824 Layer (LayerNum "Name") (
825 @ @ @ @dots{} contents @dots{}
831 The layer number. Layers are numbered sequentially, starting with 1.
832 The last two layers (9 and 10 by default) are solder-side silk and
833 component-side silk, in that order.
837 The contents of the layer, which may include attributes, lines, arcs, rectangles,
845 : T_LAYER
'(' NUMBER STRING opt_string
')' '('
847 if
($3 <= 0 ||
$3 > MAX_LAYER
+ 2)
849 yyerror("Layernumber out of range");
854 yyerror("Layernumber used twice");
857 Layer
= &yyData
->Layer
[$3-1];
859 /* memory for name is already allocated */
861 LayerFlag
[$3-1] = true
;
862 if
(yyData
->LayerN
+ 2 < $3)
863 yyData
->LayerN
= $3 - 2;
875 | layerdefinitions layerdefinition
885 /* x1, y1, x2, y2, flags */
886 | T_RECTANGLE
'(' NUMBER NUMBER NUMBER NUMBER NUMBER
')'
888 CreateNewPolygonFromRectangle
(Layer
,
889 $3*100, $4*100, ($3+$5)*100, ($4+$6)*100, OldFlags
($7));
894 |
{ attr_list
= & Layer
->Attributes
; } attributes
897 /* %start-doc pcbfile Line
900 Line [X1 Y1 X2 Y2 Thickness Clearance SFlags]
901 Line (X1 Y1 X2 Y2 Thickness Clearance NFlags)
902 Line (X1 Y1 X2 Y2 Thickness NFlags)
907 The end points of the line
909 The width of the line
911 The amount of space cleared around the line when the line passes
912 through a polygon. The clearance is added to the thickness to get the
913 thickness of the clear; thus the space between the line and the
914 polygon is @math{Clearance/2} wide.
916 Symbolic or numeric flags
924 /* x1, y1, x2, y2, thickness, clearance, flags */
925 : T_LINE
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags
']'
927 CreateNewLineOnLayer
(Layer
, $3, $4, $5, $6, $7, $8, $9);
932 /* x1, y1, x2, y2, thickness, clearance, flags */
933 : T_LINE
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
935 CreateNewLineOnLayer
(Layer
, $3*100, $4*100, $5*100, $6*100,
936 $7*100, $8*100, OldFlags
($9));
941 /* x1, y1, x2, y2, thickness, flags */
942 : T_LINE
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
944 /* eliminate old-style rat-lines */
945 if
(($8 & RATFLAG
) == 0)
946 CreateNewLineOnLayer
(Layer
, $3*100, $4*100, $5*100, $6*100, $7*100,
947 200*GROUNDPLANEFRAME
, OldFlags
($8));
951 /* %start-doc pcbfile Arc
954 Arc [X Y Width Height Thickness Clearance StartAngle DeltaAngle SFlags]
955 Arc (X Y Width Height Thickness Clearance StartAngle DeltaAngle NFlags)
956 Arc (X Y Width Height Thickness StartAngle DeltaAngle NFlags)
961 Coordinates of the center of the arc.
963 The width and height, from the center to the edge. The bounds of the
964 circle of which this arc is a segment, is thus @math{2*Width} by
967 The width of the copper trace which forms the arc.
969 The amount of space cleared around the arc when the line passes
970 through a polygon. The clearance is added to the thickness to get the
971 thickness of the clear; thus the space between the arc and the polygon
972 is @math{Clearance/2} wide.
974 The angle of one end of the arc, in degrees. In PCB, an angle of zero
975 points left (negative X direction), and 90 degrees points down
976 (positive Y direction).
978 The sweep of the arc. This may be negative. Positive angles sweep
981 Symbolic or numeric flags.
989 /* x, y, width, height, thickness, clearance, startangle, delta, flags */
990 : T_ARC
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags
']'
992 CreateNewArcOnLayer
(Layer
, $3, $4, $5, $6, $9, $10, $7, $8, $11);
997 /* x, y, width, height, thickness, clearance, startangle, delta, flags */
998 : T_ARC
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1000 CreateNewArcOnLayer
(Layer
, $3*100, $4*100, $5*100, $6*100, $9, $10,
1001 $7*100, $8*100, OldFlags
($11));
1006 /* x, y, width, height, thickness, startangle, delta, flags */
1007 : T_ARC
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1009 CreateNewArcOnLayer
(Layer
, $3*100, $4*100, $5*100, $5*100, $8, $9,
1010 $7*100, 200*GROUNDPLANEFRAME
, OldFlags
($10));
1014 /* %start-doc pcbfile Text
1017 Text [X Y Direction Scale "String" SFlags]
1018 Text (X Y Direction Scale "String" NFlags)
1019 Text (X Y Direction "String" NFlags)
1024 The location of the upper left corner of the text.
1026 0 means text is drawn left to right, 1 means up, 2 means right to left
1027 (i.e. upside down), and 3 means down.
1029 Size of the text, as a percentage of the ``default'' size of of the
1030 font (the default font is about 40 mils high). Default is 100 (40
1035 Symbolic or numeric flags.
1043 /* x, y, direction, text, flags */
1044 : T_TEXT
'(' NUMBER NUMBER NUMBER STRING NUMBER
')'
1046 /* use a default scale of 100% */
1047 CreateNewText
(Layer
,yyFont
,$3*100, $4*100, $5, 100, $6, OldFlags
($7));
1053 /* x, y, direction, scale, text, flags */
1054 : T_TEXT
'(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER
')'
1056 if
($8 & ONSILKFLAG
)
1058 LayerTypePtr lay
= &yyData
->Layer
[yyData
->LayerN
+
1059 (($8 & ONSOLDERFLAG
) ? SOLDER_LAYER
: COMPONENT_LAYER
)];
1061 CreateNewText
(lay
,yyFont
, $3*100, $4*100, $5, $6, $7,
1065 CreateNewText
(Layer
, yyFont
, $3*100, $4*100, $5, $6, $7,
1071 /* x, y, direction, scale, text, flags */
1072 : T_TEXT
'[' NUMBER NUMBER NUMBER NUMBER STRING flags
']'
1074 /* FIXME: shouldn't know about .f */
1075 /* I don't think this matters because anything with hi_format
1076 * will have the silk on its own layer in the file rather
1077 * than using the ONSILKFLAG and having it in a copper layer.
1078 * Thus there is no need for anything besides the 'else'
1079 * part of this code.
1081 if
($8.f
& ONSILKFLAG
)
1083 LayerTypePtr lay
= &yyData
->Layer
[yyData
->LayerN
+
1084 (($8.f
& ONSOLDERFLAG
) ? SOLDER_LAYER
: COMPONENT_LAYER
)];
1086 CreateNewText
(lay
, yyFont
, $3, $4, $5, $6, $7, $8);
1089 CreateNewText
(Layer
, yyFont
, $3, $4, $5, $6, $7, $8);
1094 /* %start-doc pcbfile Polygon
1098 @ @ @ @dots{} (X Y) @dots{}
1099 @ @ @ @dots{} [X Y] @dots{}
1101 @ @ @ @ @ @ @dots{} (X Y) @dots{}
1102 @ @ @ @ @ @ @dots{} [X Y] @dots{}
1110 Symbolic or numeric flags.
1112 Coordinates of each vertex. You must list at least three coordinates.
1114 Defines a hole within the polygon's outer contour. There may be zero or more such sections.
1120 : /* flags are passed in */
1121 T_POLYGON
'(' flags
')' '('
1123 Polygon
= CreateNewPolygon
(Layer
, $3);
1128 Cardinal contour
, contour_start
, contour_end
;
1129 bool bad_contour_found
= false
;
1131 for
(contour
= 0; contour
<= Polygon
->HoleIndexN
; contour
++)
1133 contour_start
= (contour
== 0) ?
1134 0 : Polygon
->HoleIndex
[contour
- 1];
1135 contour_end
= (contour
== Polygon
->HoleIndexN
) ?
1137 Polygon
->HoleIndex
[contour
];
1138 if
(contour_end
- contour_start
< 3)
1139 bad_contour_found
= true
;
1142 if
(bad_contour_found
)
1144 Message
("WARNING parsing file '%s'\n"
1146 " description: 'ignored polygon (< 3 points in a contour)'\n",
1147 yyfilename
, yylineno
);
1148 DestroyObject
(yyData
, POLYGON_TYPE
, Layer
, Polygon
, Polygon
);
1152 SetPolygonBoundingBox
(Polygon
);
1153 if
(!Layer
->polygon_tree
)
1154 Layer
->polygon_tree
= r_create_tree
(NULL
, 0, 0);
1155 r_insert_entry
(Layer
->polygon_tree
, (BoxType
*) Polygon
, 0);
1163 | polygonholes polygonhole
1167 : T_POLYGON_HOLE
'('
1169 CreateNewHoleInPolygon
(Polygon
);
1176 | polygonpoints polygonpoint
1181 : '(' NUMBER NUMBER
')'
1183 CreateNewPointInPolygon
(Polygon
, $2*100, $3*100);
1185 |
'[' NUMBER NUMBER
']'
1187 CreateNewPointInPolygon
(Polygon
, $2, $3);
1192 /* %start-doc pcbfile Element
1195 Element [SFlags "Desc" "Name" "Value" MX MY TX TY TDir TScale TSFlags] (
1196 Element (NFlags "Desc" "Name" "Value" MX MY TX TY TDir TScale TNFlags) (
1197 Element (NFlags "Desc" "Name" "Value" TX TY TDir TScale TNFlags) (
1198 Element (NFlags "Desc" "Name" TX TY TDir TScale TNFlags) (
1199 Element ("Desc" "Name" TX TY TDir TScale TNFlags) (
1200 @ @ @ @dots{} contents @dots{}
1206 Symbolic or numeric flags, for the element as a whole.
1208 Numeric flags, for the element as a whole.
1210 The description of the element. This is one of the three strings
1211 which can be displayed on the screen.
1213 The name of the element, usually the reference designator.
1215 The value of the element.
1217 The location of the element's mark. This is the reference point
1218 for placing the element and its pins and pads.
1220 The upper left corner of the text (one of the three strings).
1222 The relative direction of the text. 0 means left to right for
1223 an unrotated element, 1 means up, 2 left, 3 down.
1225 Size of the text, as a percentage of the ``default'' size of of the
1226 font (the default font is about 40 mils high). Default is 100 (40
1229 Symbolic or numeric flags, for the text.
1231 Numeric flags, for the text.
1234 Elements may contain pins, pads, element lines, element arcs,
1235 attributes, and (for older elements) an optional mark. Note that
1236 element definitions that have the mark coordinates in the element
1237 line, only support pins and pads which use relative coordinates. The
1238 pin and pad coordinates are relative to the mark. Element definitions
1239 which do not include the mark coordinates in the element line, may
1240 have a Mark definition in their contents, and only use pin and pad
1241 definitions which use absolute coordinates.
1247 | element_1.3
.4_format
1249 | element_1.7_format
1254 /* element_flags, description, pcb-name,
1255 * text_x, text_y, text_direction, text_scale, text_flags
1257 : T_ELEMENT
'(' STRING STRING NUMBER NUMBER NUMBER
')' '('
1259 yyElement
= CreateNewElement
(yyData
, yyElement
, yyFont
, NoFlags
(),
1260 $3, $4, NULL
, $5*100, $6*100, $7, 100, NoFlags
(), false
);
1265 elementdefinitions
')'
1267 SetElementBoundingBox
(yyData
, yyElement
, yyFont
);
1271 element_1.3
.4_format
1272 /* element_flags, description, pcb-name,
1273 * text_x, text_y, text_direction, text_scale, text_flags
1275 : T_ELEMENT
'(' NUMBER STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER
')' '('
1277 yyElement
= CreateNewElement
(yyData
, yyElement
, yyFont
, OldFlags
($3),
1278 $4, $5, NULL
, $6*100, $7*100, $8, $9, OldFlags
($10), false
);
1283 elementdefinitions
')'
1285 SetElementBoundingBox
(yyData
, yyElement
, yyFont
);
1290 /* element_flags, description, pcb-name, value,
1291 * text_x, text_y, text_direction, text_scale, text_flags
1293 : T_ELEMENT
'(' NUMBER STRING STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER
')' '('
1295 yyElement
= CreateNewElement
(yyData
, yyElement
, yyFont
, OldFlags
($3),
1296 $4, $5, $6, $7*100, $8*100, $9, $10, OldFlags
($11), false
);
1302 elementdefinitions
')'
1304 SetElementBoundingBox
(yyData
, yyElement
, yyFont
);
1309 /* element_flags, description, pcb-name, value, mark_x, mark_y,
1310 * text_x, text_y, text_direction, text_scale, text_flags
1312 : T_ELEMENT
'(' NUMBER STRING STRING STRING NUMBER NUMBER
1313 NUMBER NUMBER NUMBER NUMBER NUMBER
')' '('
1315 yyElement
= CreateNewElement
(yyData
, yyElement
, yyFont
, OldFlags
($3),
1316 $4, $5, $6, ($7+$9)*100, ($8+$10)*100, $11, $12, OldFlags
($13), false
);
1317 yyElement
->MarkX
= $7*100;
1318 yyElement
->MarkY
= $8*100;
1325 SetElementBoundingBox
(yyData
, yyElement
, yyFont
);
1330 /* element_flags, description, pcb-name, value, mark_x, mark_y,
1331 * text_x, text_y, text_direction, text_scale, text_flags
1333 : T_ELEMENT
'[' flags STRING STRING STRING NUMBER NUMBER
1334 NUMBER NUMBER NUMBER NUMBER flags
']' '('
1336 yyElement
= CreateNewElement
(yyData
, yyElement
, yyFont
, $3,
1337 $4, $5, $6, ($7+$9), ($8+$10), $11, $12, $13, false
);
1338 yyElement
->MarkX
= $7;
1339 yyElement
->MarkY
= $8;
1346 SetElementBoundingBox
(yyData
, yyElement
, yyFont
);
1350 /* %start-doc pcbfile ElementLine
1353 ElementLine [X1 Y1 X2 Y2 Thickness]
1354 ElementLine (X1 Y1 X2 Y2 Thickness)
1359 Coordinates of the endpoints of the line. These are relative to the
1360 Element's mark point for new element formats, or absolute for older
1363 The width of the silk for this line.
1368 /* %start-doc pcbfile ElementArc
1371 ElementArc [X Y Width Height StartAngle DeltaAngle Thickness]
1372 ElementArc (X Y Width Height StartAngle DeltaAngle Thickness)
1377 Coordinates of the center of the arc. These are relative to the
1378 Element's mark point for new element formats, or absolute for older
1381 The width and height, from the center to the edge. The bounds of the
1382 circle of which this arc is a segment, is thus @math{2*Width} by
1385 The angle of one end of the arc, in degrees. In PCB, an angle of zero
1386 points left (negative X direction), and 90 degrees points down
1387 (positive Y direction).
1389 The sweep of the arc. This may be negative. Positive angles sweep
1392 The width of the silk line which forms the arc.
1397 /* %start-doc pcbfile Mark
1406 Coordinates of the Mark, for older element formats that don't have
1407 the mark as part of the Element line.
1414 | elementdefinitions elementdefinition
1423 /* x1, y1, x2, y2, thickness */
1424 | T_ELEMENTLINE
'[' NUMBER NUMBER NUMBER NUMBER NUMBER
']'
1426 CreateNewLineInElement
(yyElement
, $3, $4, $5, $6, $7);
1428 /* x1, y1, x2, y2, thickness */
1429 | T_ELEMENTLINE
'(' NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1431 CreateNewLineInElement
(yyElement
, $3*100, $4*100, $5*100, $6*100, $7*100);
1433 /* x, y, width, height, startangle, anglediff, thickness */
1434 | T_ELEMENTARC
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
']'
1436 CreateNewArcInElement
(yyElement
, $3, $4, $5, $6, $7, $8, $9);
1438 /* x, y, width, height, startangle, anglediff, thickness */
1439 | T_ELEMENTARC
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1441 CreateNewArcInElement
(yyElement
, $3*100, $4*100, $5*100, $6*100, $7, $8, $9*100);
1444 | T_MARK
'[' NUMBER NUMBER
']'
1446 yyElement
->MarkX
= $3;
1447 yyElement
->MarkY
= $4;
1449 | T_MARK
'(' NUMBER NUMBER
')'
1451 yyElement
->MarkX
= $3*100;
1452 yyElement
->MarkY
= $4*100;
1454 |
{ attr_list
= & yyElement
->Attributes
; } attributes
1459 | relementdefs relementdef
1467 /* x1, y1, x2, y2, thickness */
1468 | T_ELEMENTLINE
'[' NUMBER NUMBER NUMBER NUMBER NUMBER
']'
1470 CreateNewLineInElement
(yyElement
, $3 + yyElement
->MarkX
,
1471 $4 + yyElement
->MarkY
, $5 + yyElement
->MarkX
,
1472 $6 + yyElement
->MarkY
, $7);
1474 | T_ELEMENTLINE
'(' NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1476 CreateNewLineInElement
(yyElement
, $3*100 + yyElement
->MarkX
,
1477 $4*100 + yyElement
->MarkY
, $5*100 + yyElement
->MarkX
,
1478 $6*100 + yyElement
->MarkY
, $7*100);
1480 /* x, y, width, height, startangle, anglediff, thickness */
1481 | T_ELEMENTARC
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
']'
1483 CreateNewArcInElement
(yyElement
, $3 + yyElement
->MarkX
,
1484 $4 + yyElement
->MarkY
, $5, $6, $7, $8, $9);
1486 | T_ELEMENTARC
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1488 CreateNewArcInElement
(yyElement
, $3*100 + yyElement
->MarkX
,
1489 $4*100 + yyElement
->MarkY
, $5*100, $6*100, $7, $8, $9*100);
1491 |
{ attr_list
= & yyElement
->Attributes
; } attributes
1494 /* %start-doc pcbfile Pin
1497 Pin [rX rY Thickness Clearance Mask Drill "Name" "Number" SFlags]
1498 Pin (rX rY Thickness Clearance Mask Drill "Name" "Number" NFlags)
1499 Pin (aX aY Thickness Drill "Name" "Number" NFlags)
1500 Pin (aX aY Thickness Drill "Name" NFlags)
1501 Pin (aX aY Thickness "Name" NFlags)
1506 coordinates of center, relative to the element's mark
1508 absolute coordinates of center.
1510 outer diameter of copper annulus
1512 add to thickness to get clearance diameter
1514 diameter of solder mask opening
1522 symbolic or numerical flags
1524 numerical flags only
1530 /* x, y, thickness, clearance, mask, drilling hole, name,
1532 : T_PIN
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING flags
']'
1534 CreateNewPin
(yyElement
, $3 + yyElement
->MarkX
,
1535 $4 + yyElement
->MarkY
, $5, $6, $7, $8, $9,
1542 /* x, y, thickness, clearance, mask, drilling hole, name,
1544 : T_PIN
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER
')'
1546 CreateNewPin
(yyElement
, $3*100 + yyElement
->MarkX
,
1547 $4*100 + yyElement
->MarkY
, $5*100, $6*100, $7*100, $8*100, $9,
1548 $10, OldFlags
($11));
1555 /* x, y, thickness, drilling hole, name, number, flags */
1556 : T_PIN
'(' NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER
')'
1558 CreateNewPin
(yyElement
, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME
,
1559 ($5 + 2*MASKFRAME
)*100, $6*100, $7, $8, OldFlags
($9));
1566 /* x, y, thickness, drilling hole, name, flags */
1567 : T_PIN
'(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER
')'
1571 sprintf
(p_number
, "%d", pin_num
++);
1572 CreateNewPin
(yyElement
, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME
,
1573 ($5 + 2*MASKFRAME
)*100, $6*100, $7, p_number
, OldFlags
($8));
1580 /* old format: x, y, thickness, name, flags
1581 * drilling hole is 40% of the diameter
1583 : T_PIN
'(' NUMBER NUMBER NUMBER STRING NUMBER
')'
1585 BDimension hole
= ($5 *DEFAULT_DRILLINGHOLE
);
1588 /* make sure that there's enough copper left */
1589 if
($5 -hole
< MIN_PINORVIACOPPER
&&
1590 $5 > MIN_PINORVIACOPPER
)
1591 hole
= $5 -MIN_PINORVIACOPPER
;
1593 sprintf
(p_number
, "%d", pin_num
++);
1594 CreateNewPin
(yyElement
, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME
,
1595 ($5 + 2*MASKFRAME
)*100, hole
, $6, p_number
, OldFlags
($7));
1600 /* %start-doc pcbfile Pad
1603 Pad [rX1 rY1 rX2 rY2 Thickness Clearance Mask "Name" "Number" SFlags]
1604 Pad (rX1 rY1 rX2 rY2 Thickness Clearance Mask "Name" "Number" NFlags)
1605 Pad (aX1 aY1 aX2 aY2 Thickness "Name" "Number" NFlags)
1606 Pad (aX1 aY1 aX2 aY2 Thickness "Name" NFlags)
1610 @item rX1 rY1 rX2 rY2
1611 Coordinates of the endpoints of the pad, relative to the element's
1612 mark. Note that the copper extends beyond these coordinates by half
1613 the thickness. To make a square or round pad, specify the same
1615 @item aX1 aY1 aX2 aY2
1616 Same, but absolute coordinates of the endpoints of the pad.
1620 add to thickness to get clearance width.
1622 width of solder mask opening.
1628 symbolic or numerical flags
1630 numerical flags only
1636 /* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */
1637 : T_PAD
'[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING flags
']'
1639 CreateNewPad
(yyElement
, $3 + yyElement
->MarkX
,
1640 $4 + yyElement
->MarkY
,
1641 $5 + yyElement
->MarkX
,
1642 $6 + yyElement
->MarkY
, $7, $8, $9,
1650 /* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */
1651 : T_PAD
'(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER
')'
1653 CreateNewPad
(yyElement
,$3*100 + yyElement
->MarkX
,
1654 $4*100 + yyElement
->MarkY
, $5*100 + yyElement
->MarkX
,
1655 $6*100 + yyElement
->MarkY
, $7*100, $8*100, $9*100,
1656 $10, $11, OldFlags
($12));
1663 /* x1, y1, x2, y2, thickness, name , pad number, flags */
1664 : T_PAD
'(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER
')'
1666 CreateNewPad
(yyElement
,$3*100,$4*100,$5*100,$6*100,$7*100, 200*GROUNDPLANEFRAME
,
1667 ($7 + 2*MASKFRAME
)*100, $8,$9, OldFlags
($10));
1674 /* x1, y1, x2, y2, thickness, name and flags */
1675 : T_PAD
'(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER
')'
1679 sprintf
(p_number
, "%d", pin_num
++);
1680 CreateNewPad
(yyElement
,$3*100,$4*100,$5*100,$6*100,$7*100, 200*GROUNDPLANEFRAME
,
1681 ($7 + 2*MASKFRAME
)*100, $8,p_number
, OldFlags
($9));
1686 flags
: NUMBER
{ $$
= OldFlags
($1); }
1687 | STRING
{ $$
= string_to_flags
($1, yyerror); }
1695 /* %start-doc pcbfile Symbol
1698 Symbol [Char Delta] (
1699 Symbol (Char Delta) (
1700 @ @ @ @dots{} symbol lines @dots{}
1706 The character or numerical character value this symbol represents.
1707 Characters must be in single quotes.
1709 Additional space to allow after this character.
1715 : T_SYMBOL
'[' symbolid NUMBER
']' '('
1717 if
($3 <= 0 ||
$3 > MAX_FONTPOSITION
)
1719 yyerror("fontposition out of range");
1722 Symbol
= &yyFont
->Symbol
[$3];
1725 yyerror("symbol ID used twice");
1728 Symbol
->Valid
= true
;
1732 | T_SYMBOL
'(' symbolid NUMBER
')' '('
1734 if
($3 <= 0 ||
$3 > MAX_FONTPOSITION
)
1736 yyerror("fontposition out of range");
1739 Symbol
= &yyFont
->Symbol
[$3];
1742 yyerror("symbol ID used twice");
1745 Symbol
->Valid
= true
;
1746 Symbol
->Delta
= $4*100;
1758 | symboldata symboldefinitions
1767 /* %start-doc pcbfile SymbolLine
1770 SymbolLine [X1 Y1 X2 Y1 Thickness]
1771 SymbolLine (X1 Y1 X2 Y1 Thickness)
1776 The endpoints of this line.
1778 The width of this line.
1784 /* x1, y1, x2, y2, thickness */
1785 : T_SYMBOLLINE
'(' NUMBER NUMBER NUMBER NUMBER NUMBER
')'
1787 CreateNewLineInSymbol
(Symbol
, $3*100, $4*100, $5*100, $6*100, $7*100);
1791 /* x1, y1, x2, y2, thickness */
1792 : T_SYMBOLLINE
'[' NUMBER NUMBER NUMBER NUMBER NUMBER
']'
1794 CreateNewLineInSymbol
(Symbol
, $3, $4, $5, $6, $7);
1798 /* %start-doc pcbfile Netlist
1802 @ @ @ @dots{} nets @dots{}
1808 pcbnetlist
: pcbnetdef
1812 /* net(...) net(...) ... */
1813 : T_NETLIST
'(' ')' '('
1827 /* %start-doc pcbfile Net
1830 Net ("Name" "Style") (
1831 @ @ @ @dots{} connects @dots{}
1837 The name of this net.
1839 The routing style that should be used when autorouting this net.
1845 /* name style pin pin ... */
1846 : T_NET
'(' STRING STRING
')' '('
1848 Menu
= CreateNewNet
(&yyPCB
->NetlistLib
, $3, $4);
1865 /* %start-doc pcbfile Connect
1873 The name of a pin or pad which is included in this net. Pin and Pad
1874 names are named by the refdes and pin name, like @code{"U14-7"} for
1875 pin 7 of U14, or @code{"T4-E"} for pin E of T4.
1881 : T_CONN
'(' STRING
')'
1883 CreateNewConnection
(Menu
, $3);
1888 /* %start-doc pcbfile Attribute
1891 Attribute ("Name" "Value")
1894 Attributes allow boards and elements to have arbitrary data attached
1895 to them, which is not directly used by PCB itself but may be of use by
1896 other programs or users.
1900 The name of the attribute
1903 The value of the attribute. Values are always stored as strings, even
1904 if the value is interpreted as, for example, a number.
1910 attributes
: attribute
1911 | attributes attribute
1914 : T_ATTRIBUTE
'(' STRING STRING
')'
1916 CreateNewAttribute
(attr_list
, $3, $4 ?
$4 : "");
1922 opt_string
: STRING
{ $$
= $1; }
1923 |
/* empty */ { $$
= 0; }
1928 /* ---------------------------------------------------------------------------
1929 * error routine called by parser library
1934 Message
("ERROR parsing file '%s'\n"
1936 " description: '%s'\n",
1937 yyfilename
, yylineno
, s
);
1948 check_file_version
(int ver
)
1950 if
( ver
> PCB_FILE_VERSION
) {
1951 Message
("ERROR: The file you are attempting to load is in a format\n"
1952 "which is too new for this version of pcb. To load this file\n"
1953 "you need a version of pcb which is >= %d. If you are\n"
1954 "using a version built from git source, the source date\n"
1955 "must be >= %d. This copy of pcb can only read files\n"
1956 "up to file version %d.\n", ver
, ver
, PCB_FILE_VERSION
);