Introduce POLYGONHOLE_MODE for creating holes in polygons
[geda-pcb/gde.git] / src / parse_y.y
bloba5b2d23529d18cd3b141afb3a320523bd081fde9
1 /* $Id$ */
2 /*
3 * ************************** README *******************
5 * If the file format is modified in any way, update
6 * PCB_FILE_VERSION in file.h
7 *
8 * ************************** README *******************
9 */
13 * COPYRIGHT
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
41 #ifdef HAVE_CONFIG_H
42 #include "config.h"
43 #endif
45 #define GRIDFIT(x,g) (int)(0.5 + (int)(((x)+(g)/2.)/(g))*(g))
46 #include "global.h"
47 #include "create.h"
48 #include "data.h"
49 #include "error.h"
50 #include "file.h"
51 #include "mymem.h"
52 #include "misc.h"
53 #include "parse_l.h"
54 #include "polygon.h"
55 #include "remove.h"
56 #include "rtree.h"
57 #include "strflags.h"
58 #include "thermal.h"
60 #ifdef HAVE_LIBDMALLOC
61 # include <dmalloc.h> /* see http://dmalloc.com */
62 #endif
64 RCSID("$Id$");
66 static LayerTypePtr Layer;
67 static PolygonTypePtr Polygon;
68 static SymbolTypePtr Symbol;
69 static int pin_num;
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);
86 int yylex();
87 static int check_file_version (int);
91 %union /* define YYSTACK type */
93 int number;
94 float floating;
95 char *string;
96 FlagType flagtype;
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
113 parse
114 : parsepcb
115 | parsedata
116 | parsefont
117 | error { YYABORT; }
120 /* %start-doc pcbfile 00pcb
121 @nodetype subsection
122 @nodename %s syntax
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
133 listed.
135 Symbolic and numeric flags (SFlags and NFlags) are described in
136 @ref{Object Flags}.
138 %end-doc */
140 parsepcb
142 /* reset flags for 'used layers';
143 * init font and data pointers
145 int i;
147 if (!yyPCB)
149 Message("illegal fileformat\n");
150 YYABORT;
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;
157 yyData->LayerN = 0;
158 layer_group_string = NULL;
160 pcbfileversion
161 pcbname
162 pcbgrid
163 pcbcursor
164 polyarea
165 pcbthermal
166 pcbdrc
167 pcbflags
168 pcbgroups
169 pcbstyles
170 pcbfont
171 pcbdata
172 pcbnetlist
174 int i, j;
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");
183 YYABORT;
185 /* initialize the polygon clipping now since
186 * we didn't know the layer grouping before.
188 PCB = yyPCB;
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]);
192 PCB = pcb_save;
195 | { PreLoadElementPCB ();
196 layer_group_string = NULL; }
197 element
198 { LayerFlag[0] = true;
199 LayerFlag[1] = true;
200 yyData->LayerN = 2;
201 PostLoadElementPCB ();
205 parsedata
207 /* reset flags for 'used layers';
208 * init font and data pointers
210 int i;
212 if (!yyData || !yyFont)
214 Message("illegal fileformat\n");
215 YYABORT;
217 for (i = 0; i < MAX_LAYER + 2; i++)
218 LayerFlag[i] = false;
219 yyData->LayerN = 0;
221 pcbdata
224 pcbfont
225 : parsefont
229 parsefont
232 /* mark all symbols invalid */
233 int i;
235 if (!yyFont)
237 Message("illegal fileformat\n");
238 YYABORT;
240 yyFont->Valid = false;
241 for (i = 0; i <= MAX_FONTPOSITION; i++)
242 yyFont->Symbol[i].Valid = false;
244 symbols
246 yyFont->Valid = true;
247 SetFontInfo(yyFont);
251 /* %start-doc pcbfile FileVersion
253 @syntax
254 FileVersion[Version]
255 @end syntax
257 @table @var
258 @item Version
259 File format version. This version number represents the date when the pcb file
260 format was last changed.
261 @end table
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.
268 %end-doc */
270 pcbfileversion
272 T_FILEVERSION '[' NUMBER ']'
274 if (check_file_version ($3) != 0)
276 YYABORT;
281 /* %start-doc pcbfile Grid
283 /* %start-doc pcbfile PCB
285 @syntax
286 PCB ["Name" Width Height]
287 PCB ("Name" Width Height]
288 PCB ("Name")
289 @end syntax
291 @table @var
292 @item Name
293 Name of the PCB project
294 @item Width Height
295 Size of the board
296 @end table
298 If you don't specify the size of the board, a very large default is
299 chosen.
301 %end-doc */
303 pcbname
304 : T_PCB '(' STRING ')'
306 yyPCB->Name = $3;
307 yyPCB->MaxWidth = MAX_COORD;
308 yyPCB->MaxHeight = MAX_COORD;
310 | T_PCB '(' STRING NUMBER NUMBER ')'
312 yyPCB->Name = $3;
313 yyPCB->MaxWidth = $4*100;
314 yyPCB->MaxHeight = $5*100;
316 | T_PCB '[' STRING NUMBER NUMBER ']'
318 yyPCB->Name = $3;
319 yyPCB->MaxWidth = $4;
320 yyPCB->MaxHeight = $5;
324 /* %start-doc pcbfile Grid
326 @syntax
327 Grid [Step OffsetX OffsetY Visible]
328 Grid (Step OffsetX OffsetY Visible)
329 Grid (Step OffsetX OffsetY)
330 @end syntax
332 @table @var
333 @item Step
334 Distance from one grid point to adjacent points. This value may be a
335 floating point number for the first two variants.
336 @item OffsetX OffsetY
337 The "origin" of the grid. Normally zero.
338 @item Visible
339 If non-zero, the grid will be visible on the screen.
340 @end table
342 %end-doc */
344 pcbgrid
345 : pcbgridold
346 | pcbgridnew
347 | pcb2grid
348 | pcbhigrid
350 pcbgridold
351 : T_GRID '(' NUMBER NUMBER NUMBER ')'
353 yyPCB->Grid = $3*100;
354 yyPCB->GridOffsetX = $4*100;
355 yyPCB->GridOffsetY = $5*100;
358 pcbgridnew
359 : T_GRID '(' NUMBER NUMBER NUMBER NUMBER ')'
361 yyPCB->Grid = $3*100;
362 yyPCB->GridOffsetX = $4*100;
363 yyPCB->GridOffsetY = $5*100;
364 if ($6)
365 Settings.DrawGrid = true;
366 else
367 Settings.DrawGrid = false;
371 pcb2grid
372 : T_GRID '(' FLOAT NUMBER NUMBER NUMBER ')'
374 yyPCB->Grid = $3*100;
375 yyPCB->GridOffsetX = $4*100;
376 yyPCB->GridOffsetY = $5*100;
377 if ($6)
378 Settings.DrawGrid = true;
379 else
380 Settings.DrawGrid = false;
383 pcbhigrid
384 : T_GRID '[' FLOAT NUMBER NUMBER NUMBER ']'
386 yyPCB->Grid = $3;
387 yyPCB->GridOffsetX = $4;
388 yyPCB->GridOffsetY = $5;
389 if ($6)
390 Settings.DrawGrid = true;
391 else
392 Settings.DrawGrid = false;
396 /* %start-doc pcbfile Cursor
398 @syntax
399 Cursor [X Y Zoom]
400 Cursor (X Y Zoom)
401 @end syntax
403 @table @var
404 @item X Y
405 Location of the cursor when the board was saved.
406 @item Zoom
407 The current zoom factor. Note that a zoom factor of "0" means 1 mil
408 per screen pixel, N means @math{2^N} mils per screen pixel, etc. The
409 first variant accepts floating point numbers. The special value
410 "1000" means "zoom to fit"
411 @end table
413 %end-doc */
415 pcbcursor
416 : T_CURSOR '(' NUMBER NUMBER NUMBER ')'
418 yyPCB->CursorX = $3*100;
419 yyPCB->CursorY = $4*100;
420 yyPCB->Zoom = $5*2;
422 | T_CURSOR '[' NUMBER NUMBER NUMBER ']'
424 yyPCB->CursorX = $3;
425 yyPCB->CursorY = $4;
426 yyPCB->Zoom = $5;
428 | T_CURSOR '[' NUMBER NUMBER FLOAT ']'
430 yyPCB->CursorX = $3;
431 yyPCB->CursorY = $4;
432 yyPCB->Zoom = $5;
437 /* %start-doc pcbfile PolyArea
439 @syntax
440 PolyArea [Area]
441 @end syntax
443 @table @var
444 @item Area
445 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.
446 @end table
448 %end-doc */
450 polyarea
452 | T_AREA '[' FLOAT ']'
454 yyPCB->IsleArea = $3;
459 /* %start-doc pcbfile Thermal
461 @syntax
462 Thermal [Scale]
463 @end syntax
465 @table @var
466 @item Scale
467 Relative size of thermal fingers. A value of 1.0 makes the finger
468 width twice the clearance gap width (measured across the gap, not
469 diameter). The normal value is 0.5, which results in a finger width
470 the same as the clearance gap width.
471 @end table
473 %end-doc */
476 pcbthermal
478 | T_THERMAL '[' FLOAT ']'
480 yyPCB->ThermScale = $3;
484 /* %start-doc pcbfile DRC
486 @syntax
487 DRC [Bloat Shrink Line Silk Drill Ring]
488 DRC [Bloat Shrink Line Silk]
489 DRC [Bloat Shrink Line]
490 @end syntax
492 @table @var
493 @item Bloat
494 Minimum spacing between copper.
495 @item Shrink
496 Minimum copper overlap to guarantee connectivity.
497 @item Line
498 Minimum line thickness.
499 @item Silk
500 Minimum silk thickness.
501 @item Drill
502 Minimum drill size.
503 @item Ring
504 Minimum width of the annular ring around pins and vias.
505 @end table
507 %end-doc */
509 pcbdrc
511 | pcbdrc1
512 | pcbdrc2
513 | pcbdrc3
516 pcbdrc1
517 : T_DRC '[' NUMBER NUMBER NUMBER ']'
519 yyPCB->Bloat = $3;
520 yyPCB->Shrink = $4;
521 yyPCB->minWid = $5;
522 yyPCB->minRing = $5;
526 pcbdrc2
527 : T_DRC '[' NUMBER NUMBER NUMBER NUMBER ']'
529 yyPCB->Bloat = $3;
530 yyPCB->Shrink = $4;
531 yyPCB->minWid = $5;
532 yyPCB->minSlk = $6;
533 yyPCB->minRing = $5;
537 pcbdrc3
538 : T_DRC '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ']'
540 yyPCB->Bloat = $3;
541 yyPCB->Shrink = $4;
542 yyPCB->minWid = $5;
543 yyPCB->minSlk = $6;
544 yyPCB->minDrill = $7;
545 yyPCB->minRing = $8;
549 /* %start-doc pcbfile Flags
551 @syntax
552 Flags(Number)
553 @end syntax
555 @table @var
556 @item Number
557 A number, whose value is normally given in hex, individual bits of which
558 represent pcb-wide flags as defined in @ref{PCBFlags}.
560 @end table
562 %end-doc */
564 pcbflags
565 : T_FLAGS '(' NUMBER ')'
567 yyPCB->Flags = MakeFlags ($3 & PCB_FLAGS);
569 | T_FLAGS '(' STRING ')'
571 yyPCB->Flags = string_to_pcbflags ($3, yyerror);
576 /* %start-doc pcbfile Groups
578 @syntax
579 Groups("String")
580 @end syntax
582 @table @var
583 @item String
585 Encodes the layer grouping information. Each group is separated by a
586 colon, each member of each group is separated by a comma. Group
587 members are either numbers from @code{1}..@var{N} for each layer, and
588 the letters @code{c} or @code{s} representing the component side and
589 solder side of the board. Including @code{c} or @code{s} marks that
590 group as being the top or bottom side of the board.
592 @example
593 Groups("1,2,c:3:4:5,6,s:7,8")
594 @end example
596 @end table
598 %end-doc */
600 pcbgroups
601 : T_GROUPS '(' STRING ')'
603 layer_group_string = $3;
608 /* %start-doc pcbfile Styles
610 @syntax
611 Styles("String")
612 @end syntax
614 @table @var
615 @item String
617 Encodes the four routing styles @code{pcb} knows about. The four styles
618 are separated by colons. Each style consists of five parameters as follows:
620 @table @var
621 @item Name
622 The name of the style.
623 @item Thickness
624 Width of lines and arcs.
625 @item Diameter
626 Copper diameter of pins and vias.
627 @item Drill
628 Drill diameter of pins and vias.
629 @item Keepaway
630 Minimum spacing to other nets. If omitted, 10 mils is the default.
632 @end table
634 @end table
636 @example
637 Styles("Signal,10,40,20:Power,25,60,35:Fat,40,60,35:Skinny,8,36,20")
638 Styles["Logic,1000,3600,2000,1000:Power,2500,6000,3500,1000:
639 @ @ @ Line,4000,6000,3500,1000:Breakout,600,2402,1181,600"]
640 @end example
642 @noindent
643 Note that strings in actual files cannot span lines; the above example
644 is split across lines only to make it readable.
646 %end-doc */
648 pcbstyles
649 : T_STYLES '(' STRING ')'
651 if (ParseRouteString($3, &yyPCB->RouteStyle[0], 100))
653 Message("illegal route-style string\n");
654 YYABORT;
657 | T_STYLES '[' STRING ']'
659 if (ParseRouteString($3, &yyPCB->RouteStyle[0], 1))
661 Message("illegal route-style string\n");
662 YYABORT;
668 pcbdata
669 : pcbdefinitions
673 pcbdefinitions
674 : pcbdefinition
675 | pcbdefinitions pcbdefinition
678 pcbdefinition
679 : via
680 | { attr_list = & yyPCB->Attributes; } attributes
681 | rats
682 | layer
685 /* clear pointer to force memory allocation by
686 * the appropriate subroutine
688 yyElement = NULL;
690 element
691 | error { YYABORT; }
695 : via_hi_format
696 | via_2.0_format
697 | via_1.7_format
698 | via_newformat
699 | via_oldformat
702 /* %start-doc pcbfile Via
704 @syntax
705 Via [X Y Thickness Clearance Mask Drill "Name" SFlags]
706 Via (X Y Thickness Clearance Mask Drill "Name" NFlags)
707 Via (X Y Thickness Clearance Drill "Name" NFlags)
708 Via (X Y Thickness Drill "Name" NFlags)
709 Via (X Y Thickness "Name" NFlags)
710 @end syntax
712 @table @var
713 @item X Y
714 coordinates of center
715 @item Thickness
716 outer diameter of copper annulus
717 @item Clearance
718 add to thickness to get clearance diameter
719 @item Mask
720 diameter of solder mask opening
721 @item Drill
722 diameter of drill
723 @item Name
724 string, name of via (vias have names?)
725 @item SFlags
726 symbolic or numerical flags
727 @item NFlags
728 numerical flags only
729 @end table
731 %end-doc */
733 via_hi_format
734 /* x, y, thickness, clearance, mask, drilling-hole, name, flags */
735 : T_VIA '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING flags ']'
737 CreateNewVia(yyData, $3, $4, $5, $6, $7, $8, $9, $10);
738 SaveFree($9);
742 via_2.0_format
743 /* x, y, thickness, clearance, mask, drilling-hole, name, flags */
744 : T_VIA '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
746 CreateNewVia(yyData, $3*100, $4*100, $5*100, $6*100, $7*100, $8*100, $9,
747 OldFlags($10));
748 SaveFree($9);
753 via_1.7_format
754 /* x, y, thickness, clearance, drilling-hole, name, flags */
755 : T_VIA '(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
757 CreateNewVia(yyData, $3*100, $4*100, $5*100, $6*100,
758 ($5 + $6)*100, $7*100, $8, OldFlags($9));
759 SaveFree($8);
763 via_newformat
764 /* x, y, thickness, drilling-hole, name, flags */
765 : T_VIA '(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
767 CreateNewVia(yyData, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
768 ($5 + 2*MASKFRAME)*100, $6*100, $7, OldFlags($8));
769 SaveFree($7);
773 via_oldformat
774 /* old format: x, y, thickness, name, flags */
775 : T_VIA '(' NUMBER NUMBER NUMBER STRING NUMBER ')'
777 BDimension hole = ($5 *DEFAULT_DRILLINGHOLE);
779 /* make sure that there's enough copper left */
780 if ($5 -hole < MIN_PINORVIACOPPER &&
781 $5 > MIN_PINORVIACOPPER)
782 hole = $5 -MIN_PINORVIACOPPER;
784 CreateNewVia(yyData, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
785 ($5 + 2*MASKFRAME)*100, hole, $6, OldFlags($7));
786 SaveFree($6);
790 /* %start-doc pcbfile Rat
792 @syntax
793 Rat [X1 Y1 Group1 X2 Y2 Group2 SFlags]
794 Rat (X1 Y1 Group1 X2 Y2 Group2 NFlags)
795 @end syntax
797 @table @var
798 @item X1 Y1 X2 Y2
799 The endpoints of the rat line.
800 @item Group1 Group2
801 The layer group each end is connected on.
802 @item SFlags
803 Symbolic or numeric flags.
804 @item NFlags
805 Numeric flags.
806 @end table
808 %end-doc */
810 rats
811 : T_RAT '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags ']'
813 CreateNewRat(yyData, $3, $4, $6, $7, $5, $8,
814 Settings.RatThickness, $9);
816 | T_RAT '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
818 CreateNewRat(yyData, $3*100, $4*100, $6*100, $7*100, $5, $8,
819 Settings.RatThickness, OldFlags($9));
823 /* %start-doc pcbfile Layer
825 @syntax
826 Layer (LayerNum "Name") (
827 @ @ @ @dots{} contents @dots{}
829 @end syntax
831 @table @var
832 @item LayerNum
833 The layer number. Layers are numbered sequentially, starting with 1.
834 The last two layers (9 and 10 by default) are solder-side silk and
835 component-side silk, in that order.
836 @item Name
837 The layer name.
838 @item contents
839 The contents of the layer, which may include attributes, lines, arcs, rectangles,
840 text, and polygons.
841 @end table
843 %end-doc */
845 layer
846 /* name */
847 : T_LAYER '(' NUMBER STRING opt_string ')' '('
849 if ($3 <= 0 || $3 > MAX_LAYER + 2)
851 yyerror("Layernumber out of range");
852 YYABORT;
854 if (LayerFlag[$3-1])
856 yyerror("Layernumber used twice");
857 YYABORT;
859 Layer = &yyData->Layer[$3-1];
861 /* memory for name is already allocated */
862 Layer->Name = $4;
863 LayerFlag[$3-1] = true;
864 if (yyData->LayerN + 2 < $3)
865 yyData->LayerN = $3 - 2;
867 layerdata ')'
870 layerdata
871 : layerdefinitions
875 layerdefinitions
876 : layerdefinition
877 | layerdefinitions layerdefinition
880 layerdefinition
881 : line_hi_format
882 | line_1.7_format
883 | line_oldformat
884 | arc_hi_format
885 | arc_1.7_format
886 | arc_oldformat
887 /* x1, y1, x2, y2, flags */
888 | T_RECTANGLE '(' NUMBER NUMBER NUMBER NUMBER NUMBER ')'
890 CreateNewPolygonFromRectangle(Layer,
891 $3*100, $4*100, ($3+$5)*100, ($4+$6)*100, OldFlags($7));
893 | text_hi_format
894 | text_newformat
895 | text_oldformat
896 | { attr_list = & Layer->Attributes; } attributes
897 | polygon_format
899 /* %start-doc pcbfile Line
901 @syntax
902 Line [X1 Y1 X2 Y2 Thickness Clearance SFlags]
903 Line (X1 Y1 X2 Y2 Thickness Clearance NFlags)
904 Line (X1 Y1 X2 Y2 Thickness NFlags)
905 @end syntax
907 @table @var
908 @item X1 Y1 X2 Y2
909 The end points of the line
910 @item Thickness
911 The width of the line
912 @item Clearance
913 The amount of space cleared around the line when the line passes
914 through a polygon. The clearance is added to the thickness to get the
915 thickness of the clear; thus the space between the line and the
916 polygon is @math{Clearance/2} wide.
917 @item SFlags
918 Symbolic or numeric flags
919 @item NFlags
920 Numeric flags.
921 @end table
923 %end-doc */
925 line_hi_format
926 /* x1, y1, x2, y2, thickness, clearance, flags */
927 : T_LINE '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags ']'
929 CreateNewLineOnLayer(Layer, $3, $4, $5, $6, $7, $8, $9);
933 line_1.7_format
934 /* x1, y1, x2, y2, thickness, clearance, flags */
935 : T_LINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
937 CreateNewLineOnLayer(Layer, $3*100, $4*100, $5*100, $6*100,
938 $7*100, $8*100, OldFlags($9));
942 line_oldformat
943 /* x1, y1, x2, y2, thickness, flags */
944 : T_LINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
946 /* eliminate old-style rat-lines */
947 if (($8 & RATFLAG) == 0)
948 CreateNewLineOnLayer(Layer, $3*100, $4*100, $5*100, $6*100, $7*100,
949 200*GROUNDPLANEFRAME, OldFlags($8));
953 /* %start-doc pcbfile Arc
955 @syntax
956 Arc [X Y Width Height Thickness Clearance StartAngle DeltaAngle SFlags]
957 Arc (X Y Width Height Thickness Clearance StartAngle DeltaAngle NFlags)
958 Arc (X Y Width Height Thickness StartAngle DeltaAngle NFlags)
959 @end syntax
961 @table @var
962 @item X Y
963 Coordinates of the center of the arc.
964 @item Width Height
965 The width and height, from the center to the edge. The bounds of the
966 circle of which this arc is a segment, is thus @math{2*Width} by
967 @math{2*Height}.
968 @item Thickness
969 The width of the copper trace which forms the arc.
970 @item Clearance
971 The amount of space cleared around the arc when the line passes
972 through a polygon. The clearance is added to the thickness to get the
973 thickness of the clear; thus the space between the arc and the polygon
974 is @math{Clearance/2} wide.
975 @item StartAngle
976 The angle of one end of the arc, in degrees. In PCB, an angle of zero
977 points left (negative X direction), and 90 degrees points down
978 (positive Y direction).
979 @item DeltaAngle
980 The sweep of the arc. This may be negative. Positive angles sweep
981 counterclockwise.
982 @item SFlags
983 Symbolic or numeric flags.
984 @item NFlags
985 Numeric flags.
986 @end table
988 %end-doc */
990 arc_hi_format
991 /* x, y, width, height, thickness, clearance, startangle, delta, flags */
992 : T_ARC '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags ']'
994 CreateNewArcOnLayer(Layer, $3, $4, $5, $6, $9, $10, $7, $8, $11);
998 arc_1.7_format
999 /* x, y, width, height, thickness, clearance, startangle, delta, flags */
1000 : T_ARC '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1002 CreateNewArcOnLayer(Layer, $3*100, $4*100, $5*100, $6*100, $9, $10,
1003 $7*100, $8*100, OldFlags($11));
1007 arc_oldformat
1008 /* x, y, width, height, thickness, startangle, delta, flags */
1009 : T_ARC '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1011 CreateNewArcOnLayer(Layer, $3*100, $4*100, $5*100, $5*100, $8, $9,
1012 $7*100, 200*GROUNDPLANEFRAME, OldFlags($10));
1016 /* %start-doc pcbfile Text
1018 @syntax
1019 Text [X Y Direction Scale "String" SFlags]
1020 Text (X Y Direction Scale "String" NFlags)
1021 Text (X Y Direction "String" NFlags)
1022 @end syntax
1024 @table @var
1025 @item X Y
1026 The location of the upper left corner of the text.
1027 @item Direction
1028 0 means text is drawn left to right, 1 means up, 2 means right to left
1029 (i.e. upside down), and 3 means down.
1030 @item Scale
1031 Size of the text, as a percentage of the ``default'' size of of the
1032 font (the default font is about 40 mils high). Default is 100 (40
1033 mils).
1034 @item String
1035 The string to draw.
1036 @item SFlags
1037 Symbolic or numeric flags.
1038 @item NFlags
1039 Numeric flags.
1040 @end table
1042 %end-doc */
1044 text_oldformat
1045 /* x, y, direction, text, flags */
1046 : T_TEXT '(' NUMBER NUMBER NUMBER STRING NUMBER ')'
1048 /* use a default scale of 100% */
1049 CreateNewText(Layer,yyFont,$3*100, $4*100, $5, 100, $6, OldFlags($7));
1050 SaveFree($6);
1054 text_newformat
1055 /* x, y, direction, scale, text, flags */
1056 : T_TEXT '(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
1058 if ($8 & ONSILKFLAG)
1060 LayerTypePtr lay = &yyData->Layer[yyData->LayerN +
1061 (($8 & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)];
1063 CreateNewText(lay ,yyFont, $3*100, $4*100, $5, $6, $7,
1064 OldFlags($8));
1066 else
1067 CreateNewText(Layer, yyFont, $3*100, $4*100, $5, $6, $7,
1068 OldFlags($8));
1069 SaveFree($7);
1072 text_hi_format
1073 /* x, y, direction, scale, text, flags */
1074 : T_TEXT '[' NUMBER NUMBER NUMBER NUMBER STRING flags ']'
1076 /* FIXME: shouldn't know about .f */
1077 /* I don't think this matters because anything with hi_format
1078 * will have the silk on its own layer in the file rather
1079 * than using the ONSILKFLAG and having it in a copper layer.
1080 * Thus there is no need for anything besides the 'else'
1081 * part of this code.
1083 if ($8.f & ONSILKFLAG)
1085 LayerTypePtr lay = &yyData->Layer[yyData->LayerN +
1086 (($8.f & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)];
1088 CreateNewText(lay, yyFont, $3, $4, $5, $6, $7, $8);
1090 else
1091 CreateNewText(Layer, yyFont, $3, $4, $5, $6, $7, $8);
1092 SaveFree($7);
1096 /* %start-doc pcbfile Polygon
1098 @syntax
1099 Polygon (SFlags) (
1100 @ @ @ @dots{} (X Y) @dots{}
1101 @ @ @ @dots{} [X Y] @dots{}
1102 @ @ @ Hole (
1103 @ @ @ @ @ @ @dots{} (X Y) @dots{}
1104 @ @ @ @ @ @ @dots{} [X Y] @dots{}
1105 @ @ @ )
1106 @ @ @ @dots{}
1108 @end syntax
1110 @table @var
1111 @item SFlags
1112 Symbolic or numeric flags.
1113 @item X Y
1114 Coordinates of each vertex. You must list at least three coordinates.
1115 @item Hole (...)
1116 Defines a hole within the polygon's outer contour. There may be zero or more such sections.
1117 @end table
1119 %end-doc */
1121 polygon_format
1122 : /* flags are passed in */
1123 T_POLYGON '(' flags ')' '('
1125 Polygon = CreateNewPolygon(Layer, $3);
1127 polygonpoints
1128 polygonholes ')'
1130 Cardinal contour, contour_start, contour_end;
1131 bool bad_contour_found = false;
1132 /* ignore junk */
1133 for (contour = 0; contour <= Polygon->HoleIndexN; contour++)
1135 contour_start = (contour == 0) ?
1136 0 : Polygon->HoleIndex[contour - 1];
1137 contour_end = (contour == Polygon->HoleIndexN) ?
1138 Polygon->PointN :
1139 Polygon->HoleIndex[contour];
1140 if (contour_end - contour_start < 3)
1141 bad_contour_found = true;
1144 if (bad_contour_found)
1146 Message("WARNING parsing file '%s'\n"
1147 " line: %i\n"
1148 " description: 'ignored polygon (< 3 points in a contour)'\n",
1149 yyfilename, yylineno);
1150 DestroyObject(yyData, POLYGON_TYPE, Layer, Polygon, Polygon);
1152 else
1154 SetPolygonBoundingBox (Polygon);
1155 if (!Layer->polygon_tree)
1156 Layer->polygon_tree = r_create_tree (NULL, 0, 0);
1157 r_insert_entry (Layer->polygon_tree, (BoxType *) Polygon, 0);
1162 polygonholes
1163 : /* empty */
1164 | polygonhole
1165 | polygonholes polygonhole
1168 polygonhole
1169 : T_POLYGON_HOLE '('
1171 CreateNewHoleInPolygon (Polygon);
1173 polygonpoints ')'
1176 polygonpoints
1177 : polygonpoint
1178 | polygonpoints polygonpoint
1181 polygonpoint
1182 /* xcoord ycoord */
1183 : '(' NUMBER NUMBER ')'
1185 CreateNewPointInPolygon(Polygon, $2*100, $3*100);
1187 | '[' NUMBER NUMBER ']'
1189 CreateNewPointInPolygon(Polygon, $2, $3);
1194 /* %start-doc pcbfile Element
1196 @syntax
1197 Element [SFlags "Desc" "Name" "Value" MX MY TX TY TDir TScale TSFlags] (
1198 Element (NFlags "Desc" "Name" "Value" MX MY TX TY TDir TScale TNFlags) (
1199 Element (NFlags "Desc" "Name" "Value" TX TY TDir TScale TNFlags) (
1200 Element (NFlags "Desc" "Name" TX TY TDir TScale TNFlags) (
1201 Element ("Desc" "Name" TX TY TDir TScale TNFlags) (
1202 @ @ @ @dots{} contents @dots{}
1204 @end syntax
1206 @table @var
1207 @item SFlags
1208 Symbolic or numeric flags, for the element as a whole.
1209 @item NFlags
1210 Numeric flags, for the element as a whole.
1211 @item Desc
1212 The description of the element. This is one of the three strings
1213 which can be displayed on the screen.
1214 @item Name
1215 The name of the element, usually the reference designator.
1216 @item Value
1217 The value of the element.
1218 @item MX MY
1219 The location of the element's mark. This is the reference point
1220 for placing the element and its pins and pads.
1221 @item TX TY
1222 The upper left corner of the text (one of the three strings).
1223 @item TDir
1224 The relative direction of the text. 0 means left to right for
1225 an unrotated element, 1 means up, 2 left, 3 down.
1226 @item TScale
1227 Size of the text, as a percentage of the ``default'' size of of the
1228 font (the default font is about 40 mils high). Default is 100 (40
1229 mils).
1230 @item TSFlags
1231 Symbolic or numeric flags, for the text.
1232 @item TNFlags
1233 Numeric flags, for the text.
1234 @end table
1236 Elements may contain pins, pads, element lines, element arcs,
1237 attributes, and (for older elements) an optional mark. Note that
1238 element definitions that have the mark coordinates in the element
1239 line, only support pins and pads which use relative coordinates. The
1240 pin and pad coordinates are relative to the mark. Element definitions
1241 which do not include the mark coordinates in the element line, may
1242 have a Mark definition in their contents, and only use pin and pad
1243 definitions which use absolute coordinates.
1245 %end-doc */
1247 element
1248 : element_oldformat
1249 | element_1.3.4_format
1250 | element_newformat
1251 | element_1.7_format
1252 | element_hi_format
1255 element_oldformat
1256 /* element_flags, description, pcb-name,
1257 * text_x, text_y, text_direction, text_scale, text_flags
1259 : T_ELEMENT '(' STRING STRING NUMBER NUMBER NUMBER ')' '('
1261 yyElement = CreateNewElement(yyData, yyElement, yyFont, NoFlags(),
1262 $3, $4, NULL, $5*100, $6*100, $7, 100, NoFlags(), false);
1263 SaveFree($3);
1264 SaveFree($4);
1265 pin_num = 1;
1267 elementdefinitions ')'
1269 SetElementBoundingBox(yyData, yyElement, yyFont);
1273 element_1.3.4_format
1274 /* element_flags, description, pcb-name,
1275 * text_x, text_y, text_direction, text_scale, text_flags
1277 : T_ELEMENT '(' NUMBER STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER ')' '('
1279 yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3),
1280 $4, $5, NULL, $6*100, $7*100, $8, $9, OldFlags($10), false);
1281 SaveFree($4);
1282 SaveFree($5);
1283 pin_num = 1;
1285 elementdefinitions ')'
1287 SetElementBoundingBox(yyData, yyElement, yyFont);
1291 element_newformat
1292 /* element_flags, description, pcb-name, value,
1293 * text_x, text_y, text_direction, text_scale, text_flags
1295 : T_ELEMENT '(' NUMBER STRING STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER ')' '('
1297 yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3),
1298 $4, $5, $6, $7*100, $8*100, $9, $10, OldFlags($11), false);
1299 SaveFree($4);
1300 SaveFree($5);
1301 SaveFree($6);
1302 pin_num = 1;
1304 elementdefinitions ')'
1306 SetElementBoundingBox(yyData, yyElement, yyFont);
1310 element_1.7_format
1311 /* element_flags, description, pcb-name, value, mark_x, mark_y,
1312 * text_x, text_y, text_direction, text_scale, text_flags
1314 : T_ELEMENT '(' NUMBER STRING STRING STRING NUMBER NUMBER
1315 NUMBER NUMBER NUMBER NUMBER NUMBER ')' '('
1317 yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3),
1318 $4, $5, $6, ($7+$9)*100, ($8+$10)*100, $11, $12, OldFlags($13), false);
1319 yyElement->MarkX = $7*100;
1320 yyElement->MarkY = $8*100;
1321 SaveFree($4);
1322 SaveFree($5);
1323 SaveFree($6);
1325 relementdefs ')'
1327 SetElementBoundingBox(yyData, yyElement, yyFont);
1331 element_hi_format
1332 /* element_flags, description, pcb-name, value, mark_x, mark_y,
1333 * text_x, text_y, text_direction, text_scale, text_flags
1335 : T_ELEMENT '[' flags STRING STRING STRING NUMBER NUMBER
1336 NUMBER NUMBER NUMBER NUMBER flags ']' '('
1338 yyElement = CreateNewElement(yyData, yyElement, yyFont, $3,
1339 $4, $5, $6, ($7+$9), ($8+$10), $11, $12, $13, false);
1340 yyElement->MarkX = $7;
1341 yyElement->MarkY = $8;
1342 SaveFree($4);
1343 SaveFree($5);
1344 SaveFree($6);
1346 relementdefs ')'
1348 SetElementBoundingBox(yyData, yyElement, yyFont);
1352 /* %start-doc pcbfile ElementLine
1354 @syntax
1355 ElementLine [X1 Y1 X2 Y2 Thickness]
1356 ElementLine (X1 Y1 X2 Y2 Thickness)
1357 @end syntax
1359 @table @var
1360 @item X1 Y1 X2 Y2
1361 Coordinates of the endpoints of the line. These are relative to the
1362 Element's mark point for new element formats, or absolute for older
1363 formats.
1364 @item Thickness
1365 The width of the silk for this line.
1366 @end table
1368 %end-doc */
1370 /* %start-doc pcbfile ElementArc
1372 @syntax
1373 ElementArc [X Y Width Height StartAngle DeltaAngle Thickness]
1374 ElementArc (X Y Width Height StartAngle DeltaAngle Thickness)
1375 @end syntax
1377 @table @var
1378 @item X Y
1379 Coordinates of the center of the arc. These are relative to the
1380 Element's mark point for new element formats, or absolute for older
1381 formats.
1382 @item Width Height
1383 The width and height, from the center to the edge. The bounds of the
1384 circle of which this arc is a segment, is thus @math{2*Width} by
1385 @math{2*Height}.
1386 @item StartAngle
1387 The angle of one end of the arc, in degrees. In PCB, an angle of zero
1388 points left (negative X direction), and 90 degrees points down
1389 (positive Y direction).
1390 @item DeltaAngle
1391 The sweep of the arc. This may be negative. Positive angles sweep
1392 counterclockwise.
1393 @item Thickness
1394 The width of the silk line which forms the arc.
1395 @end table
1397 %end-doc */
1399 /* %start-doc pcbfile Mark
1401 @syntax
1402 Mark [X Y]
1403 Mark (X Y)
1404 @end syntax
1406 @table @var
1407 @item X Y
1408 Coordinates of the Mark, for older element formats that don't have
1409 the mark as part of the Element line.
1410 @end table
1412 %end-doc */
1414 elementdefinitions
1415 : elementdefinition
1416 | elementdefinitions elementdefinition
1419 elementdefinition
1420 : pin_1.6.3_format
1421 | pin_newformat
1422 | pin_oldformat
1423 | pad_newformat
1424 | pad
1425 /* x1, y1, x2, y2, thickness */
1426 | T_ELEMENTLINE '[' NUMBER NUMBER NUMBER NUMBER NUMBER ']'
1428 CreateNewLineInElement(yyElement, $3, $4, $5, $6, $7);
1430 /* x1, y1, x2, y2, thickness */
1431 | T_ELEMENTLINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1433 CreateNewLineInElement(yyElement, $3*100, $4*100, $5*100, $6*100, $7*100);
1435 /* x, y, width, height, startangle, anglediff, thickness */
1436 | T_ELEMENTARC '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ']'
1438 CreateNewArcInElement(yyElement, $3, $4, $5, $6, $7, $8, $9);
1440 /* x, y, width, height, startangle, anglediff, thickness */
1441 | T_ELEMENTARC '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1443 CreateNewArcInElement(yyElement, $3*100, $4*100, $5*100, $6*100, $7, $8, $9*100);
1445 /* x, y position */
1446 | T_MARK '[' NUMBER NUMBER ']'
1448 yyElement->MarkX = $3;
1449 yyElement->MarkY = $4;
1451 | T_MARK '(' NUMBER NUMBER ')'
1453 yyElement->MarkX = $3*100;
1454 yyElement->MarkY = $4*100;
1456 | { attr_list = & yyElement->Attributes; } attributes
1459 relementdefs
1460 : relementdef
1461 | relementdefs relementdef
1464 relementdef
1465 : pin_1.7_format
1466 | pin_hi_format
1467 | pad_1.7_format
1468 | pad_hi_format
1469 /* x1, y1, x2, y2, thickness */
1470 | T_ELEMENTLINE '[' NUMBER NUMBER NUMBER NUMBER NUMBER ']'
1472 CreateNewLineInElement(yyElement, $3 + yyElement->MarkX,
1473 $4 + yyElement->MarkY, $5 + yyElement->MarkX,
1474 $6 + yyElement->MarkY, $7);
1476 | T_ELEMENTLINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1478 CreateNewLineInElement(yyElement, $3*100 + yyElement->MarkX,
1479 $4*100 + yyElement->MarkY, $5*100 + yyElement->MarkX,
1480 $6*100 + yyElement->MarkY, $7*100);
1482 /* x, y, width, height, startangle, anglediff, thickness */
1483 | T_ELEMENTARC '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ']'
1485 CreateNewArcInElement(yyElement, $3 + yyElement->MarkX,
1486 $4 + yyElement->MarkY, $5, $6, $7, $8, $9);
1488 | T_ELEMENTARC '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1490 CreateNewArcInElement(yyElement, $3*100 + yyElement->MarkX,
1491 $4*100 + yyElement->MarkY, $5*100, $6*100, $7, $8, $9*100);
1493 | { attr_list = & yyElement->Attributes; } attributes
1496 /* %start-doc pcbfile Pin
1498 @syntax
1499 Pin [rX rY Thickness Clearance Mask Drill "Name" "Number" SFlags]
1500 Pin (rX rY Thickness Clearance Mask Drill "Name" "Number" NFlags)
1501 Pin (aX aY Thickness Drill "Name" "Number" NFlags)
1502 Pin (aX aY Thickness Drill "Name" NFlags)
1503 Pin (aX aY Thickness "Name" NFlags)
1504 @end syntax
1506 @table @var
1507 @item rX rY
1508 coordinates of center, relative to the element's mark
1509 @item aX aY
1510 absolute coordinates of center.
1511 @item Thickness
1512 outer diameter of copper annulus
1513 @item Clearance
1514 add to thickness to get clearance diameter
1515 @item Mask
1516 diameter of solder mask opening
1517 @item Drill
1518 diameter of drill
1519 @item Name
1520 name of pin
1521 @item Number
1522 number of pin
1523 @item SFlags
1524 symbolic or numerical flags
1525 @item NFlags
1526 numerical flags only
1527 @end table
1529 %end-doc */
1531 pin_hi_format
1532 /* x, y, thickness, clearance, mask, drilling hole, name,
1533 number, flags */
1534 : T_PIN '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING flags ']'
1536 CreateNewPin(yyElement, $3 + yyElement->MarkX,
1537 $4 + yyElement->MarkY, $5, $6, $7, $8, $9,
1538 $10, $11);
1539 SaveFree($9);
1540 SaveFree($10);
1543 pin_1.7_format
1544 /* x, y, thickness, clearance, mask, drilling hole, name,
1545 number, flags */
1546 : T_PIN '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER ')'
1548 CreateNewPin(yyElement, $3*100 + yyElement->MarkX,
1549 $4*100 + yyElement->MarkY, $5*100, $6*100, $7*100, $8*100, $9,
1550 $10, OldFlags($11));
1551 SaveFree($9);
1552 SaveFree($10);
1556 pin_1.6.3_format
1557 /* x, y, thickness, drilling hole, name, number, flags */
1558 : T_PIN '(' NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER ')'
1560 CreateNewPin(yyElement, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
1561 ($5 + 2*MASKFRAME)*100, $6*100, $7, $8, OldFlags($9));
1562 SaveFree($7);
1563 SaveFree($8);
1567 pin_newformat
1568 /* x, y, thickness, drilling hole, name, flags */
1569 : T_PIN '(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
1571 char p_number[8];
1573 sprintf(p_number, "%d", pin_num++);
1574 CreateNewPin(yyElement, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
1575 ($5 + 2*MASKFRAME)*100, $6*100, $7, p_number, OldFlags($8));
1577 SaveFree($7);
1581 pin_oldformat
1582 /* old format: x, y, thickness, name, flags
1583 * drilling hole is 40% of the diameter
1585 : T_PIN '(' NUMBER NUMBER NUMBER STRING NUMBER ')'
1587 BDimension hole = ($5 *DEFAULT_DRILLINGHOLE);
1588 char p_number[8];
1590 /* make sure that there's enough copper left */
1591 if ($5 -hole < MIN_PINORVIACOPPER &&
1592 $5 > MIN_PINORVIACOPPER)
1593 hole = $5 -MIN_PINORVIACOPPER;
1595 sprintf(p_number, "%d", pin_num++);
1596 CreateNewPin(yyElement, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
1597 ($5 + 2*MASKFRAME)*100, hole, $6, p_number, OldFlags($7));
1598 SaveFree($6);
1602 /* %start-doc pcbfile Pad
1604 @syntax
1605 Pad [rX1 rY1 rX2 rY2 Thickness Clearance Mask "Name" "Number" SFlags]
1606 Pad (rX1 rY1 rX2 rY2 Thickness Clearance Mask "Name" "Number" NFlags)
1607 Pad (aX1 aY1 aX2 aY2 Thickness "Name" "Number" NFlags)
1608 Pad (aX1 aY1 aX2 aY2 Thickness "Name" NFlags)
1609 @end syntax
1611 @table @var
1612 @item rX1 rY1 rX2 rY2
1613 Coordinates of the endpoints of the pad, relative to the element's
1614 mark. Note that the copper extends beyond these coordinates by half
1615 the thickness. To make a square or round pad, specify the same
1616 coordinate twice.
1617 @item aX1 aY1 aX2 aY2
1618 Same, but absolute coordinates of the endpoints of the pad.
1619 @item Thickness
1620 width of the pad.
1621 @item Clearance
1622 add to thickness to get clearance width.
1623 @item Mask
1624 width of solder mask opening.
1625 @item Name
1626 name of pin
1627 @item Number
1628 number of pin
1629 @item SFlags
1630 symbolic or numerical flags
1631 @item NFlags
1632 numerical flags only
1633 @end table
1635 %end-doc */
1637 pad_hi_format
1638 /* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */
1639 : T_PAD '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING flags ']'
1641 CreateNewPad(yyElement, $3 + yyElement->MarkX,
1642 $4 + yyElement->MarkY,
1643 $5 + yyElement->MarkX,
1644 $6 + yyElement->MarkY, $7, $8, $9,
1645 $10, $11, $12);
1646 SaveFree($10);
1647 SaveFree($11);
1651 pad_1.7_format
1652 /* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */
1653 : T_PAD '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER ')'
1655 CreateNewPad(yyElement,$3*100 + yyElement->MarkX,
1656 $4*100 + yyElement->MarkY, $5*100 + yyElement->MarkX,
1657 $6*100 + yyElement->MarkY, $7*100, $8*100, $9*100,
1658 $10, $11, OldFlags($12));
1659 SaveFree($10);
1660 SaveFree($11);
1664 pad_newformat
1665 /* x1, y1, x2, y2, thickness, name , pad number, flags */
1666 : T_PAD '(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER ')'
1668 CreateNewPad(yyElement,$3*100,$4*100,$5*100,$6*100,$7*100, 200*GROUNDPLANEFRAME,
1669 ($7 + 2*MASKFRAME)*100, $8,$9, OldFlags($10));
1670 SaveFree($8);
1671 SaveFree($9);
1676 /* x1, y1, x2, y2, thickness, name and flags */
1677 : T_PAD '(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
1679 char p_number[8];
1681 sprintf(p_number, "%d", pin_num++);
1682 CreateNewPad(yyElement,$3*100,$4*100,$5*100,$6*100,$7*100, 200*GROUNDPLANEFRAME,
1683 ($7 + 2*MASKFRAME)*100, $8,p_number, OldFlags($9));
1684 SaveFree($8);
1688 flags : NUMBER { $$ = OldFlags($1); }
1689 | STRING { $$ = string_to_flags ($1, yyerror); }
1692 symbols
1693 : symbol
1694 | symbols symbol
1697 /* %start-doc pcbfile Symbol
1699 @syntax
1700 Symbol [Char Delta] (
1701 Symbol (Char Delta) (
1702 @ @ @ @dots{} symbol lines @dots{}
1704 @end syntax
1706 @table @var
1707 @item Char
1708 The character or numerical character value this symbol represents.
1709 Characters must be in single quotes.
1710 @item Delta
1711 Additional space to allow after this character.
1712 @end table
1714 %end-doc */
1716 symbol
1717 : T_SYMBOL '[' symbolid NUMBER ']' '('
1719 if ($3 <= 0 || $3 > MAX_FONTPOSITION)
1721 yyerror("fontposition out of range");
1722 YYABORT;
1724 Symbol = &yyFont->Symbol[$3];
1725 if (Symbol->Valid)
1727 yyerror("symbol ID used twice");
1728 YYABORT;
1730 Symbol->Valid = true;
1731 Symbol->Delta = $4;
1733 symboldata ')'
1734 | T_SYMBOL '(' symbolid NUMBER ')' '('
1736 if ($3 <= 0 || $3 > MAX_FONTPOSITION)
1738 yyerror("fontposition out of range");
1739 YYABORT;
1741 Symbol = &yyFont->Symbol[$3];
1742 if (Symbol->Valid)
1744 yyerror("symbol ID used twice");
1745 YYABORT;
1747 Symbol->Valid = true;
1748 Symbol->Delta = $4*100;
1750 symboldata ')'
1753 symbolid
1754 : NUMBER
1755 | CHAR_CONST
1758 symboldata
1759 : symboldefinitions
1760 | symboldata symboldefinitions
1763 symboldefinitions
1764 : symboldefinition
1765 | hiressymbol
1769 /* %start-doc pcbfile SymbolLine
1771 @syntax
1772 SymbolLine [X1 Y1 X2 Y1 Thickness]
1773 SymbolLine (X1 Y1 X2 Y1 Thickness)
1774 @end syntax
1776 @table @var
1777 @item X1 Y1 X2 Y2
1778 The endpoints of this line.
1779 @item Thickness
1780 The width of this line.
1781 @end table
1783 %end-doc */
1785 symboldefinition
1786 /* x1, y1, x2, y2, thickness */
1787 : T_SYMBOLLINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1789 CreateNewLineInSymbol(Symbol, $3*100, $4*100, $5*100, $6*100, $7*100);
1792 hiressymbol
1793 /* x1, y1, x2, y2, thickness */
1794 : T_SYMBOLLINE '[' NUMBER NUMBER NUMBER NUMBER NUMBER ']'
1796 CreateNewLineInSymbol(Symbol, $3, $4, $5, $6, $7);
1800 /* %start-doc pcbfile Netlist
1802 @syntax
1803 Netlist ( ) (
1804 @ @ @ @dots{} nets @dots{}
1806 @end syntax
1808 %end-doc */
1810 pcbnetlist : pcbnetdef
1813 pcbnetdef
1814 /* net(...) net(...) ... */
1815 : T_NETLIST '(' ')' '('
1816 nets ')'
1819 nets
1820 : netdefs
1824 netdefs
1825 : net
1826 | netdefs net
1829 /* %start-doc pcbfile Net
1831 @syntax
1832 Net ("Name" "Style") (
1833 @ @ @ @dots{} connects @dots{}
1835 @end syntax
1837 @table @var
1838 @item Name
1839 The name of this net.
1840 @item Style
1841 The routing style that should be used when autorouting this net.
1842 @end table
1844 %end-doc */
1847 /* name style pin pin ... */
1848 : T_NET '(' STRING STRING ')' '('
1850 Menu = CreateNewNet(&yyPCB->NetlistLib, $3, $4);
1851 SaveFree($3);
1852 SaveFree($4);
1854 connections ')'
1857 connections
1858 : conndefs
1862 conndefs
1863 : conn
1864 | conndefs conn
1867 /* %start-doc pcbfile Connect
1869 @syntax
1870 Connect ("PinPad")
1871 @end syntax
1873 @table @var
1874 @item PinPad
1875 The name of a pin or pad which is included in this net. Pin and Pad
1876 names are named by the refdes and pin name, like @code{"U14-7"} for
1877 pin 7 of U14, or @code{"T4-E"} for pin E of T4.
1878 @end table
1880 %end-doc */
1882 conn
1883 : T_CONN '(' STRING ')'
1885 CreateNewConnection(Menu, $3);
1886 SaveFree($3);
1890 /* %start-doc pcbfile Attribute
1892 @syntax
1893 Attribute ("Name" "Value")
1894 @end syntax
1896 Attributes allow boards and elements to have arbitrary data attached
1897 to them, which is not directly used by PCB itself but may be of use by
1898 other programs or users.
1900 @table @var
1901 @item Name
1902 The name of the attribute
1904 @item Value
1905 The value of the attribute. Values are always stored as strings, even
1906 if the value is interpreted as, for example, a number.
1908 @end table
1910 %end-doc */
1912 attributes : attribute
1913 | attributes attribute
1915 attribute
1916 : T_ATTRIBUTE '(' STRING STRING ')'
1918 CreateNewAttribute (attr_list, $3, $4 ? $4 : "");
1919 SaveFree ($3);
1920 SaveFree ($4);
1924 opt_string : STRING { $$ = $1; }
1925 | /* empty */ { $$ = 0; }
1930 /* ---------------------------------------------------------------------------
1931 * error routine called by parser library
1933 int yyerror(s)
1934 const char *s;
1936 Message("ERROR parsing file '%s'\n"
1937 " line: %i\n"
1938 " description: '%s'\n",
1939 yyfilename, yylineno, s);
1940 return(0);
1943 int yywrap()
1945 return 1;
1949 static int
1950 check_file_version (int ver)
1952 if ( ver > PCB_FILE_VERSION ) {
1953 Message ("ERROR: The file you are attempting to load is in a format\n"
1954 "which is too new for this version of pcb. To load this file\n"
1955 "you need a version of pcb which is >= %d. If you are\n"
1956 "using a version built from git source, the source date\n"
1957 "must be >= %d. This copy of pcb can only read files\n"
1958 "up to file version %d.\n", ver, ver, PCB_FILE_VERSION);
1959 return 1;
1962 return 0;