select.c: Remove Draw() call from SelectConnection
[geda-pcb/leaky.git] / src / parse_y.y
blob7aa7b8078ef3a28caa11899f842d468a127ad04a
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 PCB
283 @syntax
284 PCB ["Name" Width Height]
285 PCB ("Name" Width Height]
286 PCB ("Name")
287 @end syntax
289 @table @var
290 @item Name
291 Name of the PCB project
292 @item Width Height
293 Size of the board
294 @end table
296 If you don't specify the size of the board, a very large default is
297 chosen.
299 %end-doc */
301 pcbname
302 : T_PCB '(' STRING ')'
304 yyPCB->Name = $3;
305 yyPCB->MaxWidth = MAX_COORD;
306 yyPCB->MaxHeight = MAX_COORD;
308 | T_PCB '(' STRING NUMBER NUMBER ')'
310 yyPCB->Name = $3;
311 yyPCB->MaxWidth = $4*100;
312 yyPCB->MaxHeight = $5*100;
314 | T_PCB '[' STRING NUMBER NUMBER ']'
316 yyPCB->Name = $3;
317 yyPCB->MaxWidth = $4;
318 yyPCB->MaxHeight = $5;
322 /* %start-doc pcbfile Grid
324 @syntax
325 Grid [Step OffsetX OffsetY Visible]
326 Grid (Step OffsetX OffsetY Visible)
327 Grid (Step OffsetX OffsetY)
328 @end syntax
330 @table @var
331 @item Step
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.
336 @item Visible
337 If non-zero, the grid will be visible on the screen.
338 @end table
340 %end-doc */
342 pcbgrid
343 : pcbgridold
344 | pcbgridnew
345 | pcb2grid
346 | pcbhigrid
348 pcbgridold
349 : T_GRID '(' NUMBER NUMBER NUMBER ')'
351 yyPCB->Grid = $3*100;
352 yyPCB->GridOffsetX = $4*100;
353 yyPCB->GridOffsetY = $5*100;
356 pcbgridnew
357 : T_GRID '(' NUMBER NUMBER NUMBER NUMBER ')'
359 yyPCB->Grid = $3*100;
360 yyPCB->GridOffsetX = $4*100;
361 yyPCB->GridOffsetY = $5*100;
362 if ($6)
363 Settings.DrawGrid = true;
364 else
365 Settings.DrawGrid = false;
369 pcb2grid
370 : T_GRID '(' FLOAT NUMBER NUMBER NUMBER ')'
372 yyPCB->Grid = $3*100;
373 yyPCB->GridOffsetX = $4*100;
374 yyPCB->GridOffsetY = $5*100;
375 if ($6)
376 Settings.DrawGrid = true;
377 else
378 Settings.DrawGrid = false;
381 pcbhigrid
382 : T_GRID '[' FLOAT NUMBER NUMBER NUMBER ']'
384 yyPCB->Grid = $3;
385 yyPCB->GridOffsetX = $4;
386 yyPCB->GridOffsetY = $5;
387 if ($6)
388 Settings.DrawGrid = true;
389 else
390 Settings.DrawGrid = false;
394 /* %start-doc pcbfile Cursor
396 @syntax
397 Cursor [X Y Zoom]
398 Cursor (X Y Zoom)
399 @end syntax
401 @table @var
402 @item X Y
403 Location of the cursor when the board was saved.
404 @item Zoom
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"
409 @end table
411 %end-doc */
413 pcbcursor
414 : T_CURSOR '(' NUMBER NUMBER NUMBER ')'
416 yyPCB->CursorX = $3*100;
417 yyPCB->CursorY = $4*100;
418 yyPCB->Zoom = $5*2;
420 | T_CURSOR '[' NUMBER NUMBER NUMBER ']'
422 yyPCB->CursorX = $3;
423 yyPCB->CursorY = $4;
424 yyPCB->Zoom = $5;
426 | T_CURSOR '[' NUMBER NUMBER FLOAT ']'
428 yyPCB->CursorX = $3;
429 yyPCB->CursorY = $4;
430 yyPCB->Zoom = $5;
435 /* %start-doc pcbfile PolyArea
437 @syntax
438 PolyArea [Area]
439 @end syntax
441 @table @var
442 @item Area
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.
444 @end table
446 %end-doc */
448 polyarea
450 | T_AREA '[' FLOAT ']'
452 yyPCB->IsleArea = $3;
457 /* %start-doc pcbfile Thermal
459 @syntax
460 Thermal [Scale]
461 @end syntax
463 @table @var
464 @item Scale
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.
469 @end table
471 %end-doc */
474 pcbthermal
476 | T_THERMAL '[' FLOAT ']'
478 yyPCB->ThermScale = $3;
482 /* %start-doc pcbfile DRC
484 @syntax
485 DRC [Bloat Shrink Line Silk Drill Ring]
486 DRC [Bloat Shrink Line Silk]
487 DRC [Bloat Shrink Line]
488 @end syntax
490 @table @var
491 @item Bloat
492 Minimum spacing between copper.
493 @item Shrink
494 Minimum copper overlap to guarantee connectivity.
495 @item Line
496 Minimum line thickness.
497 @item Silk
498 Minimum silk thickness.
499 @item Drill
500 Minimum drill size.
501 @item Ring
502 Minimum width of the annular ring around pins and vias.
503 @end table
505 %end-doc */
507 pcbdrc
509 | pcbdrc1
510 | pcbdrc2
511 | pcbdrc3
514 pcbdrc1
515 : T_DRC '[' NUMBER NUMBER NUMBER ']'
517 yyPCB->Bloat = $3;
518 yyPCB->Shrink = $4;
519 yyPCB->minWid = $5;
520 yyPCB->minRing = $5;
524 pcbdrc2
525 : T_DRC '[' NUMBER NUMBER NUMBER NUMBER ']'
527 yyPCB->Bloat = $3;
528 yyPCB->Shrink = $4;
529 yyPCB->minWid = $5;
530 yyPCB->minSlk = $6;
531 yyPCB->minRing = $5;
535 pcbdrc3
536 : T_DRC '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ']'
538 yyPCB->Bloat = $3;
539 yyPCB->Shrink = $4;
540 yyPCB->minWid = $5;
541 yyPCB->minSlk = $6;
542 yyPCB->minDrill = $7;
543 yyPCB->minRing = $8;
547 /* %start-doc pcbfile Flags
549 @syntax
550 Flags(Number)
551 @end syntax
553 @table @var
554 @item Number
555 A number, whose value is normally given in hex, individual bits of which
556 represent pcb-wide flags as defined in @ref{PCBFlags}.
558 @end table
560 %end-doc */
562 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
576 @syntax
577 Groups("String")
578 @end syntax
580 @table @var
581 @item String
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.
590 @example
591 Groups("1,2,c:3:4:5,6,s:7,8")
592 @end example
594 @end table
596 %end-doc */
598 pcbgroups
599 : T_GROUPS '(' STRING ')'
601 layer_group_string = $3;
606 /* %start-doc pcbfile Styles
608 @syntax
609 Styles("String")
610 @end syntax
612 @table @var
613 @item String
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:
618 @table @var
619 @item Name
620 The name of the style.
621 @item Thickness
622 Width of lines and arcs.
623 @item Diameter
624 Copper diameter of pins and vias.
625 @item Drill
626 Drill diameter of pins and vias.
627 @item Keepaway
628 Minimum spacing to other nets. If omitted, 10 mils is the default.
630 @end table
632 @end table
634 @example
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"]
638 @end example
640 @noindent
641 Note that strings in actual files cannot span lines; the above example
642 is split across lines only to make it readable.
644 %end-doc */
646 pcbstyles
647 : T_STYLES '(' STRING ')'
649 if (ParseRouteString($3, &yyPCB->RouteStyle[0], 100))
651 Message("illegal route-style string\n");
652 YYABORT;
655 | T_STYLES '[' STRING ']'
657 if (ParseRouteString($3, &yyPCB->RouteStyle[0], 1))
659 Message("illegal route-style string\n");
660 YYABORT;
666 pcbdata
667 : pcbdefinitions
671 pcbdefinitions
672 : pcbdefinition
673 | pcbdefinitions pcbdefinition
676 pcbdefinition
677 : via
678 | { attr_list = & yyPCB->Attributes; } attributes
679 | rats
680 | layer
683 /* clear pointer to force memory allocation by
684 * the appropriate subroutine
686 yyElement = NULL;
688 element
689 | error { YYABORT; }
693 : via_hi_format
694 | via_2.0_format
695 | via_1.7_format
696 | via_newformat
697 | via_oldformat
700 /* %start-doc pcbfile Via
702 @syntax
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)
708 @end syntax
710 @table @var
711 @item X Y
712 coordinates of center
713 @item Thickness
714 outer diameter of copper annulus
715 @item Clearance
716 add to thickness to get clearance diameter
717 @item Mask
718 diameter of solder mask opening
719 @item Drill
720 diameter of drill
721 @item Name
722 string, name of via (vias have names?)
723 @item SFlags
724 symbolic or numerical flags
725 @item NFlags
726 numerical flags only
727 @end table
729 %end-doc */
731 via_hi_format
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);
736 free ($9);
740 via_2.0_format
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,
745 OldFlags($10));
746 free ($9);
751 via_1.7_format
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));
757 free ($8);
761 via_newformat
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));
767 free ($7);
771 via_oldformat
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));
784 free ($6);
788 /* %start-doc pcbfile Rat
790 @syntax
791 Rat [X1 Y1 Group1 X2 Y2 Group2 SFlags]
792 Rat (X1 Y1 Group1 X2 Y2 Group2 NFlags)
793 @end syntax
795 @table @var
796 @item X1 Y1 X2 Y2
797 The endpoints of the rat line.
798 @item Group1 Group2
799 The layer group each end is connected on.
800 @item SFlags
801 Symbolic or numeric flags.
802 @item NFlags
803 Numeric flags.
804 @end table
806 %end-doc */
808 rats
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
823 @syntax
824 Layer (LayerNum "Name") (
825 @ @ @ @dots{} contents @dots{}
827 @end syntax
829 @table @var
830 @item LayerNum
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.
834 @item Name
835 The layer name.
836 @item contents
837 The contents of the layer, which may include attributes, lines, arcs, rectangles,
838 text, and polygons.
839 @end table
841 %end-doc */
843 layer
844 /* name */
845 : T_LAYER '(' NUMBER STRING opt_string ')' '('
847 if ($3 <= 0 || $3 > MAX_LAYER + 2)
849 yyerror("Layernumber out of range");
850 YYABORT;
852 if (LayerFlag[$3-1])
854 yyerror("Layernumber used twice");
855 YYABORT;
857 Layer = &yyData->Layer[$3-1];
859 /* memory for name is already allocated */
860 Layer->Name = $4;
861 LayerFlag[$3-1] = true;
862 if (yyData->LayerN + 2 < $3)
863 yyData->LayerN = $3 - 2;
865 layerdata ')'
868 layerdata
869 : layerdefinitions
873 layerdefinitions
874 : layerdefinition
875 | layerdefinitions layerdefinition
878 layerdefinition
879 : line_hi_format
880 | line_1.7_format
881 | line_oldformat
882 | arc_hi_format
883 | arc_1.7_format
884 | arc_oldformat
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));
891 | text_hi_format
892 | text_newformat
893 | text_oldformat
894 | { attr_list = & Layer->Attributes; } attributes
895 | polygon_format
897 /* %start-doc pcbfile Line
899 @syntax
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)
903 @end syntax
905 @table @var
906 @item X1 Y1 X2 Y2
907 The end points of the line
908 @item Thickness
909 The width of the line
910 @item Clearance
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.
915 @item SFlags
916 Symbolic or numeric flags
917 @item NFlags
918 Numeric flags.
919 @end table
921 %end-doc */
923 line_hi_format
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);
931 line_1.7_format
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));
940 line_oldformat
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
953 @syntax
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)
957 @end syntax
959 @table @var
960 @item X Y
961 Coordinates of the center of the arc.
962 @item Width Height
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
965 @math{2*Height}.
966 @item Thickness
967 The width of the copper trace which forms the arc.
968 @item Clearance
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.
973 @item StartAngle
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).
977 @item DeltaAngle
978 The sweep of the arc. This may be negative. Positive angles sweep
979 counterclockwise.
980 @item SFlags
981 Symbolic or numeric flags.
982 @item NFlags
983 Numeric flags.
984 @end table
986 %end-doc */
988 arc_hi_format
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);
996 arc_1.7_format
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));
1005 arc_oldformat
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
1016 @syntax
1017 Text [X Y Direction Scale "String" SFlags]
1018 Text (X Y Direction Scale "String" NFlags)
1019 Text (X Y Direction "String" NFlags)
1020 @end syntax
1022 @table @var
1023 @item X Y
1024 The location of the upper left corner of the text.
1025 @item Direction
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.
1028 @item Scale
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
1031 mils).
1032 @item String
1033 The string to draw.
1034 @item SFlags
1035 Symbolic or numeric flags.
1036 @item NFlags
1037 Numeric flags.
1038 @end table
1040 %end-doc */
1042 text_oldformat
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));
1048 free ($6);
1052 text_newformat
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,
1062 OldFlags($8));
1064 else
1065 CreateNewText(Layer, yyFont, $3*100, $4*100, $5, $6, $7,
1066 OldFlags($8));
1067 free ($7);
1070 text_hi_format
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);
1088 else
1089 CreateNewText(Layer, yyFont, $3, $4, $5, $6, $7, $8);
1090 free ($7);
1094 /* %start-doc pcbfile Polygon
1096 @syntax
1097 Polygon (SFlags) (
1098 @ @ @ @dots{} (X Y) @dots{}
1099 @ @ @ @dots{} [X Y] @dots{}
1100 @ @ @ Hole (
1101 @ @ @ @ @ @ @dots{} (X Y) @dots{}
1102 @ @ @ @ @ @ @dots{} [X Y] @dots{}
1103 @ @ @ )
1104 @ @ @ @dots{}
1106 @end syntax
1108 @table @var
1109 @item SFlags
1110 Symbolic or numeric flags.
1111 @item X Y
1112 Coordinates of each vertex. You must list at least three coordinates.
1113 @item Hole (...)
1114 Defines a hole within the polygon's outer contour. There may be zero or more such sections.
1115 @end table
1117 %end-doc */
1119 polygon_format
1120 : /* flags are passed in */
1121 T_POLYGON '(' flags ')' '('
1123 Polygon = CreateNewPolygon(Layer, $3);
1125 polygonpoints
1126 polygonholes ')'
1128 Cardinal contour, contour_start, contour_end;
1129 bool bad_contour_found = false;
1130 /* ignore junk */
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) ?
1136 Polygon->PointN :
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"
1145 " line: %i\n"
1146 " description: 'ignored polygon (< 3 points in a contour)'\n",
1147 yyfilename, yylineno);
1148 DestroyObject(yyData, POLYGON_TYPE, Layer, Polygon, Polygon);
1150 else
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);
1160 polygonholes
1161 : /* empty */
1162 | polygonhole
1163 | polygonholes polygonhole
1166 polygonhole
1167 : T_POLYGON_HOLE '('
1169 CreateNewHoleInPolygon (Polygon);
1171 polygonpoints ')'
1174 polygonpoints
1175 : polygonpoint
1176 | polygonpoints polygonpoint
1179 polygonpoint
1180 /* xcoord ycoord */
1181 : '(' NUMBER NUMBER ')'
1183 CreateNewPointInPolygon(Polygon, $2*100, $3*100);
1185 | '[' NUMBER NUMBER ']'
1187 CreateNewPointInPolygon(Polygon, $2, $3);
1192 /* %start-doc pcbfile Element
1194 @syntax
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{}
1202 @end syntax
1204 @table @var
1205 @item SFlags
1206 Symbolic or numeric flags, for the element as a whole.
1207 @item NFlags
1208 Numeric flags, for the element as a whole.
1209 @item Desc
1210 The description of the element. This is one of the three strings
1211 which can be displayed on the screen.
1212 @item Name
1213 The name of the element, usually the reference designator.
1214 @item Value
1215 The value of the element.
1216 @item MX MY
1217 The location of the element's mark. This is the reference point
1218 for placing the element and its pins and pads.
1219 @item TX TY
1220 The upper left corner of the text (one of the three strings).
1221 @item TDir
1222 The relative direction of the text. 0 means left to right for
1223 an unrotated element, 1 means up, 2 left, 3 down.
1224 @item TScale
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
1227 mils).
1228 @item TSFlags
1229 Symbolic or numeric flags, for the text.
1230 @item TNFlags
1231 Numeric flags, for the text.
1232 @end table
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.
1243 %end-doc */
1245 element
1246 : element_oldformat
1247 | element_1.3.4_format
1248 | element_newformat
1249 | element_1.7_format
1250 | element_hi_format
1253 element_oldformat
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);
1261 free ($3);
1262 free ($4);
1263 pin_num = 1;
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);
1279 free ($4);
1280 free ($5);
1281 pin_num = 1;
1283 elementdefinitions ')'
1285 SetElementBoundingBox(yyData, yyElement, yyFont);
1289 element_newformat
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);
1297 free ($4);
1298 free ($5);
1299 free ($6);
1300 pin_num = 1;
1302 elementdefinitions ')'
1304 SetElementBoundingBox(yyData, yyElement, yyFont);
1308 element_1.7_format
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;
1319 free ($4);
1320 free ($5);
1321 free ($6);
1323 relementdefs ')'
1325 SetElementBoundingBox(yyData, yyElement, yyFont);
1329 element_hi_format
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;
1340 free ($4);
1341 free ($5);
1342 free ($6);
1344 relementdefs ')'
1346 SetElementBoundingBox(yyData, yyElement, yyFont);
1350 /* %start-doc pcbfile ElementLine
1352 @syntax
1353 ElementLine [X1 Y1 X2 Y2 Thickness]
1354 ElementLine (X1 Y1 X2 Y2 Thickness)
1355 @end syntax
1357 @table @var
1358 @item X1 Y1 X2 Y2
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
1361 formats.
1362 @item Thickness
1363 The width of the silk for this line.
1364 @end table
1366 %end-doc */
1368 /* %start-doc pcbfile ElementArc
1370 @syntax
1371 ElementArc [X Y Width Height StartAngle DeltaAngle Thickness]
1372 ElementArc (X Y Width Height StartAngle DeltaAngle Thickness)
1373 @end syntax
1375 @table @var
1376 @item X Y
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
1379 formats.
1380 @item Width Height
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
1383 @math{2*Height}.
1384 @item StartAngle
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).
1388 @item DeltaAngle
1389 The sweep of the arc. This may be negative. Positive angles sweep
1390 counterclockwise.
1391 @item Thickness
1392 The width of the silk line which forms the arc.
1393 @end table
1395 %end-doc */
1397 /* %start-doc pcbfile Mark
1399 @syntax
1400 Mark [X Y]
1401 Mark (X Y)
1402 @end syntax
1404 @table @var
1405 @item X Y
1406 Coordinates of the Mark, for older element formats that don't have
1407 the mark as part of the Element line.
1408 @end table
1410 %end-doc */
1412 elementdefinitions
1413 : elementdefinition
1414 | elementdefinitions elementdefinition
1417 elementdefinition
1418 : pin_1.6.3_format
1419 | pin_newformat
1420 | pin_oldformat
1421 | pad_newformat
1422 | pad
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);
1443 /* x, y position */
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
1457 relementdefs
1458 : relementdef
1459 | relementdefs relementdef
1462 relementdef
1463 : pin_1.7_format
1464 | pin_hi_format
1465 | pad_1.7_format
1466 | pad_hi_format
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
1496 @syntax
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)
1502 @end syntax
1504 @table @var
1505 @item rX rY
1506 coordinates of center, relative to the element's mark
1507 @item aX aY
1508 absolute coordinates of center.
1509 @item Thickness
1510 outer diameter of copper annulus
1511 @item Clearance
1512 add to thickness to get clearance diameter
1513 @item Mask
1514 diameter of solder mask opening
1515 @item Drill
1516 diameter of drill
1517 @item Name
1518 name of pin
1519 @item Number
1520 number of pin
1521 @item SFlags
1522 symbolic or numerical flags
1523 @item NFlags
1524 numerical flags only
1525 @end table
1527 %end-doc */
1529 pin_hi_format
1530 /* x, y, thickness, clearance, mask, drilling hole, name,
1531 number, flags */
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,
1536 $10, $11);
1537 free ($9);
1538 free ($10);
1541 pin_1.7_format
1542 /* x, y, thickness, clearance, mask, drilling hole, name,
1543 number, flags */
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));
1549 free ($9);
1550 free ($10);
1554 pin_1.6.3_format
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));
1560 free ($7);
1561 free ($8);
1565 pin_newformat
1566 /* x, y, thickness, drilling hole, name, flags */
1567 : T_PIN '(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
1569 char p_number[8];
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));
1575 free ($7);
1579 pin_oldformat
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);
1586 char p_number[8];
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));
1596 free ($6);
1600 /* %start-doc pcbfile Pad
1602 @syntax
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)
1607 @end syntax
1609 @table @var
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
1614 coordinate twice.
1615 @item aX1 aY1 aX2 aY2
1616 Same, but absolute coordinates of the endpoints of the pad.
1617 @item Thickness
1618 width of the pad.
1619 @item Clearance
1620 add to thickness to get clearance width.
1621 @item Mask
1622 width of solder mask opening.
1623 @item Name
1624 name of pin
1625 @item Number
1626 number of pin
1627 @item SFlags
1628 symbolic or numerical flags
1629 @item NFlags
1630 numerical flags only
1631 @end table
1633 %end-doc */
1635 pad_hi_format
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,
1643 $10, $11, $12);
1644 free ($10);
1645 free ($11);
1649 pad_1.7_format
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));
1657 free ($10);
1658 free ($11);
1662 pad_newformat
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));
1668 free ($8);
1669 free ($9);
1674 /* x1, y1, x2, y2, thickness, name and flags */
1675 : T_PAD '(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
1677 char p_number[8];
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));
1682 free ($8);
1686 flags : NUMBER { $$ = OldFlags($1); }
1687 | STRING { $$ = string_to_flags ($1, yyerror); }
1690 symbols
1691 : symbol
1692 | symbols symbol
1695 /* %start-doc pcbfile Symbol
1697 @syntax
1698 Symbol [Char Delta] (
1699 Symbol (Char Delta) (
1700 @ @ @ @dots{} symbol lines @dots{}
1702 @end syntax
1704 @table @var
1705 @item Char
1706 The character or numerical character value this symbol represents.
1707 Characters must be in single quotes.
1708 @item Delta
1709 Additional space to allow after this character.
1710 @end table
1712 %end-doc */
1714 symbol
1715 : T_SYMBOL '[' symbolid NUMBER ']' '('
1717 if ($3 <= 0 || $3 > MAX_FONTPOSITION)
1719 yyerror("fontposition out of range");
1720 YYABORT;
1722 Symbol = &yyFont->Symbol[$3];
1723 if (Symbol->Valid)
1725 yyerror("symbol ID used twice");
1726 YYABORT;
1728 Symbol->Valid = true;
1729 Symbol->Delta = $4;
1731 symboldata ')'
1732 | T_SYMBOL '(' symbolid NUMBER ')' '('
1734 if ($3 <= 0 || $3 > MAX_FONTPOSITION)
1736 yyerror("fontposition out of range");
1737 YYABORT;
1739 Symbol = &yyFont->Symbol[$3];
1740 if (Symbol->Valid)
1742 yyerror("symbol ID used twice");
1743 YYABORT;
1745 Symbol->Valid = true;
1746 Symbol->Delta = $4*100;
1748 symboldata ')'
1751 symbolid
1752 : NUMBER
1753 | CHAR_CONST
1756 symboldata
1757 : symboldefinitions
1758 | symboldata symboldefinitions
1761 symboldefinitions
1762 : symboldefinition
1763 | hiressymbol
1767 /* %start-doc pcbfile SymbolLine
1769 @syntax
1770 SymbolLine [X1 Y1 X2 Y1 Thickness]
1771 SymbolLine (X1 Y1 X2 Y1 Thickness)
1772 @end syntax
1774 @table @var
1775 @item X1 Y1 X2 Y2
1776 The endpoints of this line.
1777 @item Thickness
1778 The width of this line.
1779 @end table
1781 %end-doc */
1783 symboldefinition
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);
1790 hiressymbol
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
1800 @syntax
1801 Netlist ( ) (
1802 @ @ @ @dots{} nets @dots{}
1804 @end syntax
1806 %end-doc */
1808 pcbnetlist : pcbnetdef
1811 pcbnetdef
1812 /* net(...) net(...) ... */
1813 : T_NETLIST '(' ')' '('
1814 nets ')'
1817 nets
1818 : netdefs
1822 netdefs
1823 : net
1824 | netdefs net
1827 /* %start-doc pcbfile Net
1829 @syntax
1830 Net ("Name" "Style") (
1831 @ @ @ @dots{} connects @dots{}
1833 @end syntax
1835 @table @var
1836 @item Name
1837 The name of this net.
1838 @item Style
1839 The routing style that should be used when autorouting this net.
1840 @end table
1842 %end-doc */
1845 /* name style pin pin ... */
1846 : T_NET '(' STRING STRING ')' '('
1848 Menu = CreateNewNet(&yyPCB->NetlistLib, $3, $4);
1849 free ($3);
1850 free ($4);
1852 connections ')'
1855 connections
1856 : conndefs
1860 conndefs
1861 : conn
1862 | conndefs conn
1865 /* %start-doc pcbfile Connect
1867 @syntax
1868 Connect ("PinPad")
1869 @end syntax
1871 @table @var
1872 @item PinPad
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.
1876 @end table
1878 %end-doc */
1880 conn
1881 : T_CONN '(' STRING ')'
1883 CreateNewConnection(Menu, $3);
1884 free ($3);
1888 /* %start-doc pcbfile Attribute
1890 @syntax
1891 Attribute ("Name" "Value")
1892 @end syntax
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.
1898 @table @var
1899 @item Name
1900 The name of the attribute
1902 @item Value
1903 The value of the attribute. Values are always stored as strings, even
1904 if the value is interpreted as, for example, a number.
1906 @end table
1908 %end-doc */
1910 attributes : attribute
1911 | attributes attribute
1913 attribute
1914 : T_ATTRIBUTE '(' STRING STRING ')'
1916 CreateNewAttribute (attr_list, $3, $4 ? $4 : "");
1917 free ($3);
1918 free ($4);
1922 opt_string : STRING { $$ = $1; }
1923 | /* empty */ { $$ = 0; }
1928 /* ---------------------------------------------------------------------------
1929 * error routine called by parser library
1931 int yyerror(s)
1932 const char *s;
1934 Message("ERROR parsing file '%s'\n"
1935 " line: %i\n"
1936 " description: '%s'\n",
1937 yyfilename, yylineno, s);
1938 return(0);
1941 int yywrap()
1943 return 1;
1947 static int
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);
1957 return 1;
1960 return 0;