Add support for filling / thindrawing raw polygons to the HID interface
[geda-pcb/gde.git] / src / parse_y.y
blobdba260315551bd348e68f32cf9e7f695285967bb
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 Boolean LayerFlag[MAX_LAYER + 2];
73 extern char *yytext; /* defined by LEX */
74 extern PCBTypePtr yyPCB;
75 extern DataTypePtr yyData;
76 extern ElementTypePtr yyElement;
77 extern FontTypePtr yyFont;
78 extern int yylineno; /* linenumber */
79 extern char *yyfilename; /* in this file */
81 static char *layer_group_string;
83 static AttributeListTypePtr attr_list;
85 int yyerror(const char *s);
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_NETLIST T_NET T_CONN
106 %token T_AREA T_THERMAL T_DRC T_ATTRIBUTE
108 %type <number> symbolid
109 %type <string> opt_string
110 %type <flagtype> flags
114 parse
115 : parsepcb
116 | parsedata
117 | parsefont
118 | error { YYABORT; }
121 /* %start-doc pcbfile 00pcb
122 @nodetype subsection
123 @nodename %s syntax
125 A special note about units: Older versions of @code{pcb} used mils
126 (1/1000 inch) as the base unit; a value of 500 in the file meant
127 half an inch. Newer versions uses a "high resolution" syntax,
128 where the base unit is 1/100 of a mil (0.000010 inch); a value of 500 in
129 the file means 5 mils. As a general rule, the variants of each entry
130 listed below which use square brackets are the high resolution formats
131 and use the 1/100 mil units, and the ones with parentheses are the older
132 variants and use 1 mil units. Note that when multiple variants
133 are listed, the most recent (and most preferred) format is the first
134 listed.
136 Symbolic and numeric flags (SFlags and NFlags) are described in
137 @ref{Object Flags}.
139 %end-doc */
141 parsepcb
143 /* reset flags for 'used layers';
144 * init font and data pointers
146 int i;
148 if (!yyPCB)
150 Message("illegal fileformat\n");
151 YYABORT;
153 for (i = 0; i < MAX_LAYER + 2; i++)
154 LayerFlag[i] = False;
155 yyFont = &yyPCB->Font;
156 yyData = yyPCB->Data;
157 yyData->pcb = (void *)yyPCB;
158 yyData->LayerN = 0;
159 layer_group_string = NULL;
161 pcbfileversion
162 pcbname
163 pcbgrid
164 pcbcursor
165 polyarea
166 pcbthermal
167 pcbdrc
168 pcbflags
169 pcbgroups
170 pcbstyles
171 pcbfont
172 pcbdata
173 pcbnetlist
175 int i, j;
176 PCBTypePtr pcb_save = PCB;
178 if (layer_group_string == NULL)
179 layer_group_string = Settings.Groups;
180 CreateNewPCBPost (yyPCB, 0);
181 if (ParseGroupString(layer_group_string, &yyPCB->LayerGroups, yyData->LayerN))
183 Message("illegal layer-group string\n");
184 YYABORT;
186 /* initialize the polygon clipping now since
187 * we didn't know the layer grouping before.
189 PCB = yyPCB;
190 for (i = 0; i < yyData->LayerN+2; i++)
191 for (j = 0; j < yyData->Layer[i].PolygonN; j++)
192 InitClip (yyData, &yyData->Layer[i], &yyData->Layer[i].Polygon[j]);
193 PCB = pcb_save;
196 | { PreLoadElementPCB ();
197 layer_group_string = NULL; }
198 element
199 { LayerFlag[0] = True;
200 LayerFlag[1] = True;
201 yyData->LayerN = 2;
202 PostLoadElementPCB ();
206 parsedata
208 /* reset flags for 'used layers';
209 * init font and data pointers
211 int i;
213 if (!yyData || !yyFont)
215 Message("illegal fileformat\n");
216 YYABORT;
218 for (i = 0; i < MAX_LAYER + 2; i++)
219 LayerFlag[i] = False;
220 yyData->LayerN = 0;
222 pcbdata
225 pcbfont
226 : parsefont
230 parsefont
233 /* mark all symbols invalid */
234 int i;
236 if (!yyFont)
238 Message("illegal fileformat\n");
239 YYABORT;
241 yyFont->Valid = False;
242 for (i = 0; i <= MAX_FONTPOSITION; i++)
243 yyFont->Symbol[i].Valid = False;
245 symbols
247 yyFont->Valid = True;
248 SetFontInfo(yyFont);
252 /* %start-doc pcbfile FileVersion
254 @syntax
255 FileVersion[Version]
256 @end syntax
258 @table @var
259 @item Version
260 File format version. This version number represents the date when the pcb file
261 format was last changed.
262 @end table
264 Any version of pcb build from sources equal to or newer
265 than this number should be able to read the file. If this line is not present
266 in the input file then file format compatibility is not checked.
269 %end-doc */
271 pcbfileversion
273 T_FILEVERSION '[' NUMBER ']'
275 if (check_file_version ($3) != 0)
277 YYABORT;
282 /* %start-doc pcbfile Grid
284 /* %start-doc pcbfile PCB
286 @syntax
287 PCB ["Name" Width Height]
288 PCB ("Name" Width Height]
289 PCB ("Name")
290 @end syntax
292 @table @var
293 @item Name
294 Name of the PCB project
295 @item Width Height
296 Size of the board
297 @end table
299 If you don't specify the size of the board, a very large default is
300 chosen.
302 %end-doc */
304 pcbname
305 : T_PCB '(' STRING ')'
307 yyPCB->Name = $3;
308 yyPCB->MaxWidth = MAX_COORD;
309 yyPCB->MaxHeight = MAX_COORD;
311 | T_PCB '(' STRING NUMBER NUMBER ')'
313 yyPCB->Name = $3;
314 yyPCB->MaxWidth = $4*100;
315 yyPCB->MaxHeight = $5*100;
317 | T_PCB '[' STRING NUMBER NUMBER ']'
319 yyPCB->Name = $3;
320 yyPCB->MaxWidth = $4;
321 yyPCB->MaxHeight = $5;
325 /* %start-doc pcbfile Grid
327 @syntax
328 Grid [Step OffsetX OffsetY Visible]
329 Grid (Step OffsetX OffsetY Visible)
330 Grid (Step OffsetX OffsetY)
331 @end syntax
333 @table @var
334 @item Step
335 Distance from one grid point to adjacent points. This value may be a
336 floating point number for the first two variants.
337 @item OffsetX OffsetY
338 The "origin" of the grid. Normally zero.
339 @item Visible
340 If non-zero, the grid will be visible on the screen.
341 @end table
343 %end-doc */
345 pcbgrid
346 : pcbgridold
347 | pcbgridnew
348 | pcb2grid
349 | pcbhigrid
351 pcbgridold
352 : T_GRID '(' NUMBER NUMBER NUMBER ')'
354 yyPCB->Grid = $3*100;
355 yyPCB->GridOffsetX = $4*100;
356 yyPCB->GridOffsetY = $5*100;
359 pcbgridnew
360 : T_GRID '(' NUMBER NUMBER NUMBER NUMBER ')'
362 yyPCB->Grid = $3*100;
363 yyPCB->GridOffsetX = $4*100;
364 yyPCB->GridOffsetY = $5*100;
365 if ($6)
366 Settings.DrawGrid = True;
367 else
368 Settings.DrawGrid = False;
372 pcb2grid
373 : T_GRID '(' FLOAT NUMBER NUMBER NUMBER ')'
375 yyPCB->Grid = $3*100;
376 yyPCB->GridOffsetX = $4*100;
377 yyPCB->GridOffsetY = $5*100;
378 if ($6)
379 Settings.DrawGrid = True;
380 else
381 Settings.DrawGrid = False;
384 pcbhigrid
385 : T_GRID '[' FLOAT NUMBER NUMBER NUMBER ']'
387 yyPCB->Grid = $3;
388 yyPCB->GridOffsetX = $4;
389 yyPCB->GridOffsetY = $5;
390 if ($6)
391 Settings.DrawGrid = True;
392 else
393 Settings.DrawGrid = False;
397 /* %start-doc pcbfile Cursor
399 @syntax
400 Cursor [X Y Zoom]
401 Cursor (X Y Zoom)
402 @end syntax
404 @table @var
405 @item X Y
406 Location of the cursor when the board was saved.
407 @item Zoom
408 The current zoom factor. Note that a zoom factor of "0" means 1 mil
409 per screen pixel, N means @math{2^N} mils per screen pixel, etc. The
410 first variant accepts floating point numbers. The special value
411 "1000" means "zoom to fit"
412 @end table
414 %end-doc */
416 pcbcursor
417 : T_CURSOR '(' NUMBER NUMBER NUMBER ')'
419 yyPCB->CursorX = $3*100;
420 yyPCB->CursorY = $4*100;
421 yyPCB->Zoom = $5*2;
423 | T_CURSOR '[' NUMBER NUMBER NUMBER ']'
425 yyPCB->CursorX = $3;
426 yyPCB->CursorY = $4;
427 yyPCB->Zoom = $5;
429 | T_CURSOR '[' NUMBER NUMBER FLOAT ']'
431 yyPCB->CursorX = $3;
432 yyPCB->CursorY = $4;
433 yyPCB->Zoom = $5;
438 /* %start-doc pcbfile PolyArea
440 @syntax
441 PolyArea [Area]
442 @end syntax
444 @table @var
445 @item Area
446 Minimum area of polygon island to retain. If a polygon has clearances that cause an isolated island to be created, then will only be retained if the area exceeds this minimum area.
447 @end table
449 %end-doc */
451 polyarea
453 | T_AREA '[' FLOAT ']'
455 yyPCB->IsleArea = $3;
460 /* %start-doc pcbfile Thermal
462 @syntax
463 Thermal [Scale]
464 @end syntax
466 @table @var
467 @item Scale
468 Relative size of thermal fingers. A value of 1.0 makes the finger
469 width twice the clearance gap width (measured across the gap, not
470 diameter). The normal value is 0.5, which results in a finger width
471 the same as the clearance gap width.
472 @end table
474 %end-doc */
477 pcbthermal
479 | T_THERMAL '[' FLOAT ']'
481 yyPCB->ThermScale = $3;
485 /* %start-doc pcbfile DRC
487 @syntax
488 DRC [Bloat Shrink Line Silk Drill Ring]
489 DRC [Bloat Shrink Line Silk]
490 DRC [Bloat Shrink Line]
491 @end syntax
493 @table @var
494 @item Bloat
495 Minimum spacing between copper.
496 @item Shrink
497 Minimum copper overlap to guarantee connectivity.
498 @item Line
499 Minimum line thickness.
500 @item Silk
501 Minimum silk thickness.
502 @item Drill
503 Minimum drill size.
504 @item Ring
505 Minimum width of the annular ring around pins and vias.
506 @end table
508 %end-doc */
510 pcbdrc
512 | pcbdrc1
513 | pcbdrc2
514 | pcbdrc3
517 pcbdrc1
518 : T_DRC '[' NUMBER NUMBER NUMBER ']'
520 yyPCB->Bloat = $3;
521 yyPCB->Shrink = $4;
522 yyPCB->minWid = $5;
523 yyPCB->minRing = $5;
527 pcbdrc2
528 : T_DRC '[' NUMBER NUMBER NUMBER NUMBER ']'
530 yyPCB->Bloat = $3;
531 yyPCB->Shrink = $4;
532 yyPCB->minWid = $5;
533 yyPCB->minSlk = $6;
534 yyPCB->minRing = $5;
538 pcbdrc3
539 : T_DRC '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ']'
541 yyPCB->Bloat = $3;
542 yyPCB->Shrink = $4;
543 yyPCB->minWid = $5;
544 yyPCB->minSlk = $6;
545 yyPCB->minDrill = $7;
546 yyPCB->minRing = $8;
550 /* %start-doc pcbfile Flags
552 @syntax
553 Flags(Number)
554 @end syntax
556 @table @var
557 @item Number
558 A number, whose value is normally given in hex, individual bits of which
559 represent pcb-wide flags as defined in @ref{PCBFlags}.
561 @end table
563 %end-doc */
565 pcbflags
566 : T_FLAGS '(' NUMBER ')'
568 yyPCB->Flags = MakeFlags ($3 & PCB_FLAGS);
570 | T_FLAGS '(' STRING ')'
572 yyPCB->Flags = string_to_pcbflags ($3, yyerror);
577 /* %start-doc pcbfile Groups
579 @syntax
580 Groups("String")
581 @end syntax
583 @table @var
584 @item String
586 Encodes the layer grouping information. Each group is separated by a
587 colon, each member of each group is separated by a comma. Group
588 members are either numbers from @code{1}..@var{N} for each layer, and
589 the letters @code{c} or @code{s} representing the component side and
590 solder side of the board. Including @code{c} or @code{s} marks that
591 group as being the top or bottom side of the board.
593 @example
594 Groups("1,2,c:3:4:5,6,s:7,8")
595 @end example
597 @end table
599 %end-doc */
601 pcbgroups
602 : T_GROUPS '(' STRING ')'
604 layer_group_string = $3;
609 /* %start-doc pcbfile Styles
611 @syntax
612 Styles("String")
613 @end syntax
615 @table @var
616 @item String
618 Encodes the four routing styles @code{pcb} knows about. The four styles
619 are separated by colons. Each style consists of five parameters as follows:
621 @table @var
622 @item Name
623 The name of the style.
624 @item Thickness
625 Width of lines and arcs.
626 @item Diameter
627 Copper diameter of pins and vias.
628 @item Drill
629 Drill diameter of pins and vias.
630 @item Keepaway
631 Minimum spacing to other nets. If omitted, 10 mils is the default.
633 @end table
635 @end table
637 @example
638 Styles("Signal,10,40,20:Power,25,60,35:Fat,40,60,35:Skinny,8,36,20")
639 Styles["Logic,1000,3600,2000,1000:Power,2500,6000,3500,1000:
640 @ @ @ Line,4000,6000,3500,1000:Breakout,600,2402,1181,600"]
641 @end example
643 @noindent
644 Note that strings in actual files cannot span lines; the above example
645 is split across lines only to make it readable.
647 %end-doc */
649 pcbstyles
650 : T_STYLES '(' STRING ')'
652 if (ParseRouteString($3, &yyPCB->RouteStyle[0], 100))
654 Message("illegal route-style string\n");
655 YYABORT;
658 | T_STYLES '[' STRING ']'
660 if (ParseRouteString($3, &yyPCB->RouteStyle[0], 1))
662 Message("illegal route-style string\n");
663 YYABORT;
669 pcbdata
670 : pcbdefinitions
674 pcbdefinitions
675 : pcbdefinition
676 | pcbdefinitions pcbdefinition
679 pcbdefinition
680 : via
681 | { attr_list = & yyPCB->Attributes; } attributes
682 | rats
683 | layer
686 /* clear pointer to force memory allocation by
687 * the appropriate subroutine
689 yyElement = NULL;
691 element
692 | error { YYABORT; }
696 : via_hi_format
697 | via_2.0_format
698 | via_1.7_format
699 | via_newformat
700 | via_oldformat
703 /* %start-doc pcbfile Via
705 @syntax
706 Via [X Y Thickness Clearance Mask Drill "Name" SFlags]
707 Via (X Y Thickness Clearance Mask Drill "Name" NFlags)
708 Via (X Y Thickness Clearance Drill "Name" NFlags)
709 Via (X Y Thickness Drill "Name" NFlags)
710 Via (X Y Thickness "Name" NFlags)
711 @end syntax
713 @table @var
714 @item X Y
715 coordinates of center
716 @item Thickness
717 outer diameter of copper annulus
718 @item Clearance
719 add to thickness to get clearance diameter
720 @item Mask
721 diameter of solder mask opening
722 @item Drill
723 diameter of drill
724 @item Name
725 string, name of via (vias have names?)
726 @item SFlags
727 symbolic or numerical flags
728 @item NFlags
729 numerical flags only
730 @end table
732 %end-doc */
734 via_hi_format
735 /* x, y, thickness, clearance, mask, drilling-hole, name, flags */
736 : T_VIA '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING flags ']'
738 CreateNewVia(yyData, $3, $4, $5, $6, $7, $8, $9, $10);
739 SaveFree($9);
743 via_2.0_format
744 /* x, y, thickness, clearance, mask, drilling-hole, name, flags */
745 : T_VIA '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
747 CreateNewVia(yyData, $3*100, $4*100, $5*100, $6*100, $7*100, $8*100, $9,
748 OldFlags($10));
749 SaveFree($9);
754 via_1.7_format
755 /* x, y, thickness, clearance, drilling-hole, name, flags */
756 : T_VIA '(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
758 CreateNewVia(yyData, $3*100, $4*100, $5*100, $6*100,
759 ($5 + $6)*100, $7*100, $8, OldFlags($9));
760 SaveFree($8);
764 via_newformat
765 /* x, y, thickness, drilling-hole, name, flags */
766 : T_VIA '(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
768 CreateNewVia(yyData, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
769 ($5 + 2*MASKFRAME)*100, $6*100, $7, OldFlags($8));
770 SaveFree($7);
774 via_oldformat
775 /* old format: x, y, thickness, name, flags */
776 : T_VIA '(' NUMBER NUMBER NUMBER STRING NUMBER ')'
778 BDimension hole = ($5 *DEFAULT_DRILLINGHOLE);
780 /* make sure that there's enough copper left */
781 if ($5 -hole < MIN_PINORVIACOPPER &&
782 $5 > MIN_PINORVIACOPPER)
783 hole = $5 -MIN_PINORVIACOPPER;
785 CreateNewVia(yyData, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
786 ($5 + 2*MASKFRAME)*100, hole, $6, OldFlags($7));
787 SaveFree($6);
791 /* %start-doc pcbfile Rat
793 @syntax
794 Rat [X1 Y1 Group1 X2 Y2 Group2 SFlags]
795 Rat (X1 Y1 Group1 X2 Y2 Group2 NFlags)
796 @end syntax
798 @table @var
799 @item X1 Y1 X2 Y2
800 The endpoints of the rat line.
801 @item Group1 Group2
802 The layer group each end is connected on.
803 @item SFlags
804 Symbolic or numeric flags.
805 @item NFlags
806 Numeric flags.
807 @end table
809 %end-doc */
811 rats
812 : T_RAT '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags ']'
814 CreateNewRat(yyData, $3, $4, $6, $7, $5, $8,
815 Settings.RatThickness, $9);
817 | T_RAT '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
819 CreateNewRat(yyData, $3*100, $4*100, $6*100, $7*100, $5, $8,
820 Settings.RatThickness, OldFlags($9));
824 /* %start-doc pcbfile Layer
826 @syntax
827 Layer (LayerNum "Name") (
828 @ @ @ @dots{} contents @dots{}
830 @end syntax
832 @table @var
833 @item LayerNum
834 The layer number. Layers are numbered sequentially, starting with 1.
835 The last two layers (9 and 10 by default) are solder-side silk and
836 component-side silk, in that order.
837 @item Name
838 The layer name.
839 @item contents
840 The contents of the layer, which may include lines, arcs, rectangles,
841 text, and polygons.
842 @end table
844 %end-doc */
846 layer
847 /* name */
848 : T_LAYER '(' NUMBER STRING opt_string ')' '('
850 if ($3 <= 0 || $3 > MAX_LAYER + 2)
852 yyerror("Layernumber out of range");
853 YYABORT;
855 if (LayerFlag[$3-1])
857 yyerror("Layernumber used twice");
858 YYABORT;
860 Layer = &yyData->Layer[$3-1];
862 /* memory for name is already allocated */
863 Layer->Name = $4;
864 LayerFlag[$3-1] = True;
865 if (yyData->LayerN + 2 < $3)
866 yyData->LayerN = $3 - 2;
868 layerdata ')'
871 layerdata
872 : layerdefinitions
876 layerdefinitions
877 : layerdefinition
878 | layerdefinitions layerdefinition
881 layerdefinition
882 : line_hi_format
883 | line_1.7_format
884 | line_oldformat
885 | arc_hi_format
886 | arc_1.7_format
887 | arc_oldformat
888 /* x1, y1, x2, y2, flags */
889 | T_RECTANGLE '(' NUMBER NUMBER NUMBER NUMBER NUMBER ')'
891 CreateNewPolygonFromRectangle(Layer,
892 $3*100, $4*100, ($3+$5)*100, ($4+$6)*100, OldFlags($7));
894 | text_hi_format
895 | text_newformat
896 | text_oldformat
897 /* flags are passed in */
898 | T_POLYGON '(' flags ')' '('
900 Polygon = CreateNewPolygon(Layer, $3);
902 polygonpoints ')'
904 /* ignore junk */
905 if (Polygon->PointN >= 3)
907 SetPolygonBoundingBox (Polygon);
908 if (!Layer->polygon_tree)
909 Layer->polygon_tree = r_create_tree (NULL, 0, 0);
910 r_insert_entry (Layer->polygon_tree, (BoxType *) Polygon, 0);
912 else
914 Message("WARNING parsing file '%s'\n"
915 " line: %i\n"
916 " description: 'ignored polygon (< 3 points)'\n",
917 yyfilename, yylineno);
918 DestroyObject(yyData, POLYGON_TYPE, Layer, Polygon, Polygon);
923 /* %start-doc pcbfile Line
925 @syntax
926 Line [X1 Y1 X2 Y2 Thickness Clearance SFlags]
927 Line (X1 Y1 X2 Y2 Thickness Clearance NFlags)
928 Line (X1 Y1 X2 Y2 Thickness NFlags)
929 @end syntax
931 @table @var
932 @item X1 Y1 X2 Y2
933 The end points of the line
934 @item Thickness
935 The width of the line
936 @item Clearance
937 The amount of space cleared around the line when the line passes
938 through a polygon. The clearance is added to the thickness to get the
939 thickness of the clear; thus the space between the line and the
940 polygon is @math{Clearance/2} wide.
941 @item SFlags
942 Symbolic or numeric flags
943 @item NFlags
944 Numeric flags.
945 @end table
947 %end-doc */
949 line_hi_format
950 /* x1, y1, x2, y2, thickness, clearance, flags */
951 : T_LINE '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags ']'
953 CreateNewLineOnLayer(Layer, $3, $4, $5, $6, $7, $8, $9);
957 line_1.7_format
958 /* x1, y1, x2, y2, thickness, clearance, flags */
959 : T_LINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
961 CreateNewLineOnLayer(Layer, $3*100, $4*100, $5*100, $6*100,
962 $7*100, $8*100, OldFlags($9));
966 line_oldformat
967 /* x1, y1, x2, y2, thickness, flags */
968 : T_LINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
970 /* eliminate old-style rat-lines */
971 if (($8 & RATFLAG) == 0)
972 CreateNewLineOnLayer(Layer, $3*100, $4*100, $5*100, $6*100, $7*100,
973 200*GROUNDPLANEFRAME, OldFlags($8));
977 /* %start-doc pcbfile Arc
979 @syntax
980 Arc [X Y Width Height Thickness Clearance StartAngle DeltaAngle SFlags]
981 Arc (X Y Width Height Thickness Clearance StartAngle DeltaAngle NFlags)
982 Arc (X Y Width Height Thickness StartAngle DeltaAngle NFlags)
983 @end syntax
985 @table @var
986 @item X Y
987 Coordinates of the center of the arc.
988 @item Width Height
989 The width and height, from the center to the edge. The bounds of the
990 circle of which this arc is a segment, is thus @math{2*Width} by
991 @math{2*Height}.
992 @item Thickness
993 The width of the copper trace which forms the arc.
994 @item Clearance
995 The amount of space cleared around the arc when the line passes
996 through a polygon. The clearance is added to the thickness to get the
997 thickness of the clear; thus the space between the arc and the polygon
998 is @math{Clearance/2} wide.
999 @item StartAngle
1000 The angle of one end of the arc, in degrees. In PCB, an angle of zero
1001 points left (negative X direction), and 90 degrees points down
1002 (positive Y direction).
1003 @item DeltaAngle
1004 The sweep of the arc. This may be negative. Positive angles sweep
1005 counterclockwise.
1006 @item SFlags
1007 Symbolic or numeric flags.
1008 @item NFlags
1009 Numeric flags.
1010 @end table
1012 %end-doc */
1014 arc_hi_format
1015 /* x, y, width, height, thickness, clearance, startangle, delta, flags */
1016 : T_ARC '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags ']'
1018 CreateNewArcOnLayer(Layer, $3, $4, $5, $6, $9, $10, $7, $8, $11);
1022 arc_1.7_format
1023 /* x, y, width, height, thickness, clearance, startangle, delta, flags */
1024 : T_ARC '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1026 CreateNewArcOnLayer(Layer, $3*100, $4*100, $5*100, $6*100, $9, $10,
1027 $7*100, $8*100, OldFlags($11));
1031 arc_oldformat
1032 /* x, y, width, height, thickness, startangle, delta, flags */
1033 : T_ARC '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1035 CreateNewArcOnLayer(Layer, $3*100, $4*100, $5*100, $5*100, $8, $9,
1036 $7*100, 200*GROUNDPLANEFRAME, OldFlags($10));
1040 /* %start-doc pcbfile Text
1042 @syntax
1043 Text [X Y Direction Scale "String" SFlags]
1044 Text (X Y Direction Scale "String" NFlags)
1045 Text (X Y Direction "String" NFlags)
1046 @end syntax
1048 @table @var
1049 @item X Y
1050 The location of the upper left corner of the text.
1051 @item Direction
1052 0 means text is drawn left to right, 1 means up, 2 means right to left
1053 (i.e. upside down), and 3 means down.
1054 @item Scale
1055 Size of the text, as a percentage of the ``default'' size of of the
1056 font (the default font is about 40 mils high). Default is 100 (40
1057 mils).
1058 @item String
1059 The string to draw.
1060 @item SFlags
1061 Symbolic or numeric flags.
1062 @item NFlags
1063 Numeric flags.
1064 @end table
1066 %end-doc */
1068 text_oldformat
1069 /* x, y, direction, text, flags */
1070 : T_TEXT '(' NUMBER NUMBER NUMBER STRING NUMBER ')'
1072 /* use a default scale of 100% */
1073 CreateNewText(Layer,yyFont,$3*100, $4*100, $5, 100, $6, OldFlags($7));
1074 SaveFree($6);
1078 text_newformat
1079 /* x, y, direction, scale, text, flags */
1080 : T_TEXT '(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
1082 if ($8 & ONSILKFLAG)
1084 LayerTypePtr lay = &yyData->Layer[yyData->LayerN +
1085 (($8 & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)];
1087 CreateNewText(lay ,yyFont, $3*100, $4*100, $5, $6, $7,
1088 OldFlags($8));
1090 else
1091 CreateNewText(Layer, yyFont, $3*100, $4*100, $5, $6, $7,
1092 OldFlags($8));
1093 SaveFree($7);
1096 text_hi_format
1097 /* x, y, direction, scale, text, flags */
1098 : T_TEXT '[' NUMBER NUMBER NUMBER NUMBER STRING flags ']'
1100 /* FIXME: shouldn't know about .f */
1101 /* I don't think this matters because anything with hi_format
1102 * will have the silk on its own layer in the file rather
1103 * than using the ONSILKFLAG and having it in a copper layer.
1104 * Thus there is no need for anything besides the 'else'
1105 * part of this code.
1107 if ($8.f & ONSILKFLAG)
1109 LayerTypePtr lay = &yyData->Layer[yyData->LayerN +
1110 (($8.f & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)];
1112 CreateNewText(lay, yyFont, $3, $4, $5, $6, $7, $8);
1114 else
1115 CreateNewText(Layer, yyFont, $3, $4, $5, $6, $7, $8);
1116 SaveFree($7);
1120 /* %start-doc pcbfile Polygon
1122 @syntax
1123 Polygon (SFlags) (
1124 @ @ @ @dots{} (X Y) @dots{}
1125 @ @ @ @dots{} [X Y] @dots{}
1127 @end syntax
1129 @table @var
1130 @item SFlags
1131 Symbolic or numeric flags.
1132 @item X Y
1133 Coordinates of each vertex. You must list at least three coordinates.
1134 @end table
1136 %end-doc */
1138 polygonpoints
1139 : polygonpoint
1140 | polygonpoints polygonpoint
1143 polygonpoint
1144 /* xcoord ycoord */
1145 : '(' NUMBER NUMBER ')'
1147 CreateNewPointInPolygon(Polygon, $2*100, $3*100);
1149 | '[' NUMBER NUMBER ']'
1151 CreateNewPointInPolygon(Polygon, $2, $3);
1156 /* %start-doc pcbfile Element
1158 @syntax
1159 Element [SFlags "Desc" "Name" "Value" MX MY TX TY TDir TScale TSFlags] (
1160 Element (NFlags "Desc" "Name" "Value" MX MY TX TY TDir TScale TNFlags) (
1161 Element (NFlags "Desc" "Name" "Value" TX TY TDir TScale TNFlags) (
1162 Element (NFlags "Desc" "Name" TX TY TDir TScale TNFlags) (
1163 Element ("Desc" "Name" TX TY TDir TScale TNFlags) (
1164 @ @ @ @dots{} contents @dots{}
1166 @end syntax
1168 @table @var
1169 @item SFlags
1170 Symbolic or numeric flags, for the element as a whole.
1171 @item NFlags
1172 Numeric flags, for the element as a whole.
1173 @item Desc
1174 The description of the element. This is one of the three strings
1175 which can be displayed on the screen.
1176 @item Name
1177 The name of the element, usually the reference designator.
1178 @item Value
1179 The value of the element.
1180 @item MX MY
1181 The location of the element's mark. This is the reference point
1182 for placing the element and its pins and pads.
1183 @item TX TY
1184 The upper left corner of the text (one of the three strings).
1185 @item TDir
1186 The relative direction of the text. 0 means left to right for
1187 an unrotated element, 1 means up, 2 left, 3 down.
1188 @item TScale
1189 Size of the text, as a percentage of the ``default'' size of of the
1190 font (the default font is about 40 mils high). Default is 100 (40
1191 mils).
1192 @item TSFlags
1193 Symbolic or numeric flags, for the text.
1194 @item TNFlags
1195 Numeric flags, for the text.
1196 @end table
1198 Elements may contain pins, pads, element lines, element arcs,
1199 attributes, and (for older elements) an optional mark. Note that
1200 element definitions that have the mark coordinates in the element
1201 line, only support pins and pads which use relative coordinates. The
1202 pin and pad coordinates are relative to the mark. Element definitions
1203 which do not include the mark coordinates in the element line, may
1204 have a Mark definition in their contents, and only use pin and pad
1205 definitions which use absolute coordinates.
1207 %end-doc */
1209 element
1210 : element_oldformat
1211 | element_1.3.4_format
1212 | element_newformat
1213 | element_1.7_format
1214 | element_hi_format
1217 element_oldformat
1218 /* element_flags, description, pcb-name,
1219 * text_x, text_y, text_direction, text_scale, text_flags
1221 : T_ELEMENT '(' STRING STRING NUMBER NUMBER NUMBER ')' '('
1223 yyElement = CreateNewElement(yyData, yyElement, yyFont, NoFlags(),
1224 $3, $4, NULL, $5*100, $6*100, $7, 100, NoFlags(), False);
1225 SaveFree($3);
1226 SaveFree($4);
1227 pin_num = 1;
1229 elementdefinitions ')'
1231 SetElementBoundingBox(yyData, yyElement, yyFont);
1235 element_1.3.4_format
1236 /* element_flags, description, pcb-name,
1237 * text_x, text_y, text_direction, text_scale, text_flags
1239 : T_ELEMENT '(' NUMBER STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER ')' '('
1241 yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3),
1242 $4, $5, NULL, $6*100, $7*100, $8, $9, OldFlags($10), False);
1243 SaveFree($4);
1244 SaveFree($5);
1245 pin_num = 1;
1247 elementdefinitions ')'
1249 SetElementBoundingBox(yyData, yyElement, yyFont);
1253 element_newformat
1254 /* element_flags, description, pcb-name, value,
1255 * text_x, text_y, text_direction, text_scale, text_flags
1257 : T_ELEMENT '(' NUMBER STRING STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER ')' '('
1259 yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3),
1260 $4, $5, $6, $7*100, $8*100, $9, $10, OldFlags($11), False);
1261 SaveFree($4);
1262 SaveFree($5);
1263 SaveFree($6);
1264 pin_num = 1;
1266 elementdefinitions ')'
1268 SetElementBoundingBox(yyData, yyElement, yyFont);
1272 element_1.7_format
1273 /* element_flags, description, pcb-name, value, mark_x, mark_y,
1274 * text_x, text_y, text_direction, text_scale, text_flags
1276 : T_ELEMENT '(' NUMBER STRING STRING STRING NUMBER NUMBER
1277 NUMBER NUMBER NUMBER NUMBER NUMBER ')' '('
1279 yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3),
1280 $4, $5, $6, ($7+$9)*100, ($8+$10)*100, $11, $12, OldFlags($13), False);
1281 yyElement->MarkX = $7*100;
1282 yyElement->MarkY = $8*100;
1283 SaveFree($4);
1284 SaveFree($5);
1285 SaveFree($6);
1287 relementdefs ')'
1289 SetElementBoundingBox(yyData, yyElement, yyFont);
1293 element_hi_format
1294 /* element_flags, description, pcb-name, value, mark_x, mark_y,
1295 * text_x, text_y, text_direction, text_scale, text_flags
1297 : T_ELEMENT '[' flags STRING STRING STRING NUMBER NUMBER
1298 NUMBER NUMBER NUMBER NUMBER flags ']' '('
1300 yyElement = CreateNewElement(yyData, yyElement, yyFont, $3,
1301 $4, $5, $6, ($7+$9), ($8+$10), $11, $12, $13, False);
1302 yyElement->MarkX = $7;
1303 yyElement->MarkY = $8;
1304 SaveFree($4);
1305 SaveFree($5);
1306 SaveFree($6);
1308 relementdefs ')'
1310 SetElementBoundingBox(yyData, yyElement, yyFont);
1314 /* %start-doc pcbfile ElementLine
1316 @syntax
1317 ElementLine [X1 Y1 X2 Y2 Thickness]
1318 ElementLine (X1 Y1 X2 Y2 Thickness)
1319 @end syntax
1321 @table @var
1322 @item X1 Y1 X2 Y2
1323 Coordinates of the endpoints of the line. These are relative to the
1324 Element's mark point for new element formats, or absolute for older
1325 formats.
1326 @item Thickness
1327 The width of the silk for this line.
1328 @end table
1330 %end-doc */
1332 /* %start-doc pcbfile ElementArc
1334 @syntax
1335 ElementArc [X Y Width Height StartAngle DeltaAngle Thickness]
1336 ElementArc (X Y Width Height StartAngle DeltaAngle Thickness)
1337 @end syntax
1339 @table @var
1340 @item X Y
1341 Coordinates of the center of the arc. These are relative to the
1342 Element's mark point for new element formats, or absolute for older
1343 formats.
1344 @item Width Height
1345 The width and height, from the center to the edge. The bounds of the
1346 circle of which this arc is a segment, is thus @math{2*Width} by
1347 @math{2*Height}.
1348 @item StartAngle
1349 The angle of one end of the arc, in degrees. In PCB, an angle of zero
1350 points left (negative X direction), and 90 degrees points down
1351 (positive Y direction).
1352 @item DeltaAngle
1353 The sweep of the arc. This may be negative. Positive angles sweep
1354 counterclockwise.
1355 @item Thickness
1356 The width of the silk line which forms the arc.
1357 @end table
1359 %end-doc */
1361 /* %start-doc pcbfile Mark
1363 @syntax
1364 Mark [X Y]
1365 Mark (X Y)
1366 @end syntax
1368 @table @var
1369 @item X Y
1370 Coordinates of the Mark, for older element formats that don't have
1371 the mark as part of the Element line.
1372 @end table
1374 %end-doc */
1376 elementdefinitions
1377 : elementdefinition
1378 | elementdefinitions elementdefinition
1381 elementdefinition
1382 : pin_1.6.3_format
1383 | pin_newformat
1384 | pin_oldformat
1385 | pad_newformat
1386 | pad
1387 /* x1, y1, x2, y2, thickness */
1388 | T_ELEMENTLINE '[' NUMBER NUMBER NUMBER NUMBER NUMBER ']'
1390 CreateNewLineInElement(yyElement, $3, $4, $5, $6, $7);
1392 /* x1, y1, x2, y2, thickness */
1393 | T_ELEMENTLINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1395 CreateNewLineInElement(yyElement, $3*100, $4*100, $5*100, $6*100, $7*100);
1397 /* x, y, width, height, startangle, anglediff, thickness */
1398 | T_ELEMENTARC '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ']'
1400 CreateNewArcInElement(yyElement, $3, $4, $5, $6, $7, $8, $9);
1402 /* x, y, width, height, startangle, anglediff, thickness */
1403 | T_ELEMENTARC '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1405 CreateNewArcInElement(yyElement, $3*100, $4*100, $5*100, $6*100, $7, $8, $9*100);
1407 /* x, y position */
1408 | T_MARK '[' NUMBER NUMBER ']'
1410 yyElement->MarkX = $3;
1411 yyElement->MarkY = $4;
1413 | T_MARK '(' NUMBER NUMBER ')'
1415 yyElement->MarkX = $3*100;
1416 yyElement->MarkY = $4*100;
1418 | { attr_list = & yyElement->Attributes; } attributes
1421 relementdefs
1422 : relementdef
1423 | relementdefs relementdef
1426 relementdef
1427 : pin_1.7_format
1428 | pin_hi_format
1429 | pad_1.7_format
1430 | pad_hi_format
1431 /* x1, y1, x2, y2, thickness */
1432 | T_ELEMENTLINE '[' NUMBER NUMBER NUMBER NUMBER NUMBER ']'
1434 CreateNewLineInElement(yyElement, $3 + yyElement->MarkX,
1435 $4 + yyElement->MarkY, $5 + yyElement->MarkX,
1436 $6 + yyElement->MarkY, $7);
1438 | T_ELEMENTLINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1440 CreateNewLineInElement(yyElement, $3*100 + yyElement->MarkX,
1441 $4*100 + yyElement->MarkY, $5*100 + yyElement->MarkX,
1442 $6*100 + yyElement->MarkY, $7*100);
1444 /* x, y, width, height, startangle, anglediff, thickness */
1445 | T_ELEMENTARC '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ']'
1447 CreateNewArcInElement(yyElement, $3 + yyElement->MarkX,
1448 $4 + yyElement->MarkY, $5, $6, $7, $8, $9);
1450 | T_ELEMENTARC '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1452 CreateNewArcInElement(yyElement, $3*100 + yyElement->MarkX,
1453 $4*100 + yyElement->MarkY, $5*100, $6*100, $7, $8, $9*100);
1455 | { attr_list = & yyElement->Attributes; } attributes
1458 /* %start-doc pcbfile Pin
1460 @syntax
1461 Pin [rX rY Thickness Clearance Mask Drill "Name" "Number" SFlags]
1462 Pin (rX rY Thickness Clearance Mask Drill "Name" "Number" NFlags)
1463 Pin (aX aY Thickness Drill "Name" "Number" NFlags)
1464 Pin (aX aY Thickness Drill "Name" NFlags)
1465 Pin (aX aY Thickness "Name" NFlags)
1466 @end syntax
1468 @table @var
1469 @item rX rY
1470 coordinates of center, relative to the element's mark
1471 @item aX aY
1472 absolute coordinates of center.
1473 @item Thickness
1474 outer diameter of copper annulus
1475 @item Clearance
1476 add to thickness to get clearance diameter
1477 @item Mask
1478 diameter of solder mask opening
1479 @item Drill
1480 diameter of drill
1481 @item Name
1482 name of pin
1483 @item Number
1484 number of pin
1485 @item SFlags
1486 symbolic or numerical flags
1487 @item NFlags
1488 numerical flags only
1489 @end table
1491 %end-doc */
1493 pin_hi_format
1494 /* x, y, thickness, clearance, mask, drilling hole, name,
1495 number, flags */
1496 : T_PIN '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING flags ']'
1498 CreateNewPin(yyElement, $3 + yyElement->MarkX,
1499 $4 + yyElement->MarkY, $5, $6, $7, $8, $9,
1500 $10, $11);
1501 SaveFree($9);
1502 SaveFree($10);
1505 pin_1.7_format
1506 /* x, y, thickness, clearance, mask, drilling hole, name,
1507 number, flags */
1508 : T_PIN '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER ')'
1510 CreateNewPin(yyElement, $3*100 + yyElement->MarkX,
1511 $4*100 + yyElement->MarkY, $5*100, $6*100, $7*100, $8*100, $9,
1512 $10, OldFlags($11));
1513 SaveFree($9);
1514 SaveFree($10);
1518 pin_1.6.3_format
1519 /* x, y, thickness, drilling hole, name, number, flags */
1520 : T_PIN '(' NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER ')'
1522 CreateNewPin(yyElement, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
1523 ($5 + 2*MASKFRAME)*100, $6*100, $7, $8, OldFlags($9));
1524 SaveFree($7);
1525 SaveFree($8);
1529 pin_newformat
1530 /* x, y, thickness, drilling hole, name, flags */
1531 : T_PIN '(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
1533 char p_number[8];
1535 sprintf(p_number, "%d", pin_num++);
1536 CreateNewPin(yyElement, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
1537 ($5 + 2*MASKFRAME)*100, $6*100, $7, p_number, OldFlags($8));
1539 SaveFree($7);
1543 pin_oldformat
1544 /* old format: x, y, thickness, name, flags
1545 * drilling hole is 40% of the diameter
1547 : T_PIN '(' NUMBER NUMBER NUMBER STRING NUMBER ')'
1549 BDimension hole = ($5 *DEFAULT_DRILLINGHOLE);
1550 char p_number[8];
1552 /* make sure that there's enough copper left */
1553 if ($5 -hole < MIN_PINORVIACOPPER &&
1554 $5 > MIN_PINORVIACOPPER)
1555 hole = $5 -MIN_PINORVIACOPPER;
1557 sprintf(p_number, "%d", pin_num++);
1558 CreateNewPin(yyElement, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
1559 ($5 + 2*MASKFRAME)*100, hole, $6, p_number, OldFlags($7));
1560 SaveFree($6);
1564 /* %start-doc pcbfile Pad
1566 @syntax
1567 Pad [rX1 rY1 rX2 rY2 Thickness Clearance Mask "Name" "Number" SFlags]
1568 Pad (rX1 rY1 rX2 rY2 Thickness Clearance Mask "Name" "Number" NFlags)
1569 Pad (aX1 aY1 aX2 aY2 Thickness "Name" "Number" NFlags)
1570 Pad (aX1 aY1 aX2 aY2 Thickness "Name" NFlags)
1571 @end syntax
1573 @table @var
1574 @item rX1 rY1 rX2 rY2
1575 Coordinates of the endpoints of the pad, relative to the element's
1576 mark. Note that the copper extends beyond these coordinates by half
1577 the thickness. To make a square or round pad, specify the same
1578 coordinate twice.
1579 @item aX1 aY1 aX2 aY2
1580 Same, but absolute coordinates of the endpoints of the pad.
1581 @item Thickness
1582 width of the pad.
1583 @item Clearance
1584 add to thickness to get clearance width.
1585 @item Mask
1586 width of solder mask opening.
1587 @item Name
1588 name of pin
1589 @item Number
1590 number of pin
1591 @item SFlags
1592 symbolic or numerical flags
1593 @item NFlags
1594 numerical flags only
1595 @end table
1597 %end-doc */
1599 pad_hi_format
1600 /* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */
1601 : T_PAD '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING flags ']'
1603 CreateNewPad(yyElement, $3 + yyElement->MarkX,
1604 $4 + yyElement->MarkY,
1605 $5 + yyElement->MarkX,
1606 $6 + yyElement->MarkY, $7, $8, $9,
1607 $10, $11, $12);
1608 SaveFree($10);
1609 SaveFree($11);
1613 pad_1.7_format
1614 /* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */
1615 : T_PAD '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER ')'
1617 CreateNewPad(yyElement,$3*100 + yyElement->MarkX,
1618 $4*100 + yyElement->MarkY, $5*100 + yyElement->MarkX,
1619 $6*100 + yyElement->MarkY, $7*100, $8*100, $9*100,
1620 $10, $11, OldFlags($12));
1621 SaveFree($10);
1622 SaveFree($11);
1626 pad_newformat
1627 /* x1, y1, x2, y2, thickness, name , pad number, flags */
1628 : T_PAD '(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER ')'
1630 CreateNewPad(yyElement,$3*100,$4*100,$5*100,$6*100,$7*100, 200*GROUNDPLANEFRAME,
1631 ($7 + 2*MASKFRAME)*100, $8,$9, OldFlags($10));
1632 SaveFree($8);
1633 SaveFree($9);
1638 /* x1, y1, x2, y2, thickness, name and flags */
1639 : T_PAD '(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
1641 char p_number[8];
1643 sprintf(p_number, "%d", pin_num++);
1644 CreateNewPad(yyElement,$3*100,$4*100,$5*100,$6*100,$7*100, 200*GROUNDPLANEFRAME,
1645 ($7 + 2*MASKFRAME)*100, $8,p_number, OldFlags($9));
1646 SaveFree($8);
1650 flags : NUMBER { $$ = OldFlags($1); }
1651 | STRING { $$ = string_to_flags ($1, yyerror); }
1654 symbols
1655 : symbol
1656 | symbols symbol
1659 /* %start-doc pcbfile Symbol
1661 @syntax
1662 Symbol [Char Delta] (
1663 Symbol (Char Delta) (
1664 @ @ @ @dots{} symbol lines @dots{}
1666 @end syntax
1668 @table @var
1669 @item Char
1670 The character or numerical character value this symbol represents.
1671 Characters must be in single quotes.
1672 @item Delta
1673 Additional space to allow after this character.
1674 @end table
1676 %end-doc */
1678 symbol
1679 : T_SYMBOL '[' symbolid NUMBER ']' '('
1681 if ($3 <= 0 || $3 > MAX_FONTPOSITION)
1683 yyerror("fontposition out of range");
1684 YYABORT;
1686 Symbol = &yyFont->Symbol[$3];
1687 if (Symbol->Valid)
1689 yyerror("symbol ID used twice");
1690 YYABORT;
1692 Symbol->Valid = True;
1693 Symbol->Delta = $4;
1695 symboldata ')'
1696 | T_SYMBOL '(' symbolid NUMBER ')' '('
1698 if ($3 <= 0 || $3 > MAX_FONTPOSITION)
1700 yyerror("fontposition out of range");
1701 YYABORT;
1703 Symbol = &yyFont->Symbol[$3];
1704 if (Symbol->Valid)
1706 yyerror("symbol ID used twice");
1707 YYABORT;
1709 Symbol->Valid = True;
1710 Symbol->Delta = $4*100;
1712 symboldata ')'
1715 symbolid
1716 : NUMBER
1717 | CHAR_CONST
1720 symboldata
1721 : symboldefinitions
1722 | symboldata symboldefinitions
1725 symboldefinitions
1726 : symboldefinition
1727 | hiressymbol
1731 /* %start-doc pcbfile SymbolLine
1733 @syntax
1734 SymbolLine [X1 Y1 X2 Y1 Thickness]
1735 SymbolLine (X1 Y1 X2 Y1 Thickness)
1736 @end syntax
1738 @table @var
1739 @item X1 Y1 X2 Y2
1740 The endpoints of this line.
1741 @item Thickness
1742 The width of this line.
1743 @end table
1745 %end-doc */
1747 symboldefinition
1748 /* x1, y1, x2, y2, thickness */
1749 : T_SYMBOLLINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1751 CreateNewLineInSymbol(Symbol, $3*100, $4*100, $5*100, $6*100, $7*100);
1754 hiressymbol
1755 /* x1, y1, x2, y2, thickness */
1756 : T_SYMBOLLINE '[' NUMBER NUMBER NUMBER NUMBER NUMBER ']'
1758 CreateNewLineInSymbol(Symbol, $3, $4, $5, $6, $7);
1762 /* %start-doc pcbfile Netlist
1764 @syntax
1765 Netlist ( ) (
1766 @ @ @ @dots{} nets @dots{}
1768 @end syntax
1770 %end-doc */
1772 pcbnetlist : pcbnetdef
1775 pcbnetdef
1776 /* net(...) net(...) ... */
1777 : T_NETLIST '(' ')' '('
1778 nets ')'
1781 nets
1782 : netdefs
1786 netdefs
1787 : net
1788 | netdefs net
1791 /* %start-doc pcbfile Net
1793 @syntax
1794 Net ("Name" "Style") (
1795 @ @ @ @dots{} connects @dots{}
1797 @end syntax
1799 @table @var
1800 @item Name
1801 The name of this net.
1802 @item Style
1803 The routing style that should be used when autorouting this net.
1804 @end table
1806 %end-doc */
1809 /* name style pin pin ... */
1810 : T_NET '(' STRING STRING ')' '('
1812 Menu = CreateNewNet(&yyPCB->NetlistLib, $3, $4);
1813 SaveFree($3);
1814 SaveFree($4);
1816 connections ')'
1819 connections
1820 : conndefs
1824 conndefs
1825 : conn
1826 | conndefs conn
1829 /* %start-doc pcbfile Connect
1831 @syntax
1832 Connect ("PinPad")
1833 @end syntax
1835 @table @var
1836 @item PinPad
1837 The name of a pin or pad which is included in this net. Pin and Pad
1838 names are named by the refdes and pin name, like @code{"U14-7"} for
1839 pin 7 of U14, or @code{"T4-E"} for pin E of T4.
1840 @end table
1842 %end-doc */
1844 conn
1845 : T_CONN '(' STRING ')'
1847 CreateNewConnection(Menu, $3);
1848 SaveFree($3);
1852 /* %start-doc pcbfile Attribute
1854 @syntax
1855 Attribute ("Name" "Value")
1856 @end syntax
1858 Attributes allow boards and elements to have arbitrary data attached
1859 to them, which is not directly used by PCB itself but may be of use by
1860 other programs or users.
1862 @table @var
1863 @item Name
1864 The name of the attribute
1866 @item Value
1867 The value of the attribute. Values are always stored as strings, even
1868 if the value is interpreted as, for example, a number.
1870 @end table
1872 %end-doc */
1874 attributes : attribute
1875 | attributes attribute
1877 attribute
1878 : T_ATTRIBUTE '(' STRING STRING ')'
1880 CreateNewAttribute (attr_list, $3, $4);
1881 SaveFree ($3);
1882 SaveFree ($4);
1886 opt_string : STRING { $$ = $1; }
1887 | /* empty */ { $$ = 0; }
1892 /* ---------------------------------------------------------------------------
1893 * error routine called by parser library
1895 int yyerror(s)
1896 const char *s;
1898 Message("ERROR parsing file '%s'\n"
1899 " line: %i\n"
1900 " description: '%s'\n",
1901 yyfilename, yylineno, s);
1902 return(0);
1905 int yywrap()
1907 return 1;
1911 static int
1912 check_file_version (int ver)
1914 if ( ver > PCB_FILE_VERSION ) {
1915 Message ("ERROR: The file you are attempting to load is in a format\n"
1916 "which is too new for this version of pcb. To load this file\n"
1917 "you need a version of pcb which is >= %d. If you are\n"
1918 "using a version built from cvs sources, the source date\n"
1919 "must be >= %d. This copy of pcb can only read files\n"
1920 "up to file version %d.\n", ver, ver, PCB_FILE_VERSION);
1921 return 1;
1924 return 0;