hid/gtk: Fix strncat length when building accelerator string. (CODE!)
[geda-pcb/gde.git] / src / parse_y.y
blob646ef77e62c85caef9c3177ee0313a2af840b1e4
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 attributes, 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 | { attr_list = & Layer->Attributes; } attributes
898 /* flags are passed in */
899 | T_POLYGON '(' flags ')' '('
901 Polygon = CreateNewPolygon(Layer, $3);
903 polygonpoints ')'
905 /* ignore junk */
906 if (Polygon->PointN >= 3)
908 SetPolygonBoundingBox (Polygon);
909 if (!Layer->polygon_tree)
910 Layer->polygon_tree = r_create_tree (NULL, 0, 0);
911 r_insert_entry (Layer->polygon_tree, (BoxType *) Polygon, 0);
913 else
915 Message("WARNING parsing file '%s'\n"
916 " line: %i\n"
917 " description: 'ignored polygon (< 3 points)'\n",
918 yyfilename, yylineno);
919 DestroyObject(yyData, POLYGON_TYPE, Layer, Polygon, Polygon);
924 /* %start-doc pcbfile Line
926 @syntax
927 Line [X1 Y1 X2 Y2 Thickness Clearance SFlags]
928 Line (X1 Y1 X2 Y2 Thickness Clearance NFlags)
929 Line (X1 Y1 X2 Y2 Thickness NFlags)
930 @end syntax
932 @table @var
933 @item X1 Y1 X2 Y2
934 The end points of the line
935 @item Thickness
936 The width of the line
937 @item Clearance
938 The amount of space cleared around the line when the line passes
939 through a polygon. The clearance is added to the thickness to get the
940 thickness of the clear; thus the space between the line and the
941 polygon is @math{Clearance/2} wide.
942 @item SFlags
943 Symbolic or numeric flags
944 @item NFlags
945 Numeric flags.
946 @end table
948 %end-doc */
950 line_hi_format
951 /* x1, y1, x2, y2, thickness, clearance, flags */
952 : T_LINE '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags ']'
954 CreateNewLineOnLayer(Layer, $3, $4, $5, $6, $7, $8, $9);
958 line_1.7_format
959 /* x1, y1, x2, y2, thickness, clearance, flags */
960 : T_LINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
962 CreateNewLineOnLayer(Layer, $3*100, $4*100, $5*100, $6*100,
963 $7*100, $8*100, OldFlags($9));
967 line_oldformat
968 /* x1, y1, x2, y2, thickness, flags */
969 : T_LINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
971 /* eliminate old-style rat-lines */
972 if (($8 & RATFLAG) == 0)
973 CreateNewLineOnLayer(Layer, $3*100, $4*100, $5*100, $6*100, $7*100,
974 200*GROUNDPLANEFRAME, OldFlags($8));
978 /* %start-doc pcbfile Arc
980 @syntax
981 Arc [X Y Width Height Thickness Clearance StartAngle DeltaAngle SFlags]
982 Arc (X Y Width Height Thickness Clearance StartAngle DeltaAngle NFlags)
983 Arc (X Y Width Height Thickness StartAngle DeltaAngle NFlags)
984 @end syntax
986 @table @var
987 @item X Y
988 Coordinates of the center of the arc.
989 @item Width Height
990 The width and height, from the center to the edge. The bounds of the
991 circle of which this arc is a segment, is thus @math{2*Width} by
992 @math{2*Height}.
993 @item Thickness
994 The width of the copper trace which forms the arc.
995 @item Clearance
996 The amount of space cleared around the arc when the line passes
997 through a polygon. The clearance is added to the thickness to get the
998 thickness of the clear; thus the space between the arc and the polygon
999 is @math{Clearance/2} wide.
1000 @item StartAngle
1001 The angle of one end of the arc, in degrees. In PCB, an angle of zero
1002 points left (negative X direction), and 90 degrees points down
1003 (positive Y direction).
1004 @item DeltaAngle
1005 The sweep of the arc. This may be negative. Positive angles sweep
1006 counterclockwise.
1007 @item SFlags
1008 Symbolic or numeric flags.
1009 @item NFlags
1010 Numeric flags.
1011 @end table
1013 %end-doc */
1015 arc_hi_format
1016 /* x, y, width, height, thickness, clearance, startangle, delta, flags */
1017 : T_ARC '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER flags ']'
1019 CreateNewArcOnLayer(Layer, $3, $4, $5, $6, $9, $10, $7, $8, $11);
1023 arc_1.7_format
1024 /* x, y, width, height, thickness, clearance, startangle, delta, flags */
1025 : T_ARC '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1027 CreateNewArcOnLayer(Layer, $3*100, $4*100, $5*100, $6*100, $9, $10,
1028 $7*100, $8*100, OldFlags($11));
1032 arc_oldformat
1033 /* x, y, width, height, thickness, startangle, delta, flags */
1034 : T_ARC '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1036 CreateNewArcOnLayer(Layer, $3*100, $4*100, $5*100, $5*100, $8, $9,
1037 $7*100, 200*GROUNDPLANEFRAME, OldFlags($10));
1041 /* %start-doc pcbfile Text
1043 @syntax
1044 Text [X Y Direction Scale "String" SFlags]
1045 Text (X Y Direction Scale "String" NFlags)
1046 Text (X Y Direction "String" NFlags)
1047 @end syntax
1049 @table @var
1050 @item X Y
1051 The location of the upper left corner of the text.
1052 @item Direction
1053 0 means text is drawn left to right, 1 means up, 2 means right to left
1054 (i.e. upside down), and 3 means down.
1055 @item Scale
1056 Size of the text, as a percentage of the ``default'' size of of the
1057 font (the default font is about 40 mils high). Default is 100 (40
1058 mils).
1059 @item String
1060 The string to draw.
1061 @item SFlags
1062 Symbolic or numeric flags.
1063 @item NFlags
1064 Numeric flags.
1065 @end table
1067 %end-doc */
1069 text_oldformat
1070 /* x, y, direction, text, flags */
1071 : T_TEXT '(' NUMBER NUMBER NUMBER STRING NUMBER ')'
1073 /* use a default scale of 100% */
1074 CreateNewText(Layer,yyFont,$3*100, $4*100, $5, 100, $6, OldFlags($7));
1075 SaveFree($6);
1079 text_newformat
1080 /* x, y, direction, scale, text, flags */
1081 : T_TEXT '(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
1083 if ($8 & ONSILKFLAG)
1085 LayerTypePtr lay = &yyData->Layer[yyData->LayerN +
1086 (($8 & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)];
1088 CreateNewText(lay ,yyFont, $3*100, $4*100, $5, $6, $7,
1089 OldFlags($8));
1091 else
1092 CreateNewText(Layer, yyFont, $3*100, $4*100, $5, $6, $7,
1093 OldFlags($8));
1094 SaveFree($7);
1097 text_hi_format
1098 /* x, y, direction, scale, text, flags */
1099 : T_TEXT '[' NUMBER NUMBER NUMBER NUMBER STRING flags ']'
1101 /* FIXME: shouldn't know about .f */
1102 /* I don't think this matters because anything with hi_format
1103 * will have the silk on its own layer in the file rather
1104 * than using the ONSILKFLAG and having it in a copper layer.
1105 * Thus there is no need for anything besides the 'else'
1106 * part of this code.
1108 if ($8.f & ONSILKFLAG)
1110 LayerTypePtr lay = &yyData->Layer[yyData->LayerN +
1111 (($8.f & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)];
1113 CreateNewText(lay, yyFont, $3, $4, $5, $6, $7, $8);
1115 else
1116 CreateNewText(Layer, yyFont, $3, $4, $5, $6, $7, $8);
1117 SaveFree($7);
1121 /* %start-doc pcbfile Polygon
1123 @syntax
1124 Polygon (SFlags) (
1125 @ @ @ @dots{} (X Y) @dots{}
1126 @ @ @ @dots{} [X Y] @dots{}
1128 @end syntax
1130 @table @var
1131 @item SFlags
1132 Symbolic or numeric flags.
1133 @item X Y
1134 Coordinates of each vertex. You must list at least three coordinates.
1135 @end table
1137 %end-doc */
1139 polygonpoints
1140 : polygonpoint
1141 | polygonpoints polygonpoint
1144 polygonpoint
1145 /* xcoord ycoord */
1146 : '(' NUMBER NUMBER ')'
1148 CreateNewPointInPolygon(Polygon, $2*100, $3*100);
1150 | '[' NUMBER NUMBER ']'
1152 CreateNewPointInPolygon(Polygon, $2, $3);
1157 /* %start-doc pcbfile Element
1159 @syntax
1160 Element [SFlags "Desc" "Name" "Value" MX MY TX TY TDir TScale TSFlags] (
1161 Element (NFlags "Desc" "Name" "Value" MX MY TX TY TDir TScale TNFlags) (
1162 Element (NFlags "Desc" "Name" "Value" TX TY TDir TScale TNFlags) (
1163 Element (NFlags "Desc" "Name" TX TY TDir TScale TNFlags) (
1164 Element ("Desc" "Name" TX TY TDir TScale TNFlags) (
1165 @ @ @ @dots{} contents @dots{}
1167 @end syntax
1169 @table @var
1170 @item SFlags
1171 Symbolic or numeric flags, for the element as a whole.
1172 @item NFlags
1173 Numeric flags, for the element as a whole.
1174 @item Desc
1175 The description of the element. This is one of the three strings
1176 which can be displayed on the screen.
1177 @item Name
1178 The name of the element, usually the reference designator.
1179 @item Value
1180 The value of the element.
1181 @item MX MY
1182 The location of the element's mark. This is the reference point
1183 for placing the element and its pins and pads.
1184 @item TX TY
1185 The upper left corner of the text (one of the three strings).
1186 @item TDir
1187 The relative direction of the text. 0 means left to right for
1188 an unrotated element, 1 means up, 2 left, 3 down.
1189 @item TScale
1190 Size of the text, as a percentage of the ``default'' size of of the
1191 font (the default font is about 40 mils high). Default is 100 (40
1192 mils).
1193 @item TSFlags
1194 Symbolic or numeric flags, for the text.
1195 @item TNFlags
1196 Numeric flags, for the text.
1197 @end table
1199 Elements may contain pins, pads, element lines, element arcs,
1200 attributes, and (for older elements) an optional mark. Note that
1201 element definitions that have the mark coordinates in the element
1202 line, only support pins and pads which use relative coordinates. The
1203 pin and pad coordinates are relative to the mark. Element definitions
1204 which do not include the mark coordinates in the element line, may
1205 have a Mark definition in their contents, and only use pin and pad
1206 definitions which use absolute coordinates.
1208 %end-doc */
1210 element
1211 : element_oldformat
1212 | element_1.3.4_format
1213 | element_newformat
1214 | element_1.7_format
1215 | element_hi_format
1218 element_oldformat
1219 /* element_flags, description, pcb-name,
1220 * text_x, text_y, text_direction, text_scale, text_flags
1222 : T_ELEMENT '(' STRING STRING NUMBER NUMBER NUMBER ')' '('
1224 yyElement = CreateNewElement(yyData, yyElement, yyFont, NoFlags(),
1225 $3, $4, NULL, $5*100, $6*100, $7, 100, NoFlags(), False);
1226 SaveFree($3);
1227 SaveFree($4);
1228 pin_num = 1;
1230 elementdefinitions ')'
1232 SetElementBoundingBox(yyData, yyElement, yyFont);
1236 element_1.3.4_format
1237 /* element_flags, description, pcb-name,
1238 * text_x, text_y, text_direction, text_scale, text_flags
1240 : T_ELEMENT '(' NUMBER STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER ')' '('
1242 yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3),
1243 $4, $5, NULL, $6*100, $7*100, $8, $9, OldFlags($10), False);
1244 SaveFree($4);
1245 SaveFree($5);
1246 pin_num = 1;
1248 elementdefinitions ')'
1250 SetElementBoundingBox(yyData, yyElement, yyFont);
1254 element_newformat
1255 /* element_flags, description, pcb-name, value,
1256 * text_x, text_y, text_direction, text_scale, text_flags
1258 : T_ELEMENT '(' NUMBER STRING STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER ')' '('
1260 yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3),
1261 $4, $5, $6, $7*100, $8*100, $9, $10, OldFlags($11), False);
1262 SaveFree($4);
1263 SaveFree($5);
1264 SaveFree($6);
1265 pin_num = 1;
1267 elementdefinitions ')'
1269 SetElementBoundingBox(yyData, yyElement, yyFont);
1273 element_1.7_format
1274 /* element_flags, description, pcb-name, value, mark_x, mark_y,
1275 * text_x, text_y, text_direction, text_scale, text_flags
1277 : T_ELEMENT '(' NUMBER STRING STRING STRING NUMBER NUMBER
1278 NUMBER NUMBER NUMBER NUMBER NUMBER ')' '('
1280 yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3),
1281 $4, $5, $6, ($7+$9)*100, ($8+$10)*100, $11, $12, OldFlags($13), False);
1282 yyElement->MarkX = $7*100;
1283 yyElement->MarkY = $8*100;
1284 SaveFree($4);
1285 SaveFree($5);
1286 SaveFree($6);
1288 relementdefs ')'
1290 SetElementBoundingBox(yyData, yyElement, yyFont);
1294 element_hi_format
1295 /* element_flags, description, pcb-name, value, mark_x, mark_y,
1296 * text_x, text_y, text_direction, text_scale, text_flags
1298 : T_ELEMENT '[' flags STRING STRING STRING NUMBER NUMBER
1299 NUMBER NUMBER NUMBER NUMBER flags ']' '('
1301 yyElement = CreateNewElement(yyData, yyElement, yyFont, $3,
1302 $4, $5, $6, ($7+$9), ($8+$10), $11, $12, $13, False);
1303 yyElement->MarkX = $7;
1304 yyElement->MarkY = $8;
1305 SaveFree($4);
1306 SaveFree($5);
1307 SaveFree($6);
1309 relementdefs ')'
1311 SetElementBoundingBox(yyData, yyElement, yyFont);
1315 /* %start-doc pcbfile ElementLine
1317 @syntax
1318 ElementLine [X1 Y1 X2 Y2 Thickness]
1319 ElementLine (X1 Y1 X2 Y2 Thickness)
1320 @end syntax
1322 @table @var
1323 @item X1 Y1 X2 Y2
1324 Coordinates of the endpoints of the line. These are relative to the
1325 Element's mark point for new element formats, or absolute for older
1326 formats.
1327 @item Thickness
1328 The width of the silk for this line.
1329 @end table
1331 %end-doc */
1333 /* %start-doc pcbfile ElementArc
1335 @syntax
1336 ElementArc [X Y Width Height StartAngle DeltaAngle Thickness]
1337 ElementArc (X Y Width Height StartAngle DeltaAngle Thickness)
1338 @end syntax
1340 @table @var
1341 @item X Y
1342 Coordinates of the center of the arc. These are relative to the
1343 Element's mark point for new element formats, or absolute for older
1344 formats.
1345 @item Width Height
1346 The width and height, from the center to the edge. The bounds of the
1347 circle of which this arc is a segment, is thus @math{2*Width} by
1348 @math{2*Height}.
1349 @item StartAngle
1350 The angle of one end of the arc, in degrees. In PCB, an angle of zero
1351 points left (negative X direction), and 90 degrees points down
1352 (positive Y direction).
1353 @item DeltaAngle
1354 The sweep of the arc. This may be negative. Positive angles sweep
1355 counterclockwise.
1356 @item Thickness
1357 The width of the silk line which forms the arc.
1358 @end table
1360 %end-doc */
1362 /* %start-doc pcbfile Mark
1364 @syntax
1365 Mark [X Y]
1366 Mark (X Y)
1367 @end syntax
1369 @table @var
1370 @item X Y
1371 Coordinates of the Mark, for older element formats that don't have
1372 the mark as part of the Element line.
1373 @end table
1375 %end-doc */
1377 elementdefinitions
1378 : elementdefinition
1379 | elementdefinitions elementdefinition
1382 elementdefinition
1383 : pin_1.6.3_format
1384 | pin_newformat
1385 | pin_oldformat
1386 | pad_newformat
1387 | pad
1388 /* x1, y1, x2, y2, thickness */
1389 | T_ELEMENTLINE '[' NUMBER NUMBER NUMBER NUMBER NUMBER ']'
1391 CreateNewLineInElement(yyElement, $3, $4, $5, $6, $7);
1393 /* x1, y1, x2, y2, thickness */
1394 | T_ELEMENTLINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1396 CreateNewLineInElement(yyElement, $3*100, $4*100, $5*100, $6*100, $7*100);
1398 /* x, y, width, height, startangle, anglediff, thickness */
1399 | T_ELEMENTARC '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ']'
1401 CreateNewArcInElement(yyElement, $3, $4, $5, $6, $7, $8, $9);
1403 /* x, y, width, height, startangle, anglediff, thickness */
1404 | T_ELEMENTARC '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1406 CreateNewArcInElement(yyElement, $3*100, $4*100, $5*100, $6*100, $7, $8, $9*100);
1408 /* x, y position */
1409 | T_MARK '[' NUMBER NUMBER ']'
1411 yyElement->MarkX = $3;
1412 yyElement->MarkY = $4;
1414 | T_MARK '(' NUMBER NUMBER ')'
1416 yyElement->MarkX = $3*100;
1417 yyElement->MarkY = $4*100;
1419 | { attr_list = & yyElement->Attributes; } attributes
1422 relementdefs
1423 : relementdef
1424 | relementdefs relementdef
1427 relementdef
1428 : pin_1.7_format
1429 | pin_hi_format
1430 | pad_1.7_format
1431 | pad_hi_format
1432 /* x1, y1, x2, y2, thickness */
1433 | T_ELEMENTLINE '[' NUMBER NUMBER NUMBER NUMBER NUMBER ']'
1435 CreateNewLineInElement(yyElement, $3 + yyElement->MarkX,
1436 $4 + yyElement->MarkY, $5 + yyElement->MarkX,
1437 $6 + yyElement->MarkY, $7);
1439 | T_ELEMENTLINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1441 CreateNewLineInElement(yyElement, $3*100 + yyElement->MarkX,
1442 $4*100 + yyElement->MarkY, $5*100 + yyElement->MarkX,
1443 $6*100 + yyElement->MarkY, $7*100);
1445 /* x, y, width, height, startangle, anglediff, thickness */
1446 | T_ELEMENTARC '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ']'
1448 CreateNewArcInElement(yyElement, $3 + yyElement->MarkX,
1449 $4 + yyElement->MarkY, $5, $6, $7, $8, $9);
1451 | T_ELEMENTARC '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1453 CreateNewArcInElement(yyElement, $3*100 + yyElement->MarkX,
1454 $4*100 + yyElement->MarkY, $5*100, $6*100, $7, $8, $9*100);
1456 | { attr_list = & yyElement->Attributes; } attributes
1459 /* %start-doc pcbfile Pin
1461 @syntax
1462 Pin [rX rY Thickness Clearance Mask Drill "Name" "Number" SFlags]
1463 Pin (rX rY Thickness Clearance Mask Drill "Name" "Number" NFlags)
1464 Pin (aX aY Thickness Drill "Name" "Number" NFlags)
1465 Pin (aX aY Thickness Drill "Name" NFlags)
1466 Pin (aX aY Thickness "Name" NFlags)
1467 @end syntax
1469 @table @var
1470 @item rX rY
1471 coordinates of center, relative to the element's mark
1472 @item aX aY
1473 absolute coordinates of center.
1474 @item Thickness
1475 outer diameter of copper annulus
1476 @item Clearance
1477 add to thickness to get clearance diameter
1478 @item Mask
1479 diameter of solder mask opening
1480 @item Drill
1481 diameter of drill
1482 @item Name
1483 name of pin
1484 @item Number
1485 number of pin
1486 @item SFlags
1487 symbolic or numerical flags
1488 @item NFlags
1489 numerical flags only
1490 @end table
1492 %end-doc */
1494 pin_hi_format
1495 /* x, y, thickness, clearance, mask, drilling hole, name,
1496 number, flags */
1497 : T_PIN '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING flags ']'
1499 CreateNewPin(yyElement, $3 + yyElement->MarkX,
1500 $4 + yyElement->MarkY, $5, $6, $7, $8, $9,
1501 $10, $11);
1502 SaveFree($9);
1503 SaveFree($10);
1506 pin_1.7_format
1507 /* x, y, thickness, clearance, mask, drilling hole, name,
1508 number, flags */
1509 : T_PIN '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER ')'
1511 CreateNewPin(yyElement, $3*100 + yyElement->MarkX,
1512 $4*100 + yyElement->MarkY, $5*100, $6*100, $7*100, $8*100, $9,
1513 $10, OldFlags($11));
1514 SaveFree($9);
1515 SaveFree($10);
1519 pin_1.6.3_format
1520 /* x, y, thickness, drilling hole, name, number, flags */
1521 : T_PIN '(' NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER ')'
1523 CreateNewPin(yyElement, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
1524 ($5 + 2*MASKFRAME)*100, $6*100, $7, $8, OldFlags($9));
1525 SaveFree($7);
1526 SaveFree($8);
1530 pin_newformat
1531 /* x, y, thickness, drilling hole, name, flags */
1532 : T_PIN '(' NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
1534 char p_number[8];
1536 sprintf(p_number, "%d", pin_num++);
1537 CreateNewPin(yyElement, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
1538 ($5 + 2*MASKFRAME)*100, $6*100, $7, p_number, OldFlags($8));
1540 SaveFree($7);
1544 pin_oldformat
1545 /* old format: x, y, thickness, name, flags
1546 * drilling hole is 40% of the diameter
1548 : T_PIN '(' NUMBER NUMBER NUMBER STRING NUMBER ')'
1550 BDimension hole = ($5 *DEFAULT_DRILLINGHOLE);
1551 char p_number[8];
1553 /* make sure that there's enough copper left */
1554 if ($5 -hole < MIN_PINORVIACOPPER &&
1555 $5 > MIN_PINORVIACOPPER)
1556 hole = $5 -MIN_PINORVIACOPPER;
1558 sprintf(p_number, "%d", pin_num++);
1559 CreateNewPin(yyElement, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
1560 ($5 + 2*MASKFRAME)*100, hole, $6, p_number, OldFlags($7));
1561 SaveFree($6);
1565 /* %start-doc pcbfile Pad
1567 @syntax
1568 Pad [rX1 rY1 rX2 rY2 Thickness Clearance Mask "Name" "Number" SFlags]
1569 Pad (rX1 rY1 rX2 rY2 Thickness Clearance Mask "Name" "Number" NFlags)
1570 Pad (aX1 aY1 aX2 aY2 Thickness "Name" "Number" NFlags)
1571 Pad (aX1 aY1 aX2 aY2 Thickness "Name" NFlags)
1572 @end syntax
1574 @table @var
1575 @item rX1 rY1 rX2 rY2
1576 Coordinates of the endpoints of the pad, relative to the element's
1577 mark. Note that the copper extends beyond these coordinates by half
1578 the thickness. To make a square or round pad, specify the same
1579 coordinate twice.
1580 @item aX1 aY1 aX2 aY2
1581 Same, but absolute coordinates of the endpoints of the pad.
1582 @item Thickness
1583 width of the pad.
1584 @item Clearance
1585 add to thickness to get clearance width.
1586 @item Mask
1587 width of solder mask opening.
1588 @item Name
1589 name of pin
1590 @item Number
1591 number of pin
1592 @item SFlags
1593 symbolic or numerical flags
1594 @item NFlags
1595 numerical flags only
1596 @end table
1598 %end-doc */
1600 pad_hi_format
1601 /* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */
1602 : T_PAD '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING flags ']'
1604 CreateNewPad(yyElement, $3 + yyElement->MarkX,
1605 $4 + yyElement->MarkY,
1606 $5 + yyElement->MarkX,
1607 $6 + yyElement->MarkY, $7, $8, $9,
1608 $10, $11, $12);
1609 SaveFree($10);
1610 SaveFree($11);
1614 pad_1.7_format
1615 /* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */
1616 : T_PAD '(' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER ')'
1618 CreateNewPad(yyElement,$3*100 + yyElement->MarkX,
1619 $4*100 + yyElement->MarkY, $5*100 + yyElement->MarkX,
1620 $6*100 + yyElement->MarkY, $7*100, $8*100, $9*100,
1621 $10, $11, OldFlags($12));
1622 SaveFree($10);
1623 SaveFree($11);
1627 pad_newformat
1628 /* x1, y1, x2, y2, thickness, name , pad number, flags */
1629 : T_PAD '(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING STRING NUMBER ')'
1631 CreateNewPad(yyElement,$3*100,$4*100,$5*100,$6*100,$7*100, 200*GROUNDPLANEFRAME,
1632 ($7 + 2*MASKFRAME)*100, $8,$9, OldFlags($10));
1633 SaveFree($8);
1634 SaveFree($9);
1639 /* x1, y1, x2, y2, thickness, name and flags */
1640 : T_PAD '(' NUMBER NUMBER NUMBER NUMBER NUMBER STRING NUMBER ')'
1642 char p_number[8];
1644 sprintf(p_number, "%d", pin_num++);
1645 CreateNewPad(yyElement,$3*100,$4*100,$5*100,$6*100,$7*100, 200*GROUNDPLANEFRAME,
1646 ($7 + 2*MASKFRAME)*100, $8,p_number, OldFlags($9));
1647 SaveFree($8);
1651 flags : NUMBER { $$ = OldFlags($1); }
1652 | STRING { $$ = string_to_flags ($1, yyerror); }
1655 symbols
1656 : symbol
1657 | symbols symbol
1660 /* %start-doc pcbfile Symbol
1662 @syntax
1663 Symbol [Char Delta] (
1664 Symbol (Char Delta) (
1665 @ @ @ @dots{} symbol lines @dots{}
1667 @end syntax
1669 @table @var
1670 @item Char
1671 The character or numerical character value this symbol represents.
1672 Characters must be in single quotes.
1673 @item Delta
1674 Additional space to allow after this character.
1675 @end table
1677 %end-doc */
1679 symbol
1680 : T_SYMBOL '[' symbolid NUMBER ']' '('
1682 if ($3 <= 0 || $3 > MAX_FONTPOSITION)
1684 yyerror("fontposition out of range");
1685 YYABORT;
1687 Symbol = &yyFont->Symbol[$3];
1688 if (Symbol->Valid)
1690 yyerror("symbol ID used twice");
1691 YYABORT;
1693 Symbol->Valid = True;
1694 Symbol->Delta = $4;
1696 symboldata ')'
1697 | T_SYMBOL '(' symbolid NUMBER ')' '('
1699 if ($3 <= 0 || $3 > MAX_FONTPOSITION)
1701 yyerror("fontposition out of range");
1702 YYABORT;
1704 Symbol = &yyFont->Symbol[$3];
1705 if (Symbol->Valid)
1707 yyerror("symbol ID used twice");
1708 YYABORT;
1710 Symbol->Valid = True;
1711 Symbol->Delta = $4*100;
1713 symboldata ')'
1716 symbolid
1717 : NUMBER
1718 | CHAR_CONST
1721 symboldata
1722 : symboldefinitions
1723 | symboldata symboldefinitions
1726 symboldefinitions
1727 : symboldefinition
1728 | hiressymbol
1732 /* %start-doc pcbfile SymbolLine
1734 @syntax
1735 SymbolLine [X1 Y1 X2 Y1 Thickness]
1736 SymbolLine (X1 Y1 X2 Y1 Thickness)
1737 @end syntax
1739 @table @var
1740 @item X1 Y1 X2 Y2
1741 The endpoints of this line.
1742 @item Thickness
1743 The width of this line.
1744 @end table
1746 %end-doc */
1748 symboldefinition
1749 /* x1, y1, x2, y2, thickness */
1750 : T_SYMBOLLINE '(' NUMBER NUMBER NUMBER NUMBER NUMBER ')'
1752 CreateNewLineInSymbol(Symbol, $3*100, $4*100, $5*100, $6*100, $7*100);
1755 hiressymbol
1756 /* x1, y1, x2, y2, thickness */
1757 : T_SYMBOLLINE '[' NUMBER NUMBER NUMBER NUMBER NUMBER ']'
1759 CreateNewLineInSymbol(Symbol, $3, $4, $5, $6, $7);
1763 /* %start-doc pcbfile Netlist
1765 @syntax
1766 Netlist ( ) (
1767 @ @ @ @dots{} nets @dots{}
1769 @end syntax
1771 %end-doc */
1773 pcbnetlist : pcbnetdef
1776 pcbnetdef
1777 /* net(...) net(...) ... */
1778 : T_NETLIST '(' ')' '('
1779 nets ')'
1782 nets
1783 : netdefs
1787 netdefs
1788 : net
1789 | netdefs net
1792 /* %start-doc pcbfile Net
1794 @syntax
1795 Net ("Name" "Style") (
1796 @ @ @ @dots{} connects @dots{}
1798 @end syntax
1800 @table @var
1801 @item Name
1802 The name of this net.
1803 @item Style
1804 The routing style that should be used when autorouting this net.
1805 @end table
1807 %end-doc */
1810 /* name style pin pin ... */
1811 : T_NET '(' STRING STRING ')' '('
1813 Menu = CreateNewNet(&yyPCB->NetlistLib, $3, $4);
1814 SaveFree($3);
1815 SaveFree($4);
1817 connections ')'
1820 connections
1821 : conndefs
1825 conndefs
1826 : conn
1827 | conndefs conn
1830 /* %start-doc pcbfile Connect
1832 @syntax
1833 Connect ("PinPad")
1834 @end syntax
1836 @table @var
1837 @item PinPad
1838 The name of a pin or pad which is included in this net. Pin and Pad
1839 names are named by the refdes and pin name, like @code{"U14-7"} for
1840 pin 7 of U14, or @code{"T4-E"} for pin E of T4.
1841 @end table
1843 %end-doc */
1845 conn
1846 : T_CONN '(' STRING ')'
1848 CreateNewConnection(Menu, $3);
1849 SaveFree($3);
1853 /* %start-doc pcbfile Attribute
1855 @syntax
1856 Attribute ("Name" "Value")
1857 @end syntax
1859 Attributes allow boards and elements to have arbitrary data attached
1860 to them, which is not directly used by PCB itself but may be of use by
1861 other programs or users.
1863 @table @var
1864 @item Name
1865 The name of the attribute
1867 @item Value
1868 The value of the attribute. Values are always stored as strings, even
1869 if the value is interpreted as, for example, a number.
1871 @end table
1873 %end-doc */
1875 attributes : attribute
1876 | attributes attribute
1878 attribute
1879 : T_ATTRIBUTE '(' STRING STRING ')'
1881 CreateNewAttribute (attr_list, $3, $4);
1882 SaveFree ($3);
1883 SaveFree ($4);
1887 opt_string : STRING { $$ = $1; }
1888 | /* empty */ { $$ = 0; }
1893 /* ---------------------------------------------------------------------------
1894 * error routine called by parser library
1896 int yyerror(s)
1897 const char *s;
1899 Message("ERROR parsing file '%s'\n"
1900 " line: %i\n"
1901 " description: '%s'\n",
1902 yyfilename, yylineno, s);
1903 return(0);
1906 int yywrap()
1908 return 1;
1912 static int
1913 check_file_version (int ver)
1915 if ( ver > PCB_FILE_VERSION ) {
1916 Message ("ERROR: The file you are attempting to load is in a format\n"
1917 "which is too new for this version of pcb. To load this file\n"
1918 "you need a version of pcb which is >= %d. If you are\n"
1919 "using a version built from cvs sources, the source date\n"
1920 "must be >= %d. This copy of pcb can only read files\n"
1921 "up to file version %d.\n", ver, ver, PCB_FILE_VERSION);
1922 return 1;
1925 return 0;