Index: trunk/scconfig/plugins.h =================================================================== --- trunk/scconfig/plugins.h (revision 1760) +++ trunk/scconfig/plugins.h (revision 1761) @@ -33,6 +33,9 @@ plugin_def("export_lpr", "lpr exporter (printer)", sbuildin) plugin_def("export_ps", "postscript exporter", sbuildin) +plugin_header("\nIO plugins (core file formats):\n") +plugin_def("io_pcb", "the original pcb format", sbuildin) + plugin_header("\nHID plugins:\n") plugin_def("hid_batch", "batch process (no-gui HID)",sbuildin) plugin_def("hid_gtk", "the GTK gui", sbuildin) Index: trunk/src/parse_y.y =================================================================== --- trunk/src/parse_y.y (revision 1760) +++ trunk/src/parse_y.y (nonexistent) @@ -1,2071 +0,0 @@ -/* $Id$ */ -/* - * ************************** README ******************* - * - * If the file format is modified in any way, update - * PCB_FILE_VERSION in file.h - * - * ************************** README ******************* - */ - -%{ -/* - * COPYRIGHT - * - * PCB, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Contact addresses for paper mail and Email: - * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany - * Thomas.Nau@rz.uni-ulm.de - * - */ - -/* grammar to parse ASCII input of PCB description - */ - -#include "config.h" -#include "conf_core.h" - -#include "global.h" -#include "create.h" -#include "data.h" -#include "error.h" -#include "file.h" -#include "mymem.h" -#include "misc.h" -#include "parse_l.h" -#include "polygon.h" -#include "remove.h" -#include "rtree.h" -#include "strflags.h" -#include "thermal.h" -#include "rats_patch.h" - -#ifdef HAVE_LIBDMALLOC -# include /* see http://dmalloc.com */ -#endif - -RCSID("$Id$"); - -static LayerTypePtr Layer; -static PolygonTypePtr Polygon; -static SymbolTypePtr Symbol; -static int pin_num; -static LibraryMenuTypePtr Menu; -static bool LayerFlag[MAX_LAYER + 2]; - -extern char *yytext; /* defined by LEX */ -extern PCBTypePtr yyPCB; -extern DataTypePtr yyData; -extern ElementTypePtr yyElement; -extern FontTypePtr yyFont; -extern int yylineno; /* linenumber */ -extern char *yyfilename; /* in this file */ - -static char *layer_group_string; - -static AttributeListTypePtr attr_list; - -int yyerror(const char *s); -int yylex(); -static int check_file_version (int); - -static void do_measure (PLMeasure *m, Coord i, double d, int u); -#define M(r,f,d) do_measure (&(r), f, d, 1) - -/* Macros for interpreting what "measure" means - integer value only, - old units (mil), or new units (cmil). */ -#define IV(m) integer_value (m) -#define OU(m) old_units (m) -#define NU(m) new_units (m) - -static int integer_value (PLMeasure m); -static Coord old_units (PLMeasure m); -static Coord new_units (PLMeasure m); - -#define YYDEBUG 1 -#define YYERROR_VERBOSE 1 - -#include "parse_y.h" - -%} - -%verbose - -%union /* define YYSTACK type */ -{ - int integer; - double number; - char *string; - FlagType flagtype; - PLMeasure measure; -} - -%token FLOATING /* line thickness, coordinates ... */ -%token INTEGER CHAR_CONST /* flags ... */ -%token STRING /* element names ... */ - -%token T_FILEVERSION T_PCB T_LAYER T_VIA T_RAT T_LINE T_ARC T_RECTANGLE T_TEXT T_ELEMENTLINE -%token T_ELEMENT T_PIN T_PAD T_GRID T_FLAGS T_SYMBOL T_SYMBOLLINE T_CURSOR -%token T_ELEMENTARC T_MARK T_GROUPS T_STYLES T_POLYGON T_POLYGON_HOLE T_NETLIST T_NET T_CONN -%token T_NETLISTPATCH T_ADD_CONN T_DEL_CONN T_CHANGE_ATTRIB -%token T_AREA T_THERMAL T_DRC T_ATTRIBUTE -%token T_UMIL T_CMIL T_MIL T_IN T_NM T_UM T_MM T_M T_KM -%type symbolid -%type opt_string -%type flags -%type number -%type measure - -%% - -parse - : parsepcb - | parsedata - | parsefont - | error { YYABORT; } - ; - -/* %start-doc pcbfile 00pcb -@nodetype subsection -@nodename %s syntax - -A special note about units: Older versions of @code{pcb} used mils -(1/1000 inch) as the base unit; a value of 500 in the file meant -half an inch. Newer versions uses a "high resolution" syntax, -where the base unit is 1/100 of a mil (0.000010 inch); a value of 500 in -the file means 5 mils. As a general rule, the variants of each entry -listed below which use square brackets are the high resolution formats -and use the 1/100 mil units, and the ones with parentheses are the older -variants and use 1 mil units. Note that when multiple variants -are listed, the most recent (and most preferred) format is the first -listed. - -Symbolic and numeric flags (SFlags and NFlags) are described in -@ref{Object Flags}. - -%end-doc */ - -parsepcb - : { - /* reset flags for 'used layers'; - * init font and data pointers - */ - int i; - - if (!yyPCB) - { - Message("illegal fileformat\n"); - YYABORT; - } - for (i = 0; i < MAX_LAYER + 2; i++) - LayerFlag[i] = false; - yyFont = &yyPCB->Font; - yyData = yyPCB->Data; - yyData->pcb = yyPCB; - yyData->LayerN = 0; - yyPCB->NetlistPatches = yyPCB->NetlistPatchLast = NULL; - layer_group_string = NULL; - } - pcbfileversion - pcbname - pcbgrid - pcbcursor - polyarea - pcbthermal - pcbdrc - pcbflags - pcbgroups - pcbstyles - pcbfont - pcbdata - pcbnetlist - pcbnetlistpatch - { - PCBTypePtr pcb_save = PCB; - - if (layer_group_string == NULL) - layer_group_string = strdup(conf_core.design.groups); - CreateNewPCBPost (yyPCB, 0); - if (ParseGroupString(layer_group_string, &yyPCB->LayerGroups, yyData->LayerN)) - { - Message("illegal layer-group string\n"); - YYABORT; - } - /* initialize the polygon clipping now since - * we didn't know the layer grouping before. - */ - free(layer_group_string); - PCB = yyPCB; - ALLPOLYGON_LOOP (yyData); - { - InitClip (yyData, layer, polygon); - } - ENDALL_LOOP; - PCB = pcb_save; - } - - | { PreLoadElementPCB (); - layer_group_string = NULL; } - element - { LayerFlag[0] = true; - LayerFlag[1] = true; - yyData->LayerN = 2; - PostLoadElementPCB (); - } - ; - -parsedata - : { - /* reset flags for 'used layers'; - * init font and data pointers - */ - int i; - - if (!yyData || !yyFont) - { - Message("illegal fileformat\n"); - YYABORT; - } - for (i = 0; i < MAX_LAYER + 2; i++) - LayerFlag[i] = false; - yyData->LayerN = 0; - } - pcbdata - ; - -pcbfont - : parsefont - | - ; - -parsefont - : - { - /* mark all symbols invalid */ - int i; - - if (!yyFont) - { - Message("illegal fileformat\n"); - YYABORT; - } - yyFont->Valid = false; - for (i = 0; i <= MAX_FONTPOSITION; i++) - free (yyFont->Symbol[i].Line); - bzero(yyFont->Symbol, sizeof(yyFont->Symbol)); - } - symbols - { - yyFont->Valid = true; - SetFontInfo(yyFont); - } - ; - -/* %start-doc pcbfile FileVersion - -@syntax -FileVersion[Version] -@end syntax - -@table @var -@item Version -File format version. This version number represents the date when the pcb file -format was last changed. -@end table - -Any version of pcb build from sources equal to or newer -than this number should be able to read the file. If this line is not present -in the input file then file format compatibility is not checked. - - -%end-doc */ - -pcbfileversion -: | -T_FILEVERSION '[' INTEGER ']' -{ - if (check_file_version ($3) != 0) - { - YYABORT; - } -} -; - -/* %start-doc pcbfile PCB - -@syntax -PCB ["Name" Width Height] -PCB ("Name" Width Height] -PCB ("Name") -@end syntax - -@table @var -@item Name -Name of the PCB project -@item Width Height -Size of the board -@end table - -If you don't specify the size of the board, a very large default is -chosen. - -%end-doc */ - -pcbname - : T_PCB '(' STRING ')' - { - yyPCB->Name = $3; - yyPCB->MaxWidth = MAX_COORD; - yyPCB->MaxHeight = MAX_COORD; - } - | T_PCB '(' STRING measure measure ')' - { - yyPCB->Name = $3; - yyPCB->MaxWidth = OU ($4); - yyPCB->MaxHeight = OU ($5); - } - | T_PCB '[' STRING measure measure ']' - { - yyPCB->Name = $3; - yyPCB->MaxWidth = NU ($4); - yyPCB->MaxHeight = NU ($5); - } - ; - -/* %start-doc pcbfile Grid - -@syntax -Grid [Step OffsetX OffsetY Visible] -Grid (Step OffsetX OffsetY Visible) -Grid (Step OffsetX OffsetY) -@end syntax - -@table @var -@item Step -Distance from one grid point to adjacent points. This value may be a -floating point number for the first two variants. -@item OffsetX OffsetY -The "origin" of the grid. Normally zero. -@item Visible -If non-zero, the grid will be visible on the screen. -@end table - -%end-doc */ - -pcbgrid - : pcbgridold - | pcbgridnew - | pcbhigrid - ; -pcbgridold - : T_GRID '(' measure measure measure ')' - { - yyPCB->Grid = OU ($3); - yyPCB->GridOffsetX = OU ($4); - yyPCB->GridOffsetY = OU ($5); - } - ; -pcbgridnew - : T_GRID '(' measure measure measure INTEGER ')' - { - yyPCB->Grid = OU ($3); - yyPCB->GridOffsetX = OU ($4); - yyPCB->GridOffsetY = OU ($5); - if ($6) - conf_core.editor.draw_grid = true; - else - conf_core.editor.draw_grid = false; - } - ; - -pcbhigrid - : T_GRID '[' measure measure measure INTEGER ']' - { - yyPCB->Grid = NU ($3); - yyPCB->GridOffsetX = NU ($4); - yyPCB->GridOffsetY = NU ($5); - if ($6) - conf_core.editor.draw_grid = true; - else - conf_core.editor.draw_grid = false; - } - ; - -/* %start-doc pcbfile Cursor - -@syntax -Cursor [X Y Zoom] -Cursor (X Y Zoom) -@end syntax - -@table @var -@item X Y -Location of the cursor when the board was saved. -@item Zoom -The current zoom factor. Note that a zoom factor of "0" means 1 mil -per screen pixel, N means @math{2^N} mils per screen pixel, etc. The -first variant accepts floating point numbers. The special value -"1000" means "zoom to fit" -@end table - -%end-doc */ - -pcbcursor - : T_CURSOR '(' measure measure number ')' - { - yyPCB->CursorX = OU ($3); - yyPCB->CursorY = OU ($4); - yyPCB->Zoom = $5*2; - } - | T_CURSOR '[' measure measure number ']' - { - yyPCB->CursorX = NU ($3); - yyPCB->CursorY = NU ($4); - yyPCB->Zoom = $5; - } - | - ; - -/* %start-doc pcbfile PolyArea - -@syntax -PolyArea [Area] -@end syntax - -@table @var -@item Area -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. -@end table - -%end-doc */ - -polyarea - : - | T_AREA '[' number ']' - { - /* Read in cmil^2 for now; in future this should be a noop. */ - yyPCB->IsleArea = MIL_TO_COORD (MIL_TO_COORD ($3) / 100.0) / 100.0; - } - ; - - -/* %start-doc pcbfile Thermal - -@syntax -Thermal [Scale] -@end syntax - -@table @var -@item Scale -Relative size of thermal fingers. A value of 1.0 makes the finger -width twice the clearance gap width (measured across the gap, not -diameter). The normal value is 0.5, which results in a finger width -the same as the clearance gap width. -@end table - -%end-doc */ - - -pcbthermal - : - | T_THERMAL '[' number ']' - { - yyPCB->ThermScale = $3; - } - ; - -/* %start-doc pcbfile DRC - -@syntax -DRC [Bloat Shrink Line Silk Drill Ring] -DRC [Bloat Shrink Line Silk] -DRC [Bloat Shrink Line] -@end syntax - -@table @var -@item Bloat -Minimum spacing between copper. -@item Shrink -Minimum copper overlap to guarantee connectivity. -@item Line -Minimum line thickness. -@item Silk -Minimum silk thickness. -@item Drill -Minimum drill size. -@item Ring -Minimum width of the annular ring around pins and vias. -@end table - -%end-doc */ - -pcbdrc - : - | pcbdrc1 - | pcbdrc2 - | pcbdrc3 - ; - -pcbdrc1 - : T_DRC '[' measure measure measure ']' - { - yyPCB->Bloat = NU ($3); - yyPCB->Shrink = NU ($4); - yyPCB->minWid = NU ($5); - yyPCB->minRing = NU ($5); - } - ; - -pcbdrc2 - : T_DRC '[' measure measure measure measure ']' - { - yyPCB->Bloat = NU ($3); - yyPCB->Shrink = NU ($4); - yyPCB->minWid = NU ($5); - yyPCB->minSlk = NU ($6); - yyPCB->minRing = NU ($5); - } - ; - -pcbdrc3 - : T_DRC '[' measure measure measure measure measure measure ']' - { - yyPCB->Bloat = NU ($3); - yyPCB->Shrink = NU ($4); - yyPCB->minWid = NU ($5); - yyPCB->minSlk = NU ($6); - yyPCB->minDrill = NU ($7); - yyPCB->minRing = NU ($8); - } - ; - -/* %start-doc pcbfile Flags - -@syntax -Flags(Number) -@end syntax - -@table @var -@item Number -A number, whose value is normally given in hex, individual bits of which -represent pcb-wide flags as defined in @ref{PCBFlags}. - -@end table - -%end-doc */ - -pcbflags - : T_FLAGS '(' INTEGER ')' - { - yyPCB->Flags = MakeFlags ($3 & PCB_FLAGS); - } - | T_FLAGS '(' STRING ')' - { - yyPCB->Flags = string_to_pcbflags ($3, yyerror); - free($3); - } - | - ; - -/* %start-doc pcbfile Groups - -@syntax -Groups("String") -@end syntax - -@table @var -@item String - -Encodes the layer grouping information. Each group is separated by a -colon, each member of each group is separated by a comma. Group -members are either numbers from @code{1}..@var{N} for each layer, and -the letters @code{c} or @code{s} representing the component side and -solder side of the board. Including @code{c} or @code{s} marks that -group as being the top or bottom side of the board. - -@example -Groups("1,2,c:3:4:5,6,s:7,8") -@end example - -@end table - -%end-doc */ - -pcbgroups - : T_GROUPS '(' STRING ')' - { - layer_group_string = $3; - } - | - ; - -/* %start-doc pcbfile Styles - -@syntax -Styles("String") -@end syntax - -@table @var -@item String - -Encodes the four routing styles @code{pcb} knows about. The four styles -are separated by colons. Each style consists of five parameters as follows: - -@table @var -@item Name -The name of the style. -@item Thickness -Width of lines and arcs. -@item Diameter -Copper diameter of pins and vias. -@item Drill -Drill diameter of pins and vias. -@item Keepaway -Minimum spacing to other nets. If omitted, 10 mils is the default. - -@end table - -@end table - -@example -Styles("Signal,10,40,20:Power,25,60,35:Fat,40,60,35:Skinny,8,36,20") -Styles["Logic,1000,3600,2000,1000:Power,2500,6000,3500,1000: -@ @ @ Line,4000,6000,3500,1000:Breakout,600,2402,1181,600"] -@end example - -@noindent -Note that strings in actual files cannot span lines; the above example -is split across lines only to make it readable. - -%end-doc */ - -pcbstyles - : T_STYLES '(' STRING ')' - { - if (ParseRouteString($3, &yyPCB->RouteStyle[0], "mil")) - { - Message("illegal route-style string\n"); - YYABORT; - } - free($3); - } - | T_STYLES '[' STRING ']' - { - if (ParseRouteString($3, &yyPCB->RouteStyle[0], "cmil")) - { - Message("illegal route-style string\n"); - YYABORT; - } - free($3); - } - | - ; - -pcbdata - : pcbdefinitions - | - ; - -pcbdefinitions - : pcbdefinition - | pcbdefinitions pcbdefinition - ; - -pcbdefinition - : via - | { attr_list = & yyPCB->Attributes; } attribute - | rats - | layer - | - { - /* clear pointer to force memory allocation by - * the appropriate subroutine - */ - yyElement = NULL; - } - element - | error { YYABORT; } - ; - -via - : via_hi_format - | via_2.0_format - | via_1.7_format - | via_newformat - | via_oldformat - ; - -/* %start-doc pcbfile Via - -@syntax -Via [X Y Thickness Clearance Mask Drill "Name" SFlags] -Via (X Y Thickness Clearance Mask Drill "Name" NFlags) -Via (X Y Thickness Clearance Drill "Name" NFlags) -Via (X Y Thickness Drill "Name" NFlags) -Via (X Y Thickness "Name" NFlags) -@end syntax - -@table @var -@item X Y -coordinates of center -@item Thickness -outer diameter of copper annulus -@item Clearance -add to thickness to get clearance diameter -@item Mask -diameter of solder mask opening -@item Drill -diameter of drill -@item Name -string, name of via (vias have names?) -@item SFlags -symbolic or numerical flags -@item NFlags -numerical flags only -@end table - -%end-doc */ - -via_hi_format - /* x, y, thickness, clearance, mask, drilling-hole, name, flags */ - : T_VIA '[' measure measure measure measure measure measure STRING flags ']' - { - CreateNewVia(yyData, NU ($3), NU ($4), NU ($5), NU ($6), NU ($7), - NU ($8), $9, $10); - free ($9); - } - ; - -via_2.0_format - /* x, y, thickness, clearance, mask, drilling-hole, name, flags */ - : T_VIA '(' measure measure measure measure measure measure STRING INTEGER ')' - { - CreateNewVia(yyData, OU ($3), OU ($4), OU ($5), OU ($6), OU ($7), OU ($8), $9, - OldFlags($10)); - free ($9); - } - ; - - -via_1.7_format - /* x, y, thickness, clearance, drilling-hole, name, flags */ - : T_VIA '(' measure measure measure measure measure STRING INTEGER ')' - { - CreateNewVia(yyData, OU ($3), OU ($4), OU ($5), OU ($6), - OU ($5) + OU($6), OU ($7), $8, OldFlags($9)); - free ($8); - } - ; - -via_newformat - /* x, y, thickness, drilling-hole, name, flags */ - : T_VIA '(' measure measure measure measure STRING INTEGER ')' - { - CreateNewVia(yyData, OU ($3), OU ($4), OU ($5), 2*GROUNDPLANEFRAME, - OU($5) + 2*MASKFRAME, OU ($6), $7, OldFlags($8)); - free ($7); - } - ; - -via_oldformat - /* old format: x, y, thickness, name, flags */ - : T_VIA '(' measure measure measure STRING INTEGER ')' - { - Coord hole = (OU($5) * DEFAULT_DRILLINGHOLE); - - /* make sure that there's enough copper left */ - if (OU($5) - hole < MIN_PINORVIACOPPER && - OU($5) > MIN_PINORVIACOPPER) - hole = OU($5) - MIN_PINORVIACOPPER; - - CreateNewVia(yyData, OU ($3), OU ($4), OU ($5), 2*GROUNDPLANEFRAME, - OU($5) + 2*MASKFRAME, hole, $6, OldFlags($7)); - free ($6); - } - ; - -/* %start-doc pcbfile Rat - -@syntax -Rat [X1 Y1 Group1 X2 Y2 Group2 SFlags] -Rat (X1 Y1 Group1 X2 Y2 Group2 NFlags) -@end syntax - -@table @var -@item X1 Y1 X2 Y2 -The endpoints of the rat line. -@item Group1 Group2 -The layer group each end is connected on. -@item SFlags -Symbolic or numeric flags. -@item NFlags -Numeric flags. -@end table - -%end-doc */ - -rats - : T_RAT '[' measure measure INTEGER measure measure INTEGER flags ']' - { - CreateNewRat(yyData, NU ($3), NU ($4), NU ($6), NU ($7), $5, $8, - conf_core.appearance.rat_thickness, $9); - } - | T_RAT '(' measure measure INTEGER measure measure INTEGER INTEGER ')' - { - CreateNewRat(yyData, OU ($3), OU ($4), OU ($6), OU ($7), $5, $8, - conf_core.appearance.rat_thickness, OldFlags($9)); - } - ; - -/* %start-doc pcbfile Layer - -@syntax -Layer (LayerNum "Name") ( -@ @ @ @dots{} contents @dots{} -) -@end syntax - -@table @var -@item LayerNum -The layer number. Layers are numbered sequentially, starting with 1. -The last two layers (9 and 10 by default) are solder-side silk and -component-side silk, in that order. -@item Name -The layer name. -@item contents -The contents of the layer, which may include attributes, lines, arcs, rectangles, -text, and polygons. -@end table - -%end-doc */ - -layer - /* name */ - : T_LAYER '(' INTEGER STRING opt_string ')' '(' - { - if ($3 <= 0 || $3 > MAX_LAYER + 2) - { - yyerror("Layernumber out of range"); - YYABORT; - } - if (LayerFlag[$3-1]) - { - yyerror("Layernumber used twice"); - YYABORT; - } - Layer = &yyData->Layer[$3-1]; - - /* memory for name is already allocated */ - if (Layer->Name != NULL) - free(Layer->Name); - Layer->Name = $4; - LayerFlag[$3-1] = true; - if (yyData->LayerN + 2 < $3) - yyData->LayerN = $3 - 2; - if ($5 != NULL) - free($5); - } - layerdata ')' - ; - -layerdata - : layerdefinitions - | - ; - -layerdefinitions - : layerdefinition - | layerdefinitions layerdefinition - ; - -layerdefinition - : line_hi_format - | line_1.7_format - | line_oldformat - | arc_hi_format - | arc_1.7_format - | arc_oldformat - /* x1, y1, x2, y2, flags */ - | T_RECTANGLE '(' measure measure measure measure INTEGER ')' - { - CreateNewPolygonFromRectangle(Layer, - OU ($3), OU ($4), OU ($3) + OU ($5), OU ($4) + OU ($6), OldFlags($7)); - } - | text_hi_format - | text_newformat - | text_oldformat - | { attr_list = & Layer->Attributes; } attribute - | polygon_format - -/* %start-doc pcbfile Line - -@syntax -Line [X1 Y1 X2 Y2 Thickness Clearance SFlags] -Line (X1 Y1 X2 Y2 Thickness Clearance NFlags) -Line (X1 Y1 X2 Y2 Thickness NFlags) -@end syntax - -@table @var -@item X1 Y1 X2 Y2 -The end points of the line -@item Thickness -The width of the line -@item Clearance -The amount of space cleared around the line when the line passes -through a polygon. The clearance is added to the thickness to get the -thickness of the clear; thus the space between the line and the -polygon is @math{Clearance/2} wide. -@item SFlags -Symbolic or numeric flags -@item NFlags -Numeric flags. -@end table - -%end-doc */ - -line_hi_format - /* x1, y1, x2, y2, thickness, clearance, flags */ - : T_LINE '[' measure measure measure measure measure measure flags ']' - { - CreateNewLineOnLayer(Layer, NU ($3), NU ($4), NU ($5), NU ($6), - NU ($7), NU ($8), $9); - } - ; - -line_1.7_format - /* x1, y1, x2, y2, thickness, clearance, flags */ - : T_LINE '(' measure measure measure measure measure measure INTEGER ')' - { - CreateNewLineOnLayer(Layer, OU ($3), OU ($4), OU ($5), OU ($6), - OU ($7), OU ($8), OldFlags($9)); - } - ; - -line_oldformat - /* x1, y1, x2, y2, thickness, flags */ - : T_LINE '(' measure measure measure measure measure measure ')' - { - /* eliminate old-style rat-lines */ - if ((IV ($8) & RATFLAG) == 0) - CreateNewLineOnLayer(Layer, OU ($3), OU ($4), OU ($5), OU ($6), OU ($7), - 200*GROUNDPLANEFRAME, OldFlags(IV ($8))); - } - ; - -/* %start-doc pcbfile Arc - -@syntax -Arc [X Y Width Height Thickness Clearance StartAngle DeltaAngle SFlags] -Arc (X Y Width Height Thickness Clearance StartAngle DeltaAngle NFlags) -Arc (X Y Width Height Thickness StartAngle DeltaAngle NFlags) -@end syntax - -@table @var -@item X Y -Coordinates of the center of the arc. -@item Width Height -The width and height, from the center to the edge. The bounds of the -circle of which this arc is a segment, is thus @math{2*Width} by -@math{2*Height}. -@item Thickness -The width of the copper trace which forms the arc. -@item Clearance -The amount of space cleared around the arc when the line passes -through a polygon. The clearance is added to the thickness to get the -thickness of the clear; thus the space between the arc and the polygon -is @math{Clearance/2} wide. -@item StartAngle -The angle of one end of the arc, in degrees. In PCB, an angle of zero -points left (negative X direction), and 90 degrees points down -(positive Y direction). -@item DeltaAngle -The sweep of the arc. This may be negative. Positive angles sweep -counterclockwise. -@item SFlags -Symbolic or numeric flags. -@item NFlags -Numeric flags. -@end table - -%end-doc */ - -arc_hi_format - /* x, y, width, height, thickness, clearance, startangle, delta, flags */ - : T_ARC '[' measure measure measure measure measure measure number number flags ']' - { - CreateNewArcOnLayer(Layer, NU ($3), NU ($4), NU ($5), NU ($6), $9, $10, - NU ($7), NU ($8), $11); - } - ; - -arc_1.7_format - /* x, y, width, height, thickness, clearance, startangle, delta, flags */ - : T_ARC '(' measure measure measure measure measure measure number number INTEGER ')' - { - CreateNewArcOnLayer(Layer, OU ($3), OU ($4), OU ($5), OU ($6), $9, $10, - OU ($7), OU ($8), OldFlags($11)); - } - ; - -arc_oldformat - /* x, y, width, height, thickness, startangle, delta, flags */ - : T_ARC '(' measure measure measure measure measure measure number INTEGER ')' - { - CreateNewArcOnLayer(Layer, OU ($3), OU ($4), OU ($5), OU ($5), IV ($8), $9, - OU ($7), 200*GROUNDPLANEFRAME, OldFlags($10)); - } - ; - -/* %start-doc pcbfile Text - -@syntax -Text [X Y Direction Scale "String" SFlags] -Text (X Y Direction Scale "String" NFlags) -Text (X Y Direction "String" NFlags) -@end syntax - -@table @var -@item X Y -The location of the upper left corner of the text. -@item Direction -0 means text is drawn left to right, 1 means up, 2 means right to left -(i.e. upside down), and 3 means down. -@item Scale -Size of the text, as a percentage of the ``default'' size of of the -font (the default font is about 40 mils high). Default is 100 (40 -mils). -@item String -The string to draw. -@item SFlags -Symbolic or numeric flags. -@item NFlags -Numeric flags. -@end table - -%end-doc */ - -text_oldformat - /* x, y, direction, text, flags */ - : T_TEXT '(' measure measure number STRING INTEGER ')' - { - /* use a default scale of 100% */ - CreateNewText(Layer,yyFont,OU ($3), OU ($4), $5, 100, $6, OldFlags($7)); - free ($6); - } - ; - -text_newformat - /* x, y, direction, scale, text, flags */ - : T_TEXT '(' measure measure number number STRING INTEGER ')' - { - if ($8 & ONSILKFLAG) - { - LayerTypePtr lay = &yyData->Layer[yyData->LayerN + - (($8 & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)]; - - CreateNewText(lay ,yyFont, OU ($3), OU ($4), $5, $6, $7, - OldFlags($8)); - } - else - CreateNewText(Layer, yyFont, OU ($3), OU ($4), $5, $6, $7, - OldFlags($8)); - free ($7); - } - ; -text_hi_format - /* x, y, direction, scale, text, flags */ - : T_TEXT '[' measure measure number number STRING flags ']' - { - /* FIXME: shouldn't know about .f */ - /* I don't think this matters because anything with hi_format - * will have the silk on its own layer in the file rather - * than using the ONSILKFLAG and having it in a copper layer. - * Thus there is no need for anything besides the 'else' - * part of this code. - */ - if ($8.f & ONSILKFLAG) - { - LayerTypePtr lay = &yyData->Layer[yyData->LayerN + - (($8.f & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)]; - - CreateNewText(lay, yyFont, NU ($3), NU ($4), $5, $6, $7, $8); - } - else - CreateNewText(Layer, yyFont, NU ($3), NU ($4), $5, $6, $7, $8); - free ($7); - } - ; - -/* %start-doc pcbfile Polygon - -@syntax -Polygon (SFlags) ( -@ @ @ @dots{} (X Y) @dots{} -@ @ @ @dots{} [X Y] @dots{} -@ @ @ Hole ( -@ @ @ @ @ @ @dots{} (X Y) @dots{} -@ @ @ @ @ @ @dots{} [X Y] @dots{} -@ @ @ ) -@ @ @ @dots{} -) -@end syntax - -@table @var -@item SFlags -Symbolic or numeric flags. -@item X Y -Coordinates of each vertex. You must list at least three coordinates. -@item Hole (...) -Defines a hole within the polygon's outer contour. There may be zero or more such sections. -@end table - -%end-doc */ - -polygon_format - : /* flags are passed in */ - T_POLYGON '(' flags ')' '(' - { - Polygon = CreateNewPolygon(Layer, $3); - } - polygonpoints - polygonholes ')' - { - Cardinal contour, contour_start, contour_end; - bool bad_contour_found = false; - /* ignore junk */ - for (contour = 0; contour <= Polygon->HoleIndexN; contour++) - { - contour_start = (contour == 0) ? - 0 : Polygon->HoleIndex[contour - 1]; - contour_end = (contour == Polygon->HoleIndexN) ? - Polygon->PointN : - Polygon->HoleIndex[contour]; - if (contour_end - contour_start < 3) - bad_contour_found = true; - } - - if (bad_contour_found) - { - Message("WARNING parsing file '%s'\n" - " line: %i\n" - " description: 'ignored polygon (< 3 points in a contour)'\n", - yyfilename, yylineno); - DestroyObject(yyData, POLYGON_TYPE, Layer, Polygon, Polygon); - } - else - { - SetPolygonBoundingBox (Polygon); - if (!Layer->polygon_tree) - Layer->polygon_tree = r_create_tree (NULL, 0, 0); - r_insert_entry (Layer->polygon_tree, (BoxType *) Polygon, 0); - } - } - ; - -polygonholes - : /* empty */ - | polygonholes polygonhole - ; - -polygonhole - : T_POLYGON_HOLE '(' - { - CreateNewHoleInPolygon (Polygon); - } - polygonpoints ')' - ; - -polygonpoints - : /* empty */ - | polygonpoint polygonpoints - ; - -polygonpoint - /* xcoord ycoord */ - : '(' measure measure ')' - { - CreateNewPointInPolygon(Polygon, OU ($2), OU ($3)); - } - | '[' measure measure ']' - { - CreateNewPointInPolygon(Polygon, NU ($2), NU ($3)); - } - ; - -/* %start-doc pcbfile Element - -@syntax -Element [SFlags "Desc" "Name" "Value" MX MY TX TY TDir TScale TSFlags] ( -Element (NFlags "Desc" "Name" "Value" MX MY TX TY TDir TScale TNFlags) ( -Element (NFlags "Desc" "Name" "Value" TX TY TDir TScale TNFlags) ( -Element (NFlags "Desc" "Name" TX TY TDir TScale TNFlags) ( -Element ("Desc" "Name" TX TY TDir TScale TNFlags) ( -@ @ @ @dots{} contents @dots{} -) -@end syntax - -@table @var -@item SFlags -Symbolic or numeric flags, for the element as a whole. -@item NFlags -Numeric flags, for the element as a whole. -@item Desc -The description of the element. This is one of the three strings -which can be displayed on the screen. -@item Name -The name of the element, usually the reference designator. -@item Value -The value of the element. -@item MX MY -The location of the element's mark. This is the reference point -for placing the element and its pins and pads. -@item TX TY -The upper left corner of the text (one of the three strings). -@item TDir -The relative direction of the text. 0 means left to right for -an unrotated element, 1 means up, 2 left, 3 down. -@item TScale -Size of the text, as a percentage of the ``default'' size of of the -font (the default font is about 40 mils high). Default is 100 (40 -mils). -@item TSFlags -Symbolic or numeric flags, for the text. -@item TNFlags -Numeric flags, for the text. -@end table - -Elements may contain pins, pads, element lines, element arcs, -attributes, and (for older elements) an optional mark. Note that -element definitions that have the mark coordinates in the element -line, only support pins and pads which use relative coordinates. The -pin and pad coordinates are relative to the mark. Element definitions -which do not include the mark coordinates in the element line, may -have a Mark definition in their contents, and only use pin and pad -definitions which use absolute coordinates. - -%end-doc */ - -element - : element_oldformat - | element_1.3.4_format - | element_newformat - | element_1.7_format - | element_hi_format - ; - -element_oldformat - /* element_flags, description, pcb-name, - * text_x, text_y, text_direction, text_scale, text_flags - */ - : T_ELEMENT '(' STRING STRING measure measure INTEGER ')' '(' - { - yyElement = CreateNewElement(yyData, yyElement, yyFont, NoFlags(), - $3, $4, NULL, OU ($5), OU ($6), $7, 100, NoFlags(), false); - free ($3); - free ($4); - pin_num = 1; - } - elementdefinitions ')' - { - SetElementBoundingBox(yyData, yyElement, yyFont); - } - ; - -element_1.3.4_format - /* element_flags, description, pcb-name, - * text_x, text_y, text_direction, text_scale, text_flags - */ - : T_ELEMENT '(' INTEGER STRING STRING measure measure measure measure INTEGER ')' '(' - { - yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3), - $4, $5, NULL, OU ($6), OU ($7), IV ($8), IV ($9), OldFlags($10), false); - free ($4); - free ($5); - pin_num = 1; - } - elementdefinitions ')' - { - SetElementBoundingBox(yyData, yyElement, yyFont); - } - ; - -element_newformat - /* element_flags, description, pcb-name, value, - * text_x, text_y, text_direction, text_scale, text_flags - */ - : T_ELEMENT '(' INTEGER STRING STRING STRING measure measure measure measure INTEGER ')' '(' - { - yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3), - $4, $5, $6, OU ($7), OU ($8), IV ($9), IV ($10), OldFlags($11), false); - free ($4); - free ($5); - free ($6); - pin_num = 1; - } - elementdefinitions ')' - { - SetElementBoundingBox(yyData, yyElement, yyFont); - } - ; - -element_1.7_format - /* element_flags, description, pcb-name, value, mark_x, mark_y, - * text_x, text_y, text_direction, text_scale, text_flags - */ - : T_ELEMENT '(' INTEGER STRING STRING STRING measure measure - measure measure number number INTEGER ')' '(' - { - yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3), - $4, $5, $6, OU ($7) + OU ($9), OU ($8) + OU ($10), - $11, $12, OldFlags($13), false); - yyElement->MarkX = OU ($7); - yyElement->MarkY = OU ($8); - free ($4); - free ($5); - free ($6); - } - relementdefs ')' - { - SetElementBoundingBox(yyData, yyElement, yyFont); - } - ; - -element_hi_format - /* element_flags, description, pcb-name, value, mark_x, mark_y, - * text_x, text_y, text_direction, text_scale, text_flags - */ - : T_ELEMENT '[' flags STRING STRING STRING measure measure - measure measure number number flags ']' '(' - { - yyElement = CreateNewElement(yyData, yyElement, yyFont, $3, - $4, $5, $6, NU ($7) + NU ($9), NU ($8) + NU ($10), - $11, $12, $13, false); - yyElement->MarkX = NU ($7); - yyElement->MarkY = NU ($8); - free ($4); - free ($5); - free ($6); - } - relementdefs ')' - { - SetElementBoundingBox(yyData, yyElement, yyFont); - } - ; - -/* %start-doc pcbfile ElementLine - -@syntax -ElementLine [X1 Y1 X2 Y2 Thickness] -ElementLine (X1 Y1 X2 Y2 Thickness) -@end syntax - -@table @var -@item X1 Y1 X2 Y2 -Coordinates of the endpoints of the line. These are relative to the -Element's mark point for new element formats, or absolute for older -formats. -@item Thickness -The width of the silk for this line. -@end table - -%end-doc */ - -/* %start-doc pcbfile ElementArc - -@syntax -ElementArc [X Y Width Height StartAngle DeltaAngle Thickness] -ElementArc (X Y Width Height StartAngle DeltaAngle Thickness) -@end syntax - -@table @var -@item X Y -Coordinates of the center of the arc. These are relative to the -Element's mark point for new element formats, or absolute for older -formats. -@item Width Height -The width and height, from the center to the edge. The bounds of the -circle of which this arc is a segment, is thus @math{2*Width} by -@math{2*Height}. -@item StartAngle -The angle of one end of the arc, in degrees. In PCB, an angle of zero -points left (negative X direction), and 90 degrees points down -(positive Y direction). -@item DeltaAngle -The sweep of the arc. This may be negative. Positive angles sweep -counterclockwise. -@item Thickness -The width of the silk line which forms the arc. -@end table - -%end-doc */ - -/* %start-doc pcbfile Mark - -@syntax -Mark [X Y] -Mark (X Y) -@end syntax - -@table @var -@item X Y -Coordinates of the Mark, for older element formats that don't have -the mark as part of the Element line. -@end table - -%end-doc */ - -elementdefinitions - : elementdefinition - | elementdefinitions elementdefinition - ; - -elementdefinition - : pin_1.6.3_format - | pin_newformat - | pin_oldformat - | pad_newformat - | pad - /* x1, y1, x2, y2, thickness */ - | T_ELEMENTLINE '[' measure measure measure measure measure ']' - { - CreateNewLineInElement(yyElement, NU ($3), NU ($4), NU ($5), NU ($6), NU ($7)); - } - /* x1, y1, x2, y2, thickness */ - | T_ELEMENTLINE '(' measure measure measure measure measure ')' - { - CreateNewLineInElement(yyElement, OU ($3), OU ($4), OU ($5), OU ($6), OU ($7)); - } - /* x, y, width, height, startangle, anglediff, thickness */ - | T_ELEMENTARC '[' measure measure measure measure number number measure ']' - { - CreateNewArcInElement(yyElement, NU ($3), NU ($4), NU ($5), NU ($6), $7, $8, NU ($9)); - } - /* x, y, width, height, startangle, anglediff, thickness */ - | T_ELEMENTARC '(' measure measure measure measure number number measure ')' - { - CreateNewArcInElement(yyElement, OU ($3), OU ($4), OU ($5), OU ($6), $7, $8, OU ($9)); - } - /* x, y position */ - | T_MARK '[' measure measure ']' - { - yyElement->MarkX = NU ($3); - yyElement->MarkY = NU ($4); - } - | T_MARK '(' measure measure ')' - { - yyElement->MarkX = OU ($3); - yyElement->MarkY = OU ($4); - } - | { attr_list = & yyElement->Attributes; } attribute - ; - -relementdefs - : relementdef - | relementdefs relementdef - ; - -relementdef - : pin_1.7_format - | pin_hi_format - | pad_1.7_format - | pad_hi_format - /* x1, y1, x2, y2, thickness */ - | T_ELEMENTLINE '[' measure measure measure measure measure ']' - { - CreateNewLineInElement(yyElement, NU ($3) + yyElement->MarkX, - NU ($4) + yyElement->MarkY, NU ($5) + yyElement->MarkX, - NU ($6) + yyElement->MarkY, NU ($7)); - } - | T_ELEMENTLINE '(' measure measure measure measure measure ')' - { - CreateNewLineInElement(yyElement, OU ($3) + yyElement->MarkX, - OU ($4) + yyElement->MarkY, OU ($5) + yyElement->MarkX, - OU ($6) + yyElement->MarkY, OU ($7)); - } - /* x, y, width, height, startangle, anglediff, thickness */ - | T_ELEMENTARC '[' measure measure measure measure number number measure ']' - { - CreateNewArcInElement(yyElement, NU ($3) + yyElement->MarkX, - NU ($4) + yyElement->MarkY, NU ($5), NU ($6), $7, $8, NU ($9)); - } - | T_ELEMENTARC '(' measure measure measure measure number number measure ')' - { - CreateNewArcInElement(yyElement, OU ($3) + yyElement->MarkX, - OU ($4) + yyElement->MarkY, OU ($5), OU ($6), $7, $8, OU ($9)); - } - | { attr_list = & yyElement->Attributes; } attribute - ; - -/* %start-doc pcbfile Pin - -@syntax -Pin [rX rY Thickness Clearance Mask Drill "Name" "Number" SFlags] -Pin (rX rY Thickness Clearance Mask Drill "Name" "Number" NFlags) -Pin (aX aY Thickness Drill "Name" "Number" NFlags) -Pin (aX aY Thickness Drill "Name" NFlags) -Pin (aX aY Thickness "Name" NFlags) -@end syntax - -@table @var -@item rX rY -coordinates of center, relative to the element's mark -@item aX aY -absolute coordinates of center. -@item Thickness -outer diameter of copper annulus -@item Clearance -add to thickness to get clearance diameter -@item Mask -diameter of solder mask opening -@item Drill -diameter of drill -@item Name -name of pin -@item Number -number of pin -@item SFlags -symbolic or numerical flags -@item NFlags -numerical flags only -@end table - -%end-doc */ - -pin_hi_format - /* x, y, thickness, clearance, mask, drilling hole, name, - number, flags */ - : T_PIN '[' measure measure measure measure measure measure STRING STRING flags ']' - { - CreateNewPin(yyElement, NU ($3) + yyElement->MarkX, - NU ($4) + yyElement->MarkY, NU ($5), NU ($6), NU ($7), NU ($8), $9, - $10, $11); - free ($9); - free ($10); - } - ; -pin_1.7_format - /* x, y, thickness, clearance, mask, drilling hole, name, - number, flags */ - : T_PIN '(' measure measure measure measure measure measure STRING STRING INTEGER ')' - { - CreateNewPin(yyElement, OU ($3) + yyElement->MarkX, - OU ($4) + yyElement->MarkY, OU ($5), OU ($6), OU ($7), OU ($8), $9, - $10, OldFlags($11)); - free ($9); - free ($10); - } - ; - -pin_1.6.3_format - /* x, y, thickness, drilling hole, name, number, flags */ - : T_PIN '(' measure measure measure measure STRING STRING INTEGER ')' - { - CreateNewPin(yyElement, OU ($3), OU ($4), OU ($5), 2*GROUNDPLANEFRAME, - OU ($5) + 2*MASKFRAME, OU ($6), $7, $8, OldFlags($9)); - free ($7); - free ($8); - } - ; - -pin_newformat - /* x, y, thickness, drilling hole, name, flags */ - : T_PIN '(' measure measure measure measure STRING INTEGER ')' - { - char p_number[8]; - - sprintf(p_number, "%d", pin_num++); - CreateNewPin(yyElement, OU ($3), OU ($4), OU ($5), 2*GROUNDPLANEFRAME, - OU ($5) + 2*MASKFRAME, OU ($6), $7, p_number, OldFlags($8)); - - free ($7); - } - ; - -pin_oldformat - /* old format: x, y, thickness, name, flags - * drilling hole is 40% of the diameter - */ - : T_PIN '(' measure measure measure STRING INTEGER ')' - { - Coord hole = OU ($5) * DEFAULT_DRILLINGHOLE; - char p_number[8]; - - /* make sure that there's enough copper left */ - if (OU ($5) - hole < MIN_PINORVIACOPPER && - OU ($5) > MIN_PINORVIACOPPER) - hole = OU ($5) - MIN_PINORVIACOPPER; - - sprintf(p_number, "%d", pin_num++); - CreateNewPin(yyElement, OU ($3), OU ($4), OU ($5), 2*GROUNDPLANEFRAME, - OU ($5) + 2*MASKFRAME, hole, $6, p_number, OldFlags($7)); - free ($6); - } - ; - -/* %start-doc pcbfile Pad - -@syntax -Pad [rX1 rY1 rX2 rY2 Thickness Clearance Mask "Name" "Number" SFlags] -Pad (rX1 rY1 rX2 rY2 Thickness Clearance Mask "Name" "Number" NFlags) -Pad (aX1 aY1 aX2 aY2 Thickness "Name" "Number" NFlags) -Pad (aX1 aY1 aX2 aY2 Thickness "Name" NFlags) -@end syntax - -@table @var -@item rX1 rY1 rX2 rY2 -Coordinates of the endpoints of the pad, relative to the element's -mark. Note that the copper extends beyond these coordinates by half -the thickness. To make a square or round pad, specify the same -coordinate twice. -@item aX1 aY1 aX2 aY2 -Same, but absolute coordinates of the endpoints of the pad. -@item Thickness -width of the pad. -@item Clearance -add to thickness to get clearance width. -@item Mask -width of solder mask opening. -@item Name -name of pin -@item Number -number of pin -@item SFlags -symbolic or numerical flags -@item NFlags -numerical flags only -@end table - -%end-doc */ - -pad_hi_format - /* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */ - : T_PAD '[' measure measure measure measure measure measure measure STRING STRING flags ']' - { - CreateNewPad(yyElement, NU ($3) + yyElement->MarkX, - NU ($4) + yyElement->MarkY, - NU ($5) + yyElement->MarkX, - NU ($6) + yyElement->MarkY, NU ($7), NU ($8), NU ($9), - $10, $11, $12); - free ($10); - free ($11); - } - ; - -pad_1.7_format - /* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */ - : T_PAD '(' measure measure measure measure measure measure measure STRING STRING INTEGER ')' - { - CreateNewPad(yyElement,OU ($3) + yyElement->MarkX, - OU ($4) + yyElement->MarkY, OU ($5) + yyElement->MarkX, - OU ($6) + yyElement->MarkY, OU ($7), OU ($8), OU ($9), - $10, $11, OldFlags($12)); - free ($10); - free ($11); - } - ; - -pad_newformat - /* x1, y1, x2, y2, thickness, name , pad number, flags */ - : T_PAD '(' measure measure measure measure measure STRING STRING INTEGER ')' - { - CreateNewPad(yyElement,OU ($3),OU ($4),OU ($5),OU ($6),OU ($7), 2*GROUNDPLANEFRAME, - OU ($7) + 2*MASKFRAME, $8, $9, OldFlags($10)); - free ($8); - free ($9); - } - ; - -pad - /* x1, y1, x2, y2, thickness, name and flags */ - : T_PAD '(' measure measure measure measure measure STRING INTEGER ')' - { - char p_number[8]; - - sprintf(p_number, "%d", pin_num++); - CreateNewPad(yyElement,OU ($3),OU ($4),OU ($5),OU ($6),OU ($7), 2*GROUNDPLANEFRAME, - OU ($7) + 2*MASKFRAME, $8,p_number, OldFlags($9)); - free ($8); - } - ; - -flags : INTEGER { $$ = OldFlags($1); } - | STRING { $$ = string_to_flags ($1, yyerror); free($1); } - ; - -symbols - : symbol - | symbols symbol - ; - -/* %start-doc pcbfile Symbol - -@syntax -Symbol [Char Delta] ( -Symbol (Char Delta) ( -@ @ @ @dots{} symbol lines @dots{} -) -@end syntax - -@table @var -@item Char -The character or numerical character value this symbol represents. -Characters must be in single quotes. -@item Delta -Additional space to allow after this character. -@end table - -%end-doc */ - -symbol : symbolhead symboldata ')' - -symbolhead : T_SYMBOL '[' symbolid measure ']' '(' - { - if ($3 <= 0 || $3 > MAX_FONTPOSITION) - { - yyerror("fontposition out of range"); - YYABORT; - } - Symbol = &yyFont->Symbol[$3]; - if (Symbol->Valid) - { - yyerror("symbol ID used twice"); - YYABORT; - } - Symbol->Valid = true; - Symbol->Delta = NU ($4); - } - | T_SYMBOL '(' symbolid measure ')' '(' - { - if ($3 <= 0 || $3 > MAX_FONTPOSITION) - { - yyerror("fontposition out of range"); - YYABORT; - } - Symbol = &yyFont->Symbol[$3]; - if (Symbol->Valid) - { - yyerror("symbol ID used twice"); - YYABORT; - } - Symbol->Valid = true; - Symbol->Delta = OU ($4); - } - ; - -symbolid - : INTEGER - | CHAR_CONST - ; - -symboldata - : /* empty */ - | symboldata symboldefinition - | symboldata hiressymbol - ; - -/* %start-doc pcbfile SymbolLine - -@syntax -SymbolLine [X1 Y1 X2 Y1 Thickness] -SymbolLine (X1 Y1 X2 Y1 Thickness) -@end syntax - -@table @var -@item X1 Y1 X2 Y2 -The endpoints of this line. -@item Thickness -The width of this line. -@end table - -%end-doc */ - -symboldefinition - /* x1, y1, x2, y2, thickness */ - : T_SYMBOLLINE '(' measure measure measure measure measure ')' - { - CreateNewLineInSymbol(Symbol, OU ($3), OU ($4), OU ($5), OU ($6), OU ($7)); - } - ; -hiressymbol - /* x1, y1, x2, y2, thickness */ - : T_SYMBOLLINE '[' measure measure measure measure measure ']' - { - CreateNewLineInSymbol(Symbol, NU ($3), NU ($4), NU ($5), NU ($6), NU ($7)); - } - ; - -/* %start-doc pcbfile Netlist - -@syntax -Netlist ( ) ( -@ @ @ @dots{} nets @dots{} -) -@end syntax - -%end-doc */ - -pcbnetlist : pcbnetdef - | - ; -pcbnetdef - /* net(...) net(...) ... */ - : T_NETLIST '(' ')' '(' - nets ')' - ; - -nets - : netdefs - | - ; - -netdefs - : net - | netdefs net - ; - - -/* %start-doc pcbfile Net - -@syntax -Net ("Name" "Style") ( -@ @ @ @dots{} connects @dots{} -) -@end syntax - -@table @var -@item Name -The name of this net. -@item Style -The routing style that should be used when autorouting this net. -@end table - -%end-doc */ - -net - /* name style pin pin ... */ - : T_NET '(' STRING STRING ')' '(' - { - Menu = CreateNewNet((LibraryTypePtr)&yyPCB->NetlistLib, $3, $4); - free ($3); - free ($4); - } - connections ')' - ; - -connections - : conndefs - | - ; - -conndefs - : conn - | conndefs conn - ; - -/* %start-doc pcbfile Connect - -@syntax -Connect ("PinPad") -@end syntax - -@table @var -@item PinPad -The name of a pin or pad which is included in this net. Pin and Pad -names are named by the refdes and pin name, like @code{"U14-7"} for -pin 7 of U14, or @code{"T4-E"} for pin E of T4. -@end table - -%end-doc */ - -conn - : T_CONN '(' STRING ')' - { - CreateNewConnection(Menu, $3); - free ($3); - } - ; - -/* %start-doc pcbfile Netlistpatch - -@syntax -NetListPatch ( ) ( -@ @ @ @dots{} netpatch @dots{} -) -@end syntax - -%end-doc */ - -pcbnetlistpatch : pcbnetpatchdef - | - ; -pcbnetpatchdef - /* net(...) net(...) ... */ - : T_NETLISTPATCH '(' ')' '(' - netpatches ')' - ; - -netpatches - : netpatchdefs - | - ; - -netpatchdefs - : netpatch - | netpatchdefs netpatch - ; - -/* %start-doc pcbfile NetPatch - -@syntax -op (arg1 arg2 ...) ( -@ @ @ @dots{} netlist patch directive @dots{} -) -@end syntax - -%end-doc */ - -netpatch - /* name style pin pin ... */ - : T_ADD_CONN '(' STRING STRING ')' { rats_patch_append(yyPCB, RATP_ADD_CONN, $3, $4, NULL); free($3); free($4); } - | T_DEL_CONN '(' STRING STRING ')' { rats_patch_append(yyPCB, RATP_DEL_CONN, $3, $4, NULL); free($3); free($4); } - | T_CHANGE_ATTRIB '(' STRING STRING STRING ')' { rats_patch_append(yyPCB, RATP_CHANGE_ATTRIB, $3, $4, $5); free($3); free($4); free($5); } - ; - - -/* %start-doc pcbfile Attribute - -@syntax -Attribute ("Name" "Value") -@end syntax - -Attributes allow boards and elements to have arbitrary data attached -to them, which is not directly used by PCB itself but may be of use by -other programs or users. - -@table @var -@item Name -The name of the attribute - -@item Value -The value of the attribute. Values are always stored as strings, even -if the value is interpreted as, for example, a number. - -@end table - -%end-doc */ - -attribute - : T_ATTRIBUTE '(' STRING STRING ')' - { - CreateNewAttribute (attr_list, $3, $4 ? $4 : (char *)""); - free ($3); - free ($4); - } - ; - -opt_string : STRING { $$ = $1; } - | /* empty */ { $$ = 0; } - ; - -number - : FLOATING { $$ = $1; } - | INTEGER { $$ = $1; } - ; - -measure - /* Default unit (no suffix) is cmil */ - : number { do_measure(&$$, $1, MIL_TO_COORD ($1) / 100.0, 0); } - | number T_UMIL { M ($$, $1, MIL_TO_COORD ($1) / 100000.0); } - | number T_CMIL { M ($$, $1, MIL_TO_COORD ($1) / 100.0); } - | number T_MIL { M ($$, $1, MIL_TO_COORD ($1)); } - | number T_IN { M ($$, $1, INCH_TO_COORD ($1)); } - | number T_NM { M ($$, $1, MM_TO_COORD ($1) / 1000000.0); } - | number T_UM { M ($$, $1, MM_TO_COORD ($1) / 1000.0); } - | number T_MM { M ($$, $1, MM_TO_COORD ($1)); } - | number T_M { M ($$, $1, MM_TO_COORD ($1) * 1000.0); } - | number T_KM { M ($$, $1, MM_TO_COORD ($1) * 1000000.0); } - ; - -%% - -/* --------------------------------------------------------------------------- - * error routine called by parser library - */ -int yyerror(const char * s) -{ - Message("ERROR parsing file '%s'\n" - " line: %i\n" - " description: '%s'\n", - yyfilename, yylineno, s); - return(0); -} - -int yywrap() -{ - return 1; -} - -static int -check_file_version (int ver) -{ - if ( ver > PCB_FILE_VERSION ) { - Message ("ERROR: The file you are attempting to load is in a format\n" - "which is too new for this version of pcb. To load this file\n" - "you need a version of pcb which is >= %d. If you are\n" - "using a version built from git source, the source date\n" - "must be >= %d. This copy of pcb can only read files\n" - "up to file version %d.\n", ver, ver, PCB_FILE_VERSION); - return 1; - } - - return 0; -} - -static void -do_measure (PLMeasure *m, Coord i, double d, int u) -{ - m->ival = i; - m->bval = round (d); - m->dval = d; - m->has_units = u; -} - -static int -integer_value (PLMeasure m) -{ - if (m.has_units) - yyerror("units ignored here"); - return m.ival; -} - -static Coord -old_units (PLMeasure m) -{ - if (m.has_units) - return m.bval; - return round (MIL_TO_COORD (m.ival)); -} - -static Coord -new_units (PLMeasure m) -{ - if (m.has_units) - return m.bval; - return round (MIL_TO_COORD (m.ival) / 100.0); -} Index: trunk/src/parse_l.c =================================================================== --- trunk/src/parse_l.c (revision 1760) +++ trunk/src/parse_l.c (nonexistent) @@ -1,2501 +0,0 @@ - -#line 3 "lex.yy.c" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 35 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN (yy_start) = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START (((yy_start) - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart(yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -extern int yyleng; - -extern FILE *yyin, *yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires - * access to the local variable yy_act. Since yyless() is a macro, it would break - * existing scanners that call yyless() from OUTSIDE yylex. - * One obvious solution it to make yy_act a global. I tried that, and saw - * a 5% performance hit in a non-yylineno scanner, because yy_act is - * normally declared as a register variable-- so it is not worth it. - */ - #define YY_LESS_LINENO(n) \ - do { \ - int yyl;\ - for ( yyl = n; yyl < yyleng; ++yyl )\ - if ( yytext[yyl] == '\n' )\ - --yylineno;\ - }while(0) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, (yytext_ptr) ) - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] - -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; -static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 0; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void yyrestart (FILE *input_file ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); -void yy_delete_buffer (YY_BUFFER_STATE b ); -void yy_flush_buffer (YY_BUFFER_STATE b ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); -void yypop_buffer_state (void ); - -static void yyensure_buffer_stack (void ); -static void yy_load_buffer_state (void ); -static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); - -#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) - -YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ); - -void *yyalloc (yy_size_t ); -void *yyrealloc (void *,yy_size_t ); -void yyfree (void * ); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -typedef unsigned char YY_CHAR; - -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; - -typedef int yy_state_type; - -extern int yylineno; - -int yylineno = 1; - -extern char *yytext; -#define yytext_ptr yytext - -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; - -#define YY_NUM_RULES 55 -#define YY_END_OF_BUFFER 56 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_accept[222] = - { 0, - 0, 0, 56, 54, 51, 52, 53, 54, 50, 54, - 54, 47, 47, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 39, 54, 54, 51, 0, 49, 0, - 50, 0, 47, 47, 46, 0, 47, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 44, 40, 0, 38, - 36, 37, 45, 46, 48, 27, 0, 0, 0, 7, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, - - 2, 11, 10, 0, 14, 0, 0, 0, 0, 0, - 12, 0, 0, 0, 0, 43, 0, 0, 0, 0, - 0, 0, 0, 3, 0, 26, 0, 13, 22, 0, - 0, 0, 0, 0, 16, 0, 0, 0, 42, 0, - 41, 0, 0, 0, 0, 0, 8, 0, 9, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 4, 0, 0, 23, 0, 0, 0, 0, 24, - 21, 0, 0, 0, 0, 0, 30, 19, 0, 28, - 0, 25, 0, 0, 5, 0, 0, 0, 0, 0, - 0, 0, 0, 6, 0, 0, 32, 0, 33, 35, - - 0, 0, 0, 0, 15, 0, 0, 18, 0, 0, - 0, 20, 0, 17, 1, 0, 0, 31, 0, 34, - 0 - } ; - -static yyconst flex_int32_t yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 5, 6, 1, 1, 1, 7, 1, - 1, 1, 8, 1, 8, 9, 1, 10, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 1, 1, 1, - 1, 1, 1, 1, 12, 13, 14, 15, 16, 17, - 18, 19, 1, 1, 1, 20, 21, 22, 1, 23, - 1, 24, 25, 26, 1, 27, 1, 1, 1, 1, - 1, 28, 1, 1, 29, 1, 30, 31, 32, 33, - - 34, 35, 36, 37, 38, 1, 39, 40, 41, 42, - 43, 44, 1, 45, 46, 47, 48, 1, 1, 49, - 50, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst flex_int32_t yy_meta[51] = - { 0, - 1, 1, 2, 3, 1, 1, 1, 1, 1, 4, - 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, - 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 - } ; - -static yyconst flex_int16_t yy_base[226] = - { 0, - 0, 0, 256, 257, 253, 257, 257, 46, 0, 0, - 42, 45, 46, 13, 16, 230, 213, 23, 207, 208, - 32, 220, 215, 52, 35, 21, 38, 210, 214, 36, - 212, 203, 203, 38, 202, 201, 239, 73, 257, 236, - 0, 232, 229, 74, 70, 0, 77, 205, 189, 193, - 189, 219, 198, 191, 200, 53, 189, 178, 185, 181, - 178, 211, 190, 180, 181, 173, 187, 168, 176, 167, - 181, 184, 180, 182, 173, 170, 257, 257, 169, 257, - 257, 170, 257, 82, 0, 257, 162, 164, 159, 257, - 163, 169, 166, 168, 152, 165, 164, 163, 157, 175, - - 257, 257, 257, 144, 257, 146, 152, 160, 143, 144, - 257, 159, 145, 146, 156, 257, 144, 145, 148, 138, - 146, 152, 132, 257, 133, 257, 131, 257, 257, 137, - 77, 144, 139, 129, 257, 130, 138, 133, 257, 136, - 257, 136, 134, 120, 122, 129, 257, 116, 257, 115, - 115, 116, 116, 111, 116, 125, 111, 119, 109, 103, - 103, 257, 102, 103, 257, 100, 112, 103, 108, 257, - 123, 102, 99, 111, 97, 91, 257, 85, 91, 113, - 105, 257, 94, 95, 257, 90, 101, 88, 95, 83, - 89, 88, 93, 257, 85, 74, 257, 68, 257, 257, - - 80, 69, 67, 62, 257, 74, 60, 257, 72, 62, - 71, 257, 57, 257, 257, 63, 61, 257, 67, 257, - 257, 113, 117, 121, 63 - } ; - -static yyconst flex_int16_t yy_def[226] = - { 0, - 221, 1, 221, 221, 221, 221, 221, 222, 223, 224, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 222, 221, 222, - 223, 221, 221, 221, 221, 225, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 225, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 0, 221, 221, 221, 221 - } ; - -static yyconst flex_int16_t yy_nxt[308] = - { 0, - 4, 5, 6, 7, 8, 9, 10, 11, 4, 12, - 13, 14, 4, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 4, 4, 29, - 4, 30, 31, 4, 4, 4, 4, 32, 33, 4, - 34, 35, 4, 4, 4, 4, 4, 36, 4, 4, - 39, 43, 44, 45, 45, 47, 47, 48, 50, 49, - 54, 58, 55, 51, 66, 62, 85, 68, 67, 59, - 69, 70, 74, 40, 71, 79, 75, 39, 80, 84, - 84, 63, 45, 47, 47, 45, 47, 47, 151, 64, - 94, 84, 84, 46, 65, 95, 190, 220, 219, 218, - - 40, 217, 216, 215, 191, 214, 213, 212, 211, 210, - 209, 208, 152, 38, 207, 206, 38, 41, 205, 41, - 41, 42, 204, 42, 42, 203, 202, 201, 200, 199, - 198, 197, 196, 195, 194, 193, 192, 189, 188, 187, - 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, - 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, - 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, - 156, 155, 154, 153, 150, 149, 148, 147, 146, 145, - 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, - 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, - - 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, - 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, - 104, 103, 102, 101, 100, 99, 98, 97, 96, 93, - 92, 91, 90, 89, 88, 87, 86, 45, 83, 38, - 37, 82, 81, 78, 77, 76, 73, 72, 61, 60, - 57, 56, 53, 52, 37, 221, 3, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - - 221, 221, 221, 221, 221, 221, 221 - } ; - -static yyconst flex_int16_t yy_chk[308] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 8, 11, 11, 12, 13, 13, 13, 14, 15, 14, - 18, 21, 18, 15, 25, 24, 225, 26, 25, 21, - 26, 27, 30, 8, 27, 34, 30, 38, 34, 45, - 45, 24, 44, 44, 44, 47, 47, 47, 131, 24, - 56, 84, 84, 12, 24, 56, 178, 219, 217, 216, - - 38, 213, 211, 210, 178, 209, 207, 206, 204, 203, - 202, 201, 131, 222, 198, 196, 222, 223, 195, 223, - 223, 224, 193, 224, 224, 192, 191, 190, 189, 188, - 187, 186, 184, 183, 181, 180, 179, 176, 175, 174, - 173, 172, 171, 169, 168, 167, 166, 164, 163, 161, - 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, - 150, 148, 146, 145, 144, 143, 142, 140, 138, 137, - 136, 134, 133, 132, 130, 127, 125, 123, 122, 121, - 120, 119, 118, 117, 115, 114, 113, 112, 110, 109, - 108, 107, 106, 104, 100, 99, 98, 97, 96, 95, - - 94, 93, 92, 91, 89, 88, 87, 82, 79, 76, - 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, - 65, 64, 63, 62, 61, 60, 59, 58, 57, 55, - 54, 53, 52, 51, 50, 49, 48, 43, 42, 40, - 37, 36, 35, 33, 32, 31, 29, 28, 23, 22, - 20, 19, 17, 16, 5, 3, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - - 221, 221, 221, 221, 221, 221, 221 - } ; - -/* Table of booleans, true if rule could match eol. */ -static yyconst flex_int32_t yy_rule_can_match_eol[56] = - { 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, }; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -extern int yy_flex_debug; -int yy_flex_debug = 0; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *yytext; -#line 1 "parse_l.l" -/* $Id$ */ -#line 4 "parse_l.l" -/* - * COPYRIGHT - * - * PCB, interactive printed circuit board design - * Copyright (C) 1994,1995,1996,2006 Thomas Nau - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Contact addresses for paper mail and Email: - * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany - * Thomas.Nau@rz.uni-ulm.de - * - */ - -/* lexical definitions to parse ASCII input of PCB and Element description - */ - -#include "config.h" -#include "conf_core.h" - -#include -#include -#include -#include - -#if defined(_POSIX_SOURCE) || defined(_HPUX_SOURCE) -#include -#endif - -#include "global.h" - -#ifdef HAVE_LIBDMALLOC -# include /* see http://dmalloc.com */ -#endif - -RCSID("$Id$"); - - -#include "global.h" -#include "crosshair.h" -#include "data.h" -#include "error.h" -#include "file.h" -#include "mymem.h" -#include "misc.h" -#include "strflags.h" -#include "parse_l.h" -#include "parse_y.h" -#include "create.h" -#include "plug_footprint.h" - -#define YY_NO_INPUT - -/* --------------------------------------------------------------------------- - * some shared parser identifiers - */ -#ifdef FLEX_SCANNER - -#define yyunput ATTRIBUTE_UNUSED yyunput -#endif - -char *yyfilename; /* in this file */ -PCBTypePtr yyPCB; /* used by parser */ -DataTypePtr yyData; -ElementTypePtr yyElement; -FontTypePtr yyFont; - -static int parse_number (void); - -/* --------------------------------------------------------------------------- - * an external prototypes - */ -int yyparse(void); - -/* --------------------------------------------------------------------------- - * some local prototypes - */ -static int Parse(FILE *, char *, char *, char *, char *); - -#line 713 "lex.yy.c" - -#define INITIAL 0 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -static int yy_init_globals (void ); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy (void ); - -int yyget_debug (void ); - -void yyset_debug (int debug_flag ); - -YY_EXTRA_TYPE yyget_extra (void ); - -void yyset_extra (YY_EXTRA_TYPE user_defined ); - -FILE *yyget_in (void ); - -void yyset_in (FILE * in_str ); - -FILE *yyget_out (void ); - -void yyset_out (FILE * out_str ); - -int yyget_leng (void ); - -char *yyget_text (void ); - -int yyget_lineno (void ); - -void yyset_lineno (int line_number ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap (void ); -#else -extern int yywrap (void ); -#endif -#endif - - static void yyunput (int c,char *buf_ptr ); - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); -#endif - -#ifndef YY_NO_INPUT - -#ifdef __cplusplus -static int yyinput (void ); -#else -static int input (void ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - size_t n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (void); - -#define YY_DECL int yylex (void) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 104 "parse_l.l" - - -#line 903 "lex.yy.c" - - if ( !(yy_init) ) - { - (yy_init) = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); - } - - yy_load_buffer_state( ); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = (yy_c_buf_p); - - /* Support of yytext. */ - *yy_cp = (yy_hold_char); - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = (yy_start); -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 222 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 257 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - - if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) - { - int yyl; - for ( yyl = 0; yyl < yyleng; ++yyl ) - if ( yytext[yyl] == '\n' ) - - yylineno++; -; - } - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = (yy_hold_char); - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 106 "parse_l.l" -{ return(T_FILEVERSION); } - YY_BREAK -case 2: -YY_RULE_SETUP -#line 107 "parse_l.l" -{ return(T_PCB); } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 108 "parse_l.l" -{ return(T_GRID); } - YY_BREAK -case 4: -YY_RULE_SETUP -#line 109 "parse_l.l" -{ return(T_CURSOR); } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 110 "parse_l.l" -{ return(T_THERMAL); } - YY_BREAK -case 6: -YY_RULE_SETUP -#line 111 "parse_l.l" -{ return(T_AREA); } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 112 "parse_l.l" -{ return(T_DRC); } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 113 "parse_l.l" -{ return(T_FLAGS); } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 114 "parse_l.l" -{ return(T_LAYER); } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 115 "parse_l.l" -{ return(T_PIN); } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 116 "parse_l.l" -{ return(T_PAD); } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 117 "parse_l.l" -{ return(T_VIA); } - YY_BREAK -case 13: -YY_RULE_SETUP -#line 118 "parse_l.l" -{ return(T_LINE); } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 119 "parse_l.l" -{ return(T_RAT); } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 120 "parse_l.l" -{ return(T_RECTANGLE); } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 121 "parse_l.l" -{ return(T_TEXT); } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 122 "parse_l.l" -{ return(T_ELEMENTLINE); } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 123 "parse_l.l" -{ return(T_ELEMENTARC); } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 124 "parse_l.l" -{ return(T_ELEMENT); } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 125 "parse_l.l" -{ return(T_SYMBOLLINE); } - YY_BREAK -case 21: -YY_RULE_SETUP -#line 126 "parse_l.l" -{ return(T_SYMBOL); } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 127 "parse_l.l" -{ return(T_MARK); } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 128 "parse_l.l" -{ return(T_GROUPS); } - YY_BREAK -case 24: -YY_RULE_SETUP -#line 129 "parse_l.l" -{ return(T_STYLES); } - YY_BREAK -case 25: -YY_RULE_SETUP -#line 130 "parse_l.l" -{ return(T_POLYGON); } - YY_BREAK -case 26: -YY_RULE_SETUP -#line 131 "parse_l.l" -{ return(T_POLYGON_HOLE); } - YY_BREAK -case 27: -YY_RULE_SETUP -#line 132 "parse_l.l" -{ return(T_ARC); } - YY_BREAK -case 28: -YY_RULE_SETUP -#line 133 "parse_l.l" -{ return(T_NETLIST); } - YY_BREAK -case 29: -YY_RULE_SETUP -#line 134 "parse_l.l" -{ return(T_NET); } - YY_BREAK -case 30: -YY_RULE_SETUP -#line 135 "parse_l.l" -{ return(T_CONN); } - YY_BREAK -case 31: -YY_RULE_SETUP -#line 136 "parse_l.l" -{ return(T_NETLISTPATCH); } - YY_BREAK -case 32: -YY_RULE_SETUP -#line 137 "parse_l.l" -{ return(T_ADD_CONN); } - YY_BREAK -case 33: -YY_RULE_SETUP -#line 138 "parse_l.l" -{ return(T_DEL_CONN); } - YY_BREAK -case 34: -YY_RULE_SETUP -#line 139 "parse_l.l" -{ return(T_CHANGE_ATTRIB); } - YY_BREAK -case 35: -YY_RULE_SETUP -#line 140 "parse_l.l" -{ return(T_ATTRIBUTE); } - YY_BREAK -case 36: -YY_RULE_SETUP -#line 142 "parse_l.l" -{ return T_NM; } - YY_BREAK -case 37: -YY_RULE_SETUP -#line 143 "parse_l.l" -{ return T_UM; } - YY_BREAK -case 38: -YY_RULE_SETUP -#line 144 "parse_l.l" -{ return T_MM; } - YY_BREAK -case 39: -YY_RULE_SETUP -#line 145 "parse_l.l" -{ return T_M; } - YY_BREAK -case 40: -YY_RULE_SETUP -#line 146 "parse_l.l" -{ return T_KM; } - YY_BREAK -case 41: -YY_RULE_SETUP -#line 147 "parse_l.l" -{ return T_UMIL; } - YY_BREAK -case 42: -YY_RULE_SETUP -#line 148 "parse_l.l" -{ return T_CMIL; } - YY_BREAK -case 43: -YY_RULE_SETUP -#line 149 "parse_l.l" -{ return T_MIL; } - YY_BREAK -case 44: -YY_RULE_SETUP -#line 150 "parse_l.l" -{ return T_IN; } - YY_BREAK -case 45: -YY_RULE_SETUP -#line 152 "parse_l.l" -{ - yylval.integer = (unsigned) *(yytext+1); - return(CHAR_CONST); - } - YY_BREAK -case 46: -YY_RULE_SETUP -#line 156 "parse_l.l" -{ return parse_number(); } - YY_BREAK -case 47: -YY_RULE_SETUP -#line 157 "parse_l.l" -{ yylval.integer = round (strtod (yytext, NULL)); return INTEGER; } - YY_BREAK -case 48: -YY_RULE_SETUP -#line 159 "parse_l.l" -{ unsigned n; - sscanf((char *) yytext, "%x", &n); - yylval.integer = n; - return INTEGER; - } - YY_BREAK -case 49: -YY_RULE_SETUP -#line 164 "parse_l.l" -{ - char *p1, *p2; - - /* return NULL on empty string */ - if (yyleng == 2) - { - yylval.string = NULL; - return(STRING); - } - - /* allocate memory and copy string; - * stringlength is counted and copied without - * leading and trailing '"' - */ - yyleng -= 2; - yylval.string = (char *)calloc (yyleng+1, sizeof (char)); - p1 = (char *) (yytext +1); - p2 = yylval.string; - while(yyleng--) - { - /* check for special character */ - if (*p1 == '\\') - { - yyleng--; - p1++; - - } - *p2++ = *p1++; - } - *p2 = '\0'; - return(STRING); - } - YY_BREAK -case 50: -YY_RULE_SETUP -#line 196 "parse_l.l" -{} - YY_BREAK -case 51: -YY_RULE_SETUP -#line 197 "parse_l.l" -{} - YY_BREAK -case 52: -/* rule 52 can match eol */ -YY_RULE_SETUP -#line 198 "parse_l.l" -{ -#ifndef FLEX_SCANNER - yylineno++; -#endif - } - YY_BREAK -case 53: -YY_RULE_SETUP -#line 203 "parse_l.l" -{} - YY_BREAK -case 54: -YY_RULE_SETUP -#line 204 "parse_l.l" -{ return(*yytext); } - YY_BREAK -case 55: -YY_RULE_SETUP -#line 206 "parse_l.l" -ECHO; - YY_BREAK -#line 1314 "lex.yy.c" -case YY_STATE_EOF(INITIAL): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = (yy_c_buf_p); - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_END_OF_FILE: - { - (yy_did_buffer_switch_on_eof) = 0; - - if ( yywrap( ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = - (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (void) -{ - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; - int ret_val; - - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER; - - int yy_c_buf_p_offset = - (int) ((yy_c_buf_p) - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), (size_t) num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - if ( (yy_n_chars) == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (void) -{ - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = (yy_start); - - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 222 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) -{ - register int yy_is_jam; - register char *yy_cp = (yy_c_buf_p); - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 222 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 221); - - return yy_is_jam ? 0 : yy_current_state; -} - - static void yyunput (int c, register char * yy_bp ) -{ - register char *yy_cp; - - yy_cp = (yy_c_buf_p); - - /* undo effects of setting up yytext */ - *yy_cp = (yy_hold_char); - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = (yy_n_chars) + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - if ( c == '\n' ){ - --yylineno; - } - - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; -} - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (void) -#else - static int input (void) -#endif - -{ - int c; - - *(yy_c_buf_p) = (yy_hold_char); - - if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; - - else - { /* need more input */ - int offset = (yy_c_buf_p) - (yytext_ptr); - ++(yy_c_buf_p); - - switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart(yyin ); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( ) ) - return EOF; - - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; - break; - } - } - } - - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve yytext */ - (yy_hold_char) = *++(yy_c_buf_p); - - if ( c == '\n' ) - - yylineno++; -; - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyrestart (FILE * input_file ) -{ - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); - } - - yy_init_buffer(YY_CURRENT_BUFFER,input_file ); - yy_load_buffer_state( ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * - */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) -{ - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - (yy_did_buffer_switch_on_eof) = 1; -} - -static void yy_load_buffer_state (void) -{ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer(b,file ); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * - */ - void yy_delete_buffer (YY_BUFFER_STATE b ) -{ - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree((void *) b->yy_ch_buf ); - - yyfree((void *) b ); -} - -#ifndef __cplusplus -extern int isatty (int ); -#endif /* __cplusplus */ - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) - -{ - int oerrno = errno; - - yy_flush_buffer(b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * - */ - void yy_flush_buffer (YY_BUFFER_STATE b ) -{ - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * - */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) -{ - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * - */ -void yypop_buffer_state (void) -{ - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (void) -{ - int num_to_alloc; - - if (!(yy_buffer_stack)) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; - } - - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc - ((yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer(b ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) -{ - - return yy_scan_bytes(yystr,strlen(yystr) ); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) yyalloc(n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer(buf,n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error (yyconst char* msg ) -{ - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = (yy_hold_char); \ - (yy_c_buf_p) = yytext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the current line number. - * - */ -int yyget_lineno (void) -{ - - return yylineno; -} - -/** Get the input stream. - * - */ -FILE *yyget_in (void) -{ - return yyin; -} - -/** Get the output stream. - * - */ -FILE *yyget_out (void) -{ - return yyout; -} - -/** Get the length of the current token. - * - */ -int yyget_leng (void) -{ - return yyleng; -} - -/** Get the current token. - * - */ - -char *yyget_text (void) -{ - return yytext; -} - -/** Set the current line number. - * @param line_number - * - */ -void yyset_lineno (int line_number ) -{ - - yylineno = line_number; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * in_str ) -{ - yyin = in_str ; -} - -void yyset_out (FILE * out_str ) -{ - yyout = out_str ; -} - -int yyget_debug (void) -{ - return yy_flex_debug; -} - -void yyset_debug (int bdebug ) -{ - yy_flex_debug = bdebug ; -} - -static int yy_init_globals (void) -{ - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - /* We do not touch yylineno unless the option is enabled. */ - yylineno = 1; - - (yy_buffer_stack) = 0; - (yy_buffer_stack_top) = 0; - (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; - (yy_init) = 0; - (yy_start) = 0; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = (FILE *) 0; - yyout = (FILE *) 0; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (void) -{ - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(); - } - - /* Destroy the stack itself. */ - yyfree((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( ); - - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) -{ - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size ) -{ - return (void *) malloc( size ); -} - -void *yyrealloc (void * ptr, yy_size_t size ) -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} - -void yyfree (void * ptr ) -{ - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 206 "parse_l.l" - - - -/* --------------------------------------------------------------------------- - * sets up the preprocessor command - */ -static int Parse(FILE *Pipe, char *Executable, char *Path, char *Filename, char *Parameter) -{ - static char *command = NULL; - int returncode; - int used_popen = 0; - char *tmps; - size_t l; -#ifdef FLEX_SCANNER - static bool firsttime = true; -#endif - - if (Pipe == NULL) { - if (EMPTY_STRING_P (Executable)) - { - l = 2; - if ( Path != NULL ) - l += strlen (Path); - - l += strlen (Filename); - - if ( (tmps = (char *) malloc ( l * sizeof (char))) == NULL) - { - fprintf (stderr, "Parse(): malloc failed\n"); - exit (1); - } - - if ( Path != NULL && *Path != '\0') - sprintf (tmps, "%s%s%s", Path, PCB_DIR_SEPARATOR_S, Filename); - else - sprintf (tmps, "%s", Filename); - - yyin = fopen (tmps, "r"); -printf("OPENING: %s -> %p\n", tmps, yyin); - if (!yyin) - { - /* Special case this one, we get it all the time... */ - if (strcmp (tmps, "./default_font")) - Message("Can't open %s for reading\n", tmps); - return(1); - } - free (tmps); - } - else - { - used_popen = 1; - - command = EvaluateFilename(Executable, Path, Filename, Parameter); - - /* open pipe to stdout of command */ - if (*command == '\0' || (yyin = popen(command, "r")) == NULL) - { - PopenErrorMessage(command); - free(command); - return(1); - } - free(command); - } - } - else { - yyin = Pipe; - } - -#ifdef FLEX_SCANNER - /* reset parser if not called the first time */ - if (!firsttime) - yyrestart(yyin); - firsttime = false; -#endif - - /* init linenumber and filename for yyerror() */ - yylineno = 1; - yyfilename = Filename; - - /* We need to save the data temporarily because lex-yacc are able - * to break the application if the input file has an illegal format. - * It's not necessary if the system supports the call of functions - * on termination. - */ - - CreateBeLenient (true); - -#if !defined(HAS_ATEXIT) && !defined(HAS_ON_EXIT) - if (PCB && PCB->Data) - SaveTMPData(); - returncode = yyparse(); - RemoveTMPData(); -#else - returncode = yyparse(); -#endif - /* clean up parse buffer */ - yy_delete_buffer(YY_CURRENT_BUFFER); - - CreateBeLenient (false); - - if (Pipe != NULL) - return returncode; - - if (used_popen) - return(pclose(yyin) ? 1 : returncode); - return(fclose(yyin) ? 1 : returncode); -} - -/* --------------------------------------------------------------------------- - * initializes LEX and calls parser for a single element file - */ -int ParseElement(DataTypePtr Ptr, const char *name) -{ - FILE *f; - int ret; - fp_fopen_ctx_t st; - - yyPCB = NULL; - yyData = Ptr; - yyFont = &PCB->Font; - yyElement = NULL; - - f = fp_fopen(conf_core.rc.library_search_paths, name, &st); - - if (f == NULL) - return -1; - - ret = Parse(f, NULL,NULL,NULL,NULL); - - fp_fclose(f, &st); - - return(ret); -} - -/* --------------------------------------------------------------------------- - * initializes LEX and calls parser for a complete board - */ -int ParsePCB(PCBTypePtr Ptr, char *Filename) -{ - int retval; - yyPCB = Ptr; - yyData = NULL; - yyFont = NULL; - yyElement = NULL; - setlocale(LC_ALL, "C"); /* make sure numerics are read predictably */ - retval = Parse(NULL, conf_core.rc.file_command, conf_core.rc.file_path, Filename, NULL); - setlocale(LC_ALL, ""); - return retval; -} - -/* --------------------------------------------------------------------------- - * initializes LEX and calls parser for a font - */ -int ParseFont(FontTypePtr Ptr, char *Filename) -{ - int r = 0; - char *path, *p; - yyPCB = NULL; - yyFont = Ptr; - yyElement = NULL; - - r = Parse(NULL, conf_core.rc.font_command, NULL, Filename, NULL); - if (r == 0) { -#ifdef DEBUG - Message ("Found %s in %s\n", Filename, p); -#endif - } - return r; -} - -static int -parse_number () -{ - yylval.number = strtod ((char *) yytext, NULL); - return FLOATING; -} - - Index: trunk/src/parse_l.l =================================================================== --- trunk/src/parse_l.l (revision 1760) +++ trunk/src/parse_l.l (nonexistent) @@ -1,381 +0,0 @@ -/* $Id$ */ - -%{ -/* - * COPYRIGHT - * - * PCB, interactive printed circuit board design - * Copyright (C) 1994,1995,1996,2006 Thomas Nau - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Contact addresses for paper mail and Email: - * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany - * Thomas.Nau@rz.uni-ulm.de - * - */ - -/* lexical definitions to parse ASCII input of PCB and Element description - */ - -#include "config.h" -#include "conf_core.h" - -#include -#include -#include -#include - -#if defined(_POSIX_SOURCE) || defined(_HPUX_SOURCE) -#include -#endif - -#include "global.h" - -#ifdef HAVE_LIBDMALLOC -# include /* see http://dmalloc.com */ -#endif - -RCSID("$Id$"); - - -#include "global.h" -#include "crosshair.h" -#include "data.h" -#include "error.h" -#include "file.h" -#include "mymem.h" -#include "misc.h" -#include "strflags.h" -#include "parse_l.h" -#include "parse_y.h" -#include "create.h" -#include "plug_footprint.h" - -#define YY_NO_INPUT - -/* --------------------------------------------------------------------------- - * some shared parser identifiers - */ -#ifdef FLEX_SCANNER - -#define yyunput ATTRIBUTE_UNUSED yyunput -#endif - -char *yyfilename; /* in this file */ -PCBTypePtr yyPCB; /* used by parser */ -DataTypePtr yyData; -ElementTypePtr yyElement; -FontTypePtr yyFont; - -static int parse_number (void); - -/* --------------------------------------------------------------------------- - * an external prototypes - */ -int yyparse(void); - -/* --------------------------------------------------------------------------- - * some local prototypes - */ -static int Parse(FILE *, char *, char *, char *, char *); - -%} - -HEX 0x[0-9a-fA-F]+ -INTEGER [+-]?([1-9][0-9]*|0) -FLOATING {INTEGER}"."[0-9]* -STRINGCHAR ([^"\n\r\\]|\\.) - -%option yylineno - -%% - -FileVersion { return(T_FILEVERSION); } -PCB { return(T_PCB); } -Grid { return(T_GRID); } -Cursor { return(T_CURSOR); } -Thermal { return(T_THERMAL); } -PolyArea { return(T_AREA); } -DRC { return(T_DRC); } -Flags { return(T_FLAGS); } -Layer { return(T_LAYER); } -Pin { return(T_PIN); } -Pad { return(T_PAD); } -Via { return(T_VIA); } -Line { return(T_LINE); } -Rat { return(T_RAT); } -Rectangle { return(T_RECTANGLE); } -Text { return(T_TEXT); } -ElementLine { return(T_ELEMENTLINE); } -ElementArc { return(T_ELEMENTARC); } -Element { return(T_ELEMENT); } -SymbolLine { return(T_SYMBOLLINE); } -Symbol { return(T_SYMBOL); } -Mark { return(T_MARK); } -Groups { return(T_GROUPS); } -Styles { return(T_STYLES); } -Polygon { return(T_POLYGON); } -Hole { return(T_POLYGON_HOLE); } -Arc { return(T_ARC); } -NetList { return(T_NETLIST); } -Net { return(T_NET); } -Connect { return(T_CONN); } -NetListPatch { return(T_NETLISTPATCH); } -add_conn { return(T_ADD_CONN); } -del_conn { return(T_DEL_CONN); } -change_attrib { return(T_CHANGE_ATTRIB); } -Attribute { return(T_ATTRIBUTE); } - -nm { return T_NM; } -um { return T_UM; } -mm { return T_MM; } -m { return T_M; } -km { return T_KM; } -umil { return T_UMIL; } -cmil { return T_CMIL; } -mil { return T_MIL; } -in { return T_IN; } - -\'.\' { - yylval.integer = (unsigned) *(yytext+1); - return(CHAR_CONST); - } -{FLOATING} { return parse_number(); } -{INTEGER} { yylval.integer = round (strtod (yytext, NULL)); return INTEGER; } - -{HEX} { unsigned n; - sscanf((char *) yytext, "%x", &n); - yylval.integer = n; - return INTEGER; - } -\"{STRINGCHAR}*\" { - char *p1, *p2; - - /* return NULL on empty string */ - if (yyleng == 2) - { - yylval.string = NULL; - return(STRING); - } - - /* allocate memory and copy string; - * stringlength is counted and copied without - * leading and trailing '"' - */ - yyleng -= 2; - yylval.string = (char *)calloc (yyleng+1, sizeof (char)); - p1 = (char *) (yytext +1); - p2 = yylval.string; - while(yyleng--) - { - /* check for special character */ - if (*p1 == '\\') - { - yyleng--; - p1++; - - } - *p2++ = *p1++; - } - *p2 = '\0'; - return(STRING); - } -#.* {} -[ \t]+ {} -[\n] { -#ifndef FLEX_SCANNER - yylineno++; -#endif - } -[\r] {} -. { return(*yytext); } - -%% - -/* --------------------------------------------------------------------------- - * sets up the preprocessor command - */ -static int Parse(FILE *Pipe, char *Executable, char *Path, char *Filename, char *Parameter) -{ - static char *command = NULL; - int returncode; - int used_popen = 0; - char *tmps; - size_t l; -#ifdef FLEX_SCANNER - static bool firsttime = true; -#endif - - if (Pipe == NULL) { - if (EMPTY_STRING_P (Executable)) - { - l = 2; - if ( Path != NULL ) - l += strlen (Path); - - l += strlen (Filename); - - if ( (tmps = (char *) malloc ( l * sizeof (char))) == NULL) - { - fprintf (stderr, "Parse(): malloc failed\n"); - exit (1); - } - - if ( Path != NULL && *Path != '\0') - sprintf (tmps, "%s%s%s", Path, PCB_DIR_SEPARATOR_S, Filename); - else - sprintf (tmps, "%s", Filename); - - yyin = fopen (tmps, "r"); -printf("OPENING: %s -> %p\n", tmps, yyin); - if (!yyin) - { - /* Special case this one, we get it all the time... */ - if (strcmp (tmps, "./default_font")) - Message("Can't open %s for reading\n", tmps); - return(1); - } - free (tmps); - } - else - { - used_popen = 1; - - command = EvaluateFilename(Executable, Path, Filename, Parameter); - - /* open pipe to stdout of command */ - if (*command == '\0' || (yyin = popen(command, "r")) == NULL) - { - PopenErrorMessage(command); - free(command); - return(1); - } - free(command); - } - } - else { - yyin = Pipe; - } - -#ifdef FLEX_SCANNER - /* reset parser if not called the first time */ - if (!firsttime) - yyrestart(yyin); - firsttime = false; -#endif - - /* init linenumber and filename for yyerror() */ - yylineno = 1; - yyfilename = Filename; - - /* We need to save the data temporarily because lex-yacc are able - * to break the application if the input file has an illegal format. - * It's not necessary if the system supports the call of functions - * on termination. - */ - - CreateBeLenient (true); - -#if !defined(HAS_ATEXIT) && !defined(HAS_ON_EXIT) - if (PCB && PCB->Data) - SaveTMPData(); - returncode = yyparse(); - RemoveTMPData(); -#else - returncode = yyparse(); -#endif - /* clean up parse buffer */ - yy_delete_buffer(YY_CURRENT_BUFFER); - - CreateBeLenient (false); - - if (Pipe != NULL) - return returncode; - - if (used_popen) - return(pclose(yyin) ? 1 : returncode); - return(fclose(yyin) ? 1 : returncode); -} - -/* --------------------------------------------------------------------------- - * initializes LEX and calls parser for a single element file - */ -int ParseElement(DataTypePtr Ptr, const char *name) -{ - FILE *f; - int ret; - fp_fopen_ctx_t st; - - yyPCB = NULL; - yyData = Ptr; - yyFont = &PCB->Font; - yyElement = NULL; - - f = fp_fopen(conf_core.rc.library_search_paths, name, &st); - - if (f == NULL) - return -1; - - ret = Parse(f, NULL,NULL,NULL,NULL); - - fp_fclose(f, &st); - - return(ret); -} - -/* --------------------------------------------------------------------------- - * initializes LEX and calls parser for a complete board - */ -int ParsePCB(PCBTypePtr Ptr, char *Filename) -{ - int retval; - yyPCB = Ptr; - yyData = NULL; - yyFont = NULL; - yyElement = NULL; - setlocale(LC_ALL, "C"); /* make sure numerics are read predictably */ - retval = Parse(NULL, conf_core.rc.file_command, conf_core.rc.file_path, Filename, NULL); - setlocale(LC_ALL, ""); - return retval; -} - -/* --------------------------------------------------------------------------- - * initializes LEX and calls parser for a font - */ -int ParseFont(FontTypePtr Ptr, char *Filename) -{ - int r = 0; - char *path, *p; - yyPCB = NULL; - yyFont = Ptr; - yyElement = NULL; - - r = Parse(NULL, conf_core.rc.font_command, NULL, Filename, NULL); - if (r == 0) { -#ifdef DEBUG - Message ("Found %s in %s\n", Filename, p); -#endif - } - return r; -} - -static int -parse_number () -{ - yylval.number = strtod ((char *) yytext, NULL); - return FLOATING; -} - Index: trunk/src/file.c =================================================================== --- trunk/src/file.c (revision 1760) +++ trunk/src/file.c (nonexistent) @@ -1,1209 +0,0 @@ -/* $Id$ */ - -/* - * COPYRIGHT - * - * PCB, interactive printed circuit board design - * Copyright (C) 1994,1995,1996,1997,1998,2005,2006 Thomas Nau - * Copyright (C) 2015 Tibor 'Igor2' Palinkas - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Contact addresses for paper mail and Email: - * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany - * Thomas.Nau@rz.uni-ulm.de - * - */ - -/* file save, load, merge ... routines - * getpid() needs a cast to (int) to get rid of compiler warnings - * on several architectures - */ - -#include "config.h" -#include "conf_core.h" - -#include - -#ifdef HAVE_SYS_PARAM_H -#include -#endif - -#include "global.h" - -#include -#ifdef HAVE_PWD_H -#include -#endif -#include - -#ifdef HAVE_SYS_SOCKET_H -#include -#endif - -#include - -#ifdef HAVE_NETINET_IN_H -#include -#endif - -#ifdef HAVE_NETDB_H -#include -#endif - -#include - -#ifdef HAVE_STDLIB_H -#include -#endif - -#ifdef HAVE_STRING_H -#include -#endif - -#ifdef HAVE_UNISTD_H -#include -#endif - - -#include "buffer.h" -#include "change.h" -#include "create.h" -#include "crosshair.h" -#include "data.h" -#include "error.h" -#include "file.h" -#include "hid.h" -#include "misc.h" -#include "move.h" -#include "mymem.h" -#include "parse_l.h" -#include "pcb-printf.h" -#include "polygon.h" -#include "rats.h" -#include "remove.h" -#include "set.h" -#include "strflags.h" -#include "compat_fs.h" -#include "paths.h" -#include "rats_patch.h" -#include "stub_edif.h" -#include "hid_actions.h" -#include "hid_flags.h" - -RCSID("$Id$"); - -#if !defined(HAS_ATEXIT) && !defined(HAS_ON_EXIT) -/* --------------------------------------------------------------------------- - * some local identifiers for OS without an atexit() or on_exit() - * call - */ -static char TMPFilename[80]; -#endif - -/* --------------------------------------------------------------------------- - * some local prototypes - */ -static void WritePCBInfoHeader(FILE *); -static void WritePCBDataHeader(FILE *); -static void WritePCBFontData(FILE *); -static void WriteViaData(FILE *, DataTypePtr); -static void WritePCBRatData(FILE *); -static void WriteElementData(FILE *, DataTypePtr); -static void WriteLayerData(FILE *, Cardinal, LayerTypePtr); -static int WritePCB(FILE *); -static int WritePCBFile(char *); -static int WritePipe(char *, bool); - -/* --------------------------------------------------------------------------- - * Flag helper functions - */ - -#define F2S(OBJ, TYPE) flags_to_string ((OBJ)->Flags, TYPE) - -/* --------------------------------------------------------------------------- */ - -/* The idea here is to avoid gratuitously breaking backwards - compatibility due to a new but rarely used feature. The first such - case, for example, was the polygon Hole - if your design included - polygon holes, you needed a newer PCB to read it, but if your - design didn't include holes, PCB would produce a file that older - PCBs could read, if only it had the correct version number in it. - - If, however, you have to add or change a feature that really does - require a new PCB version all the time, it's time to remove all the - tests below and just always output the new version. - - Note: Best practices here is to add support for a feature *first* - (and bump PCB_FILE_VERSION in file.h), and note the version that - added that support below, and *later* update the file format to - need that version (which may then be older than PCB_FILE_VERSION). - Hopefully, that allows for one release between adding support and - needing it, which should minimize breakage. Of course, that's not - *always* possible, practical, or desirable. - -*/ - -/* Hole[] in Polygon. */ -#define PCB_FILE_VERSION_HOLES 20100606 -/* First version ever saved. */ -#define PCB_FILE_VERSION_BASELINE 20070407 - -int PCBFileVersionNeeded(void) -{ - ALLPOLYGON_LOOP(PCB->Data); - { - if (polygon->HoleIndexN > 0) - return PCB_FILE_VERSION_HOLES; - } - ENDALL_LOOP; - - return PCB_FILE_VERSION_BASELINE; -} - -/* --------------------------------------------------------------------------- */ - -static int string_cmp(const char *a, const char *b) -{ - while (*a && *b) { - if (isdigit((int) *a) && isdigit((int) *b)) { - int ia = atoi(a); - int ib = atoi(b); - if (ia != ib) - return ia - ib; - while (isdigit((int) *a) && *(a + 1)) - a++; - while (isdigit((int) *b) && *(b + 1)) - b++; - } - else if (tolower((int) *a) != tolower((int) *b)) - return tolower((int) *a) - tolower((int) *b); - a++; - b++; - } - if (*a) - return 1; - if (*b) - return -1; - return 0; -} - -static int netlist_sort_offset = 0; - -static int netlist_sort(const void *va, const void *vb) -{ - LibraryMenuType *am = (LibraryMenuType *) va; - LibraryMenuType *bm = (LibraryMenuType *) vb; - char *a = am->Name; - char *b = bm->Name; - if (*a == '~') - a++; - if (*b == '~') - b++; - return string_cmp(a, b); -} - -static int netnode_sort(const void *va, const void *vb) -{ - LibraryEntryType *am = (LibraryEntryType *) va; - LibraryEntryType *bm = (LibraryEntryType *) vb; - char *a = am->ListEntry; - char *b = bm->ListEntry; - return string_cmp(a, b); -} - -void sort_library(LibraryTypePtr lib) -{ - int i; - qsort(lib->Menu, lib->MenuN, sizeof(lib->Menu[0]), netlist_sort); - for (i = 0; i < lib->MenuN; i++) - qsort(lib->Menu[i].Entry, lib->Menu[i].EntryN, sizeof(lib->Menu[i].Entry[0]), netnode_sort); -} - -void sort_netlist() -{ - netlist_sort_offset = 2; - sort_library(&(PCB->NetlistLib[NETLIST_INPUT])); - netlist_sort_offset = 0; -} - -/* --------------------------------------------------------------------------- - * opens a file and check if it exists - */ -FILE *CheckAndOpenFile(char *Filename, bool Confirm, bool AllButton, bool * WasAllButton, bool * WasCancelButton) -{ - FILE *fp = NULL; - struct stat buffer; - char message[MAXPATHLEN + 80]; - int response; - - if (Filename && *Filename) { - if (!stat(Filename, &buffer) && Confirm) { - sprintf(message, _("File '%s' exists, use anyway?"), Filename); - if (WasAllButton) - *WasAllButton = false; - if (WasCancelButton) - *WasCancelButton = false; - if (AllButton) - response = gui->confirm_dialog(message, "Cancel", "Ok", AllButton ? "Sequence OK" : 0); - else - response = gui->confirm_dialog(message, "Cancel", "Ok", "Sequence OK"); - - switch (response) { - case 2: - if (WasAllButton) - *WasAllButton = true; - break; - case 0: - if (WasCancelButton) - *WasCancelButton = true; - } - } - if ((fp = fopen(Filename, "w")) == NULL) - OpenErrorMessage(Filename); - } - return (fp); -} - -/* --------------------------------------------------------------------------- - * opens a file for saving connection data - */ -FILE *OpenConnectionDataFile(void) -{ - char *fname; - FILE *fp; - static char *default_file = NULL; - bool result; /* not used */ - - /* CheckAndOpenFile deals with the case where fname already exists */ - fname = gui->fileselect(_("Save Connection Data As ..."), - _("Choose a file to save all connection data to."), default_file, ".net", "connection_data", 0); - if (fname == NULL) - return NULL; - - if (default_file != NULL) { - free(default_file); - default_file = NULL; - } - - if (fname && *fname) - default_file = strdup(fname); - - fp = CheckAndOpenFile(fname, true, false, &result, NULL); - free(fname); - - return fp; -} - -/* --------------------------------------------------------------------------- - * save elements in the current buffer - */ -int SaveBufferElements(char *Filename) -{ - int result; - - if (SWAP_IDENT) - SwapBuffers(); - result = WritePipe(Filename, false); - if (SWAP_IDENT) - SwapBuffers(); - return (result); -} - -/* --------------------------------------------------------------------------- - * save PCB - */ -int SavePCB(char *file) -{ - int retcode; - - if (gui->notify_save_pcb == NULL) - return WritePipe(file, true); - - gui->notify_save_pcb(file, false); - retcode = WritePipe(file, true); - gui->notify_save_pcb(file, true); - - return retcode; -} - -/* --------------------------------------------------------------------------- - * set the route style to the first one, if the current one doesn't - * happen to match any. This way, "revert" won't change the route - * style. - */ -static void set_some_route_style() -{ - if (hid_get_flag("style")) - return; - SetLineSize(PCB->RouteStyle[0].Thick); - SetViaSize(PCB->RouteStyle[0].Diameter, true); - SetViaDrillingHole(PCB->RouteStyle[0].Hole, true); - SetKeepawayWidth(PCB->RouteStyle[0].Keepaway); -} - -/* --------------------------------------------------------------------------- - * load PCB - * parse the file with enabled 'PCB mode' (see parser) - * if successful, update some other stuff - * - * If revert is true, we pass "revert" as a parameter - * to the HID's PCBChanged action. - */ -static int real_load_pcb(char *Filename, bool revert, bool require_font, bool is_misc) -{ - const char *unit_suffix; - char *new_filename; - PCBTypePtr newPCB = CreateNewPCB_(false); - PCBTypePtr oldPCB; -#ifdef DEBUG - double elapsed; - clock_t start, end; - - start = clock(); -#endif - - resolve_path(Filename, &new_filename, 0); - - oldPCB = PCB; - PCB = newPCB; - - /* mark the default font invalid to know if the file has one */ - newPCB->Font.Valid = false; - - /* new data isn't added to the undo list */ - if (!ParsePCB(PCB, new_filename)) { - RemovePCB(oldPCB); - - CreateNewPCBPost(PCB, 0); - ResetStackAndVisibility(); - - if (!is_misc) { - /* update cursor location */ - Crosshair.X = PCB_CLAMP(PCB->CursorX, 0, PCB->MaxWidth); - Crosshair.Y = PCB_CLAMP(PCB->CursorY, 0, PCB->MaxHeight); - - /* update cursor confinement and output area (scrollbars) */ - ChangePCBSize(PCB->MaxWidth, PCB->MaxHeight); - } - - /* enable default font if necessary */ - if (!PCB->Font.Valid) { - if (require_font) - Message(_("File '%s' has no font information, using default font\n"), new_filename); - PCB->Font.Valid = true; - } - - /* clear 'changed flag' */ - SetChangedFlag(false); - PCB->Filename = new_filename; - /* just in case a bad file saved file is loaded */ - - /* Use attribute PCB::grid::unit as unit, if we can */ - unit_suffix = AttributeGet(PCB, "PCB::grid::unit"); - if (unit_suffix && *unit_suffix) { - const Unit *new_unit = get_unit_struct(unit_suffix); -#warning TODO: we MUST NOT overwrite this here; should be handled by pcb-local settings - if (new_unit) - conf_core.editor.grid_unit = new_unit; - } - AttributePut(PCB, "PCB::grid::unit", conf_core.editor.grid_unit->suffix); - - sort_netlist(); - rats_patch_make_edited(PCB); - - set_some_route_style(); - - if (!is_misc) { - if (revert) - hid_actionl("PCBChanged", "revert", NULL); - else - hid_action("PCBChanged"); - } - -#ifdef DEBUG - end = clock(); - elapsed = ((double) (end - start)) / CLOCKS_PER_SEC; - gui->log("Loading file %s took %f seconds of CPU time\n", new_filename, elapsed); -#endif - - return (0); - } - PCB = oldPCB; - hid_action("PCBChanged"); - - /* release unused memory */ - RemovePCB(newPCB); - return (1); -} - -/* --------------------------------------------------------------------------- - * Load PCB - */ -int LoadPCB(char *file, bool require_font, bool is_misc) -{ - return real_load_pcb(file, false, require_font, is_misc); -} - -/* --------------------------------------------------------------------------- - * Revert PCB - */ -int RevertPCB(void) -{ - return real_load_pcb(PCB->Filename, true, true, true); -} - -/* --------------------------------------------------------------------------- - * functions for loading elements-as-pcb - */ - -extern PCBTypePtr yyPCB; -extern DataTypePtr yyData; -extern FontTypePtr yyFont; - -void PreLoadElementPCB() -{ - - if (!yyPCB) - return; - - yyFont = &yyPCB->Font; - yyData = yyPCB->Data; - yyData->pcb = yyPCB; - yyData->LayerN = 0; -} - -void PostLoadElementPCB() -{ - PCBTypePtr pcb_save = PCB; - ElementTypePtr e; - - if (!yyPCB) - return; - - CreateNewPCBPost(yyPCB, 0); - ParseGroupString("1,c:2,s", &yyPCB->LayerGroups, yyData->LayerN); - e = elementlist_first(&yyPCB->Data->Element); /* we know there's only one */ - PCB = yyPCB; - MoveElementLowLevel(yyPCB->Data, e, -e->BoundingBox.X1, -e->BoundingBox.Y1); - PCB = pcb_save; - yyPCB->MaxWidth = e->BoundingBox.X2; - yyPCB->MaxHeight = e->BoundingBox.Y2; - yyPCB->is_footprint = 1; -} - -/* --------------------------------------------------------------------------- - * writes the quoted string created by another subroutine - */ -void PrintQuotedString(FILE * FP, const char *S) -{ - const char *start; - - fputc('"', FP); - for(start = S; *S != '\0'; S++) { - if (*S == '"' || *S == '\\') { - if (start != S) - fwrite(start, S-start, 1, FP); - fputc('\\', FP); - fputc(*S, FP); - start = S+1; - } - } - - if (start != S) - fwrite(start, S-start, 1, FP); - - fputc('"', FP); -} - -void file_uninit() -{ -} - -/* --------------------------------------------------------------------------- - * writes out an attribute list - */ -static void WriteAttributeList(FILE * FP, AttributeListTypePtr list, char *prefix) -{ - int i; - - for (i = 0; i < list->Number; i++) - fprintf(FP, "%sAttribute(\"%s\" \"%s\")\n", prefix, list->List[i].name, list->List[i].value); -} - -/* --------------------------------------------------------------------------- - * writes layout header information - */ -static void WritePCBInfoHeader(FILE * FP) -{ - /* write some useful comments */ - fprintf(FP, "# release: %s " VERSION "\n", Progname); - - /* avoid writing things like user name or date, as these cause merge - * conflicts in collaborative environments using version control systems - */ -} - -/* --------------------------------------------------------------------------- - * writes data header - * the name of the PCB, cursor location, zoom and grid - * layergroups and some flags - */ -static void WritePCBDataHeader(FILE * FP) -{ - Cardinal group; - - /* - * ************************** README ******************* - * ************************** README ******************* - * - * If the file format is modified in any way, update - * PCB_FILE_VERSION in file.h as well as PCBFileVersionNeeded() - * at the top of this file. - * - * ************************** README ******************* - * ************************** README ******************* - */ - - fprintf(FP, "\n# To read pcb files, the pcb version (or the git source date) must be >= the file version\n"); - fprintf(FP, "FileVersion[%i]\n", PCBFileVersionNeeded()); - - fputs("\nPCB[", FP); - PrintQuotedString(FP, (char *) EMPTY(PCB->Name)); - pcb_fprintf(FP, " %mr %mr]\n\n", PCB->MaxWidth, PCB->MaxHeight); - pcb_fprintf(FP, "Grid[%.1mr %mr %mr %d]\n", PCB->Grid, PCB->GridOffsetX, PCB->GridOffsetY, conf_core.editor.draw_grid); - pcb_fprintf(FP, "Cursor[%mr %mr %s]\n", Crosshair.X, Crosshair.Y, c_dtostr(PCB->Zoom)); - /* PolyArea should be output in square cmils, no suffix */ - fprintf(FP, "PolyArea[%s]\n", c_dtostr(COORD_TO_MIL(COORD_TO_MIL(PCB->IsleArea) * 100) * 100)); - pcb_fprintf(FP, "Thermal[%s]\n", c_dtostr(PCB->ThermScale)); - pcb_fprintf(FP, "DRC[%mr %mr %mr %mr %mr %mr]\n", PCB->Bloat, PCB->Shrink, - PCB->minWid, PCB->minSlk, PCB->minDrill, PCB->minRing); - fprintf(FP, "Flags(%s)\n", pcbflags_to_string(PCB->Flags)); - fprintf(FP, "Groups(\"%s\")\n", LayerGroupsToString(&PCB->LayerGroups)); - fputs("Styles[\"", FP); - for (group = 0; group < NUM_STYLES - 1; group++) - pcb_fprintf(FP, "%s,%mr,%mr,%mr,%mr:", PCB->RouteStyle[group].Name, - PCB->RouteStyle[group].Thick, - PCB->RouteStyle[group].Diameter, PCB->RouteStyle[group].Hole, PCB->RouteStyle[group].Keepaway); - pcb_fprintf(FP, "%s,%mr,%mr,%mr,%mr\"]\n\n", PCB->RouteStyle[group].Name, - PCB->RouteStyle[group].Thick, - PCB->RouteStyle[group].Diameter, PCB->RouteStyle[group].Hole, PCB->RouteStyle[group].Keepaway); -} - -/* --------------------------------------------------------------------------- - * writes font data of non empty symbols - */ -static void WritePCBFontData(FILE * FP) -{ - Cardinal i, j; - LineTypePtr line; - FontTypePtr font; - - for (font = &PCB->Font, i = 0; i <= MAX_FONTPOSITION; i++) { - if (!font->Symbol[i].Valid) - continue; - - if (isprint(i)) - pcb_fprintf(FP, "Symbol['%c' %mr]\n(\n", i, font->Symbol[i].Delta); - else - pcb_fprintf(FP, "Symbol[%i %mr]\n(\n", i, font->Symbol[i].Delta); - - line = font->Symbol[i].Line; - for (j = font->Symbol[i].LineN; j; j--, line++) - pcb_fprintf(FP, "\tSymbolLine[%mr %mr %mr %mr %mr]\n", - line->Point1.X, line->Point1.Y, line->Point2.X, line->Point2.Y, line->Thickness); - fputs(")\n", FP); - } -} - -/* --------------------------------------------------------------------------- - * writes via data - */ -static void WriteViaData(FILE * FP, DataTypePtr Data) -{ - gdl_iterator_t it; - PinType *via; - - /* write information about vias */ - pinlist_foreach(&Data->Via, &it, via) { - pcb_fprintf(FP, "Via[%mr %mr %mr %mr %mr %mr ", via->X, via->Y, - via->Thickness, via->Clearance, via->Mask, via->DrillingHole); - PrintQuotedString(FP, (char *) EMPTY(via->Name)); - fprintf(FP, " %s]\n", F2S(via, VIA_TYPE)); - } -} - -/* --------------------------------------------------------------------------- - * writes rat-line data - */ -static void WritePCBRatData(FILE * FP) -{ - gdl_iterator_t it; - RatType *line; - - /* write information about rats */ - ratlist_foreach(&PCB->Data->Rat, &it, line) { - pcb_fprintf(FP, "Rat[%mr %mr %d %mr %mr %d ", - line->Point1.X, line->Point1.Y, line->group1, line->Point2.X, line->Point2.Y, line->group2); - fprintf(FP, " %s]\n", F2S(line, RATLINE_TYPE)); - } -} - -/* --------------------------------------------------------------------------- - * writes netlist data - */ -static void WritePCBNetlistData(FILE * FP) -{ - /* write out the netlist if it exists */ - if (PCB->NetlistLib[NETLIST_INPUT].MenuN) { - int n, p; - fprintf(FP, "NetList()\n(\n"); - - for (n = 0; n < PCB->NetlistLib[NETLIST_INPUT].MenuN; n++) { - LibraryMenuTypePtr menu = &PCB->NetlistLib[NETLIST_INPUT].Menu[n]; - fprintf(FP, "\tNet("); - PrintQuotedString(FP, &menu->Name[2]); - fprintf(FP, " "); - PrintQuotedString(FP, (char *) UNKNOWN(menu->Style)); - fprintf(FP, ")\n\t(\n"); - for (p = 0; p < menu->EntryN; p++) { - LibraryEntryTypePtr entry = &menu->Entry[p]; - fprintf(FP, "\t\tConnect("); - PrintQuotedString(FP, entry->ListEntry); - fprintf(FP, ")\n"); - } - fprintf(FP, "\t)\n"); - } - fprintf(FP, ")\n"); - } -} - -/* --------------------------------------------------------------------------- - * writes netlist patch data - */ -static void WritePCBNetlistPatchData(FILE * FP) -{ - if (PCB->NetlistPatches != NULL) { - fprintf(FP, "NetListPatch()\n(\n"); - rats_patch_fexport(PCB, FP, 1); - fprintf(FP, ")\n"); - } -} - -/* --------------------------------------------------------------------------- - * writes element data - */ -static void WriteElementData(FILE * FP, DataTypePtr Data) -{ - gdl_iterator_t eit; - LineType *line; - ArcType *arc; - ElementType *element; - - elementlist_foreach(&Data->Element, &eit, element) { - gdl_iterator_t it; - PinType *pin; - PadType *pad; - - /* only non empty elements */ - if (!linelist_length(&element->Line) && !pinlist_length(&element->Pin) && !arclist_length(&element->Arc) && !padlist_length(&element->Pad)) - continue; - /* the coordinates and text-flags are the same for - * both names of an element - */ - fprintf(FP, "\nElement[%s ", F2S(element, ELEMENT_TYPE)); - PrintQuotedString(FP, (char *) EMPTY(DESCRIPTION_NAME(element))); - fputc(' ', FP); - PrintQuotedString(FP, (char *) EMPTY(NAMEONPCB_NAME(element))); - fputc(' ', FP); - PrintQuotedString(FP, (char *) EMPTY(VALUE_NAME(element))); - pcb_fprintf(FP, " %mr %mr %mr %mr %d %d %s]\n(\n", - element->MarkX, element->MarkY, - DESCRIPTION_TEXT(element).X - element->MarkX, - DESCRIPTION_TEXT(element).Y - element->MarkY, - DESCRIPTION_TEXT(element).Direction, - DESCRIPTION_TEXT(element).Scale, F2S(&(DESCRIPTION_TEXT(element)), ELEMENTNAME_TYPE)); - WriteAttributeList(FP, &element->Attributes, "\t"); - pinlist_foreach(&element->Pin, &it, pin) { - pcb_fprintf(FP, "\tPin[%mr %mr %mr %mr %mr %mr ", - pin->X - element->MarkX, - pin->Y - element->MarkY, pin->Thickness, pin->Clearance, pin->Mask, pin->DrillingHole); - PrintQuotedString(FP, (char *) EMPTY(pin->Name)); - fprintf(FP, " "); - PrintQuotedString(FP, (char *) EMPTY(pin->Number)); - fprintf(FP, " %s]\n", F2S(pin, PIN_TYPE)); - } - pinlist_foreach(&element->Pad, &it, pad) { - pcb_fprintf(FP, "\tPad[%mr %mr %mr %mr %mr %mr %mr ", - pad->Point1.X - element->MarkX, - pad->Point1.Y - element->MarkY, - pad->Point2.X - element->MarkX, pad->Point2.Y - element->MarkY, pad->Thickness, pad->Clearance, pad->Mask); - PrintQuotedString(FP, (char *) EMPTY(pad->Name)); - fprintf(FP, " "); - PrintQuotedString(FP, (char *) EMPTY(pad->Number)); - fprintf(FP, " %s]\n", F2S(pad, PAD_TYPE)); - } - linelist_foreach(&element->Line, &it, line) { - pcb_fprintf(FP, "\tElementLine [%mr %mr %mr %mr %mr]\n", - line->Point1.X - element->MarkX, - line->Point1.Y - element->MarkY, - line->Point2.X - element->MarkX, line->Point2.Y - element->MarkY, line->Thickness); - } - linelist_foreach(&element->Arc, &it, arc) { - pcb_fprintf(FP, "\tElementArc [%mr %mr %mr %mr %ma %ma %mr]\n", - arc->X - element->MarkX, - arc->Y - element->MarkY, arc->Width, arc->Height, arc->StartAngle, arc->Delta, arc->Thickness); - } - fputs("\n\t)\n", FP); - } -} - -/* --------------------------------------------------------------------------- - * writes layer data - */ -static void WriteLayerData(FILE * FP, Cardinal Number, LayerTypePtr layer) -{ - gdl_iterator_t it; - LineType *line; - ArcType *arc; - TextType *text; - PolygonType *polygon; - - /* write information about non empty layers */ - if (!LAYER_IS_EMPTY(layer) || (layer->Name && *layer->Name)) { - fprintf(FP, "Layer(%i ", (int) Number + 1); - PrintQuotedString(FP, (char *) EMPTY(layer->Name)); - fputs(")\n(\n", FP); - WriteAttributeList(FP, &layer->Attributes, "\t"); - - linelist_foreach(&layer->Line, &it, line) { - pcb_fprintf(FP, "\tLine[%mr %mr %mr %mr %mr %mr %s]\n", - line->Point1.X, line->Point1.Y, - line->Point2.X, line->Point2.Y, line->Thickness, line->Clearance, F2S(line, LINE_TYPE)); - } - arclist_foreach(&layer->Arc, &it, arc) { - pcb_fprintf(FP, "\tArc[%mr %mr %mr %mr %mr %mr %ma %ma %s]\n", - arc->X, arc->Y, arc->Width, - arc->Height, arc->Thickness, arc->Clearance, arc->StartAngle, arc->Delta, F2S(arc, ARC_TYPE)); - } - textlist_foreach(&layer->Text, &it, text) { - pcb_fprintf(FP, "\tText[%mr %mr %d %d ", text->X, text->Y, text->Direction, text->Scale); - PrintQuotedString(FP, (char *) EMPTY(text->TextString)); - fprintf(FP, " %s]\n", F2S(text, TEXT_TYPE)); - } - textlist_foreach(&layer->Polygon, &it, polygon) { - int p, i = 0; - Cardinal hole = 0; - fprintf(FP, "\tPolygon(%s)\n\t(", F2S(polygon, POLYGON_TYPE)); - for (p = 0; p < polygon->PointN; p++) { - PointTypePtr point = &polygon->Points[p]; - - if (hole < polygon->HoleIndexN && p == polygon->HoleIndex[hole]) { - if (hole > 0) - fputs("\n\t\t)", FP); - fputs("\n\t\tHole (", FP); - hole++; - i = 0; - } - - if (i++ % 5 == 0) { - fputs("\n\t\t", FP); - if (hole) - fputs("\t", FP); - } - pcb_fprintf(FP, "[%mr %mr] ", point->X, point->Y); - } - if (hole > 0) - fputs("\n\t\t)", FP); - fputs("\n\t)\n", FP); - } - fputs(")\n", FP); - } -} - -/* --------------------------------------------------------------------------- - * writes just the elements in the buffer to file - */ -static int WriteBuffer(FILE * FP) -{ - Cardinal i; - - WriteViaData(FP, PASTEBUFFER->Data); - WriteElementData(FP, PASTEBUFFER->Data); - for (i = 0; i < max_copper_layer + 2; i++) - WriteLayerData(FP, i, &(PASTEBUFFER->Data->Layer[i])); - return (STATUS_OK); -} - -/* --------------------------------------------------------------------------- - * writes PCB to file - */ -static int WritePCB(FILE * FP) -{ - Cardinal i; - - WritePCBInfoHeader(FP); - WritePCBDataHeader(FP); - WritePCBFontData(FP); - WriteAttributeList(FP, &PCB->Attributes, ""); - WriteViaData(FP, PCB->Data); - WriteElementData(FP, PCB->Data); - WritePCBRatData(FP); - for (i = 0; i < max_copper_layer + 2; i++) - WriteLayerData(FP, i, &(PCB->Data->Layer[i])); - WritePCBNetlistData(FP); - WritePCBNetlistPatchData(FP); - - return (STATUS_OK); -} - -/* --------------------------------------------------------------------------- - * writes PCB to file - */ -static int WritePCBFile(char *Filename) -{ - FILE *fp; - int result; - - if ((fp = fopen(Filename, "w")) == NULL) { - OpenErrorMessage(Filename); - return (STATUS_ERROR); - } - result = WritePCB(fp); - fclose(fp); - return (result); -} - -/* --------------------------------------------------------------------------- - * writes to pipe using the command defined by conf_core.rc.save_command - * %f are replaced by the passed filename - */ -static int WritePipe(char *Filename, bool thePcb) -{ - FILE *fp; - int result; - char *p; - static gds_t command; - int used_popen = 0; - - if (EMPTY_STRING_P(conf_core.rc.save_command)) { - fp = fopen(Filename, "w"); - if (fp == 0) { - Message("Unable to write to file %s\n", Filename); - return STATUS_ERROR; - } - } - else { - used_popen = 1; - /* setup commandline */ - gds_truncate(&command,0); - for (p = conf_core.rc.save_command; *p; p++) { - /* copy character if not special or add string to command */ - if (!(*p == '%' && *(p + 1) == 'f')) - gds_append(&command, *p); - else { - gds_append_str(&command, Filename); - - /* skip the character */ - p++; - } - } - printf("write to pipe \"%s\"\n", command.array); - if ((fp = popen(command.array, "w")) == NULL) { - PopenErrorMessage(command.array); - return (STATUS_ERROR); - } - } - if (thePcb) { - if (PCB->is_footprint) { - WriteElementData(fp, PCB->Data); - result = 0; - } - else - result = WritePCB(fp); - } - else - result = WriteBuffer(fp); - - if (used_popen) - return (pclose(fp) ? STATUS_ERROR : result); - return (fclose(fp) ? STATUS_ERROR : result); -} - -/* --------------------------------------------------------------------------- - * saves the layout in a temporary file - * this is used for fatal errors and does not call the program specified - * in 'saveCommand' for safety reasons - */ -void SaveInTMP(void) -{ - char filename[80]; - - /* memory might have been released before this function is called */ - if (PCB && PCB->Changed) { - sprintf(filename, EMERGENCY_NAME, (int) getpid()); - Message(_("Trying to save your layout in '%s'\n"), filename); - WritePCBFile(filename); - } -} - -/* --------------------------------------------------------------------------- - * front-end for 'SaveInTMP()' - * just makes sure that the routine is only called once - */ -static bool dont_save_any_more = false; -void EmergencySave(void) -{ - - if (!dont_save_any_more) { - SaveInTMP(); - dont_save_any_more = true; - } -} - -void DisableEmergencySave(void) -{ - dont_save_any_more = true; -} - -/* ---------------------------------------------------------------------- - * Callback for the autosave - */ - -static hidval backup_timer; - -/* - * If the backup interval is > 0 then set another timer. Otherwise - * we do nothing and it is up to the GUI to call EnableAutosave() - * after setting conf_core.rc.backup_interval > 0 again. - */ -static void backup_cb(hidval data) -{ - backup_timer.ptr = NULL; - Backup(); - if (conf_core.rc.backup_interval > 0 && gui->add_timer) - backup_timer = gui->add_timer(backup_cb, 1000 * conf_core.rc.backup_interval, data); -} - -void EnableAutosave(void) -{ - hidval x; - - x.ptr = NULL; - - /* If we already have a timer going, then cancel it out */ - if (backup_timer.ptr != NULL && gui->stop_timer) - gui->stop_timer(backup_timer); - - backup_timer.ptr = NULL; - /* Start up a new timer */ - if (conf_core.rc.backup_interval > 0 && gui->add_timer) - backup_timer = gui->add_timer(backup_cb, 1000 * conf_core.rc.backup_interval, x); -} - -/* --------------------------------------------------------------------------- - * creates backup file. The default is to use the pcb file name with - * a "-" appended (like "foo.pcb-") and if we don't have a pcb file name - * then use the template in BACKUP_NAME - */ -void Backup(void) -{ - char *filename = NULL; - - if (PCB && PCB->Filename) { - filename = (char *) malloc(sizeof(char) * (strlen(PCB->Filename) + 2)); - if (filename == NULL) { - fprintf(stderr, "Backup(): malloc failed\n"); - exit(1); - } - sprintf(filename, "%s-", PCB->Filename); - } - else { - /* BACKUP_NAME has %.8i which will be replaced by the process ID */ - filename = (char *) malloc(sizeof(char) * (strlen(BACKUP_NAME) + 8)); - if (filename == NULL) { - fprintf(stderr, "Backup(): malloc failed\n"); - exit(1); - } - sprintf(filename, BACKUP_NAME, (int) getpid()); - } - - WritePCBFile(filename); - free(filename); -} - -#if !defined(HAS_ATEXIT) && !defined(HAS_ON_EXIT) -/* --------------------------------------------------------------------------- - * makes a temporary copy of the data. This is useful for systems which - * doesn't support calling functions on exit. We use this to save the data - * before LEX and YACC functions are called because they are able to abort - * the program. - */ -void SaveTMPData(void) -{ - sprintf(TMPFilename, EMERGENCY_NAME, (int) getpid()); - WritePCBFile(TMPFilename); -} - -/* --------------------------------------------------------------------------- - * removes the temporary copy of the data file - */ -void RemoveTMPData(void) -{ - unlink(TMPFilename); -} -#endif - -#define BLANK(x) ((x) == ' ' || (x) == '\t' || (x) == '\n' \ - || (x) == '\0') - -/* --------------------------------------------------------------------------- - * Read in a netlist and store it in the netlist menu - */ - -int ReadNetlist(char *filename) -{ - char *command = NULL; - char inputline[MAX_NETLIST_LINE_LENGTH + 1]; - char temp[MAX_NETLIST_LINE_LENGTH + 1]; - FILE *fp; - LibraryMenuTypePtr menu = NULL; - LibraryEntryTypePtr entry; - int i, j, lines, kind; - bool continued; - int used_popen = 0; - - if (!filename) - return (1); /* nothing to do */ - - Message(_("Importing PCB netlist %s\n"), filename); - - if (EMPTY_STRING_P(conf_core.rc.rat_command)) { - fp = fopen(filename, "r"); - if (!fp) { - Message("Cannot open %s for reading", filename); - return 1; - } - } - else { - used_popen = 1; - command = EvaluateFilename(conf_core.rc.rat_command, conf_core.rc.rat_path, filename, NULL); - - /* open pipe to stdout of command */ - if (*command == '\0' || (fp = popen(command, "r")) == NULL) { - PopenErrorMessage(command); - free(command); - return (1); - } - free(command); - } - lines = 0; - /* kind = 0 is net name - * kind = 1 is route style name - * kind = 2 is connection - */ - kind = 0; - while (fgets(inputline, MAX_NETLIST_LINE_LENGTH, fp)) { - size_t len = strlen(inputline); - /* check for maximum length line */ - if (len) { - if (inputline[--len] != '\n') - Message(_("Line length (%i) exceeded in netlist file.\n" - "additional characters will be ignored.\n"), MAX_NETLIST_LINE_LENGTH); - else - inputline[len] = '\0'; - } - continued = (inputline[len - 1] == '\\') ? true : false; - if (continued) - inputline[len - 1] = '\0'; - lines++; - i = 0; - while (inputline[i] != '\0') { - j = 0; - /* skip leading blanks */ - while (inputline[i] != '\0' && BLANK(inputline[i])) - i++; - if (kind == 0) { - /* add two spaces for included/unincluded */ - temp[j++] = ' '; - temp[j++] = ' '; - } - while (!BLANK(inputline[i])) - temp[j++] = inputline[i++]; - temp[j] = '\0'; - while (inputline[i] != '\0' && BLANK(inputline[i])) - i++; - if (kind == 0) { - menu = GetLibraryMenuMemory(&PCB->NetlistLib[NETLIST_INPUT], NULL); - menu->Name = strdup(temp); - menu->flag = 1; - kind++; - } - else { - if (kind == 1 && strchr(temp, '-') == NULL) { - kind++; - menu->Style = strdup(temp); - } - else { - entry = GetLibraryEntryMemory(menu); - entry->ListEntry = strdup(temp); - entry->ListEntry_dontfree = 0; - } - } - } - if (!continued) - kind = 0; - } - if (!lines) { - Message(_("Empty netlist file!\n")); - pclose(fp); - return (1); - } - if (used_popen) - pclose(fp); - else - fclose(fp); - sort_netlist(); - rats_patch_make_edited(PCB); - return (0); -} - -int ImportNetlist(char *filename) -{ - FILE *fp; - char buf[16]; - int i; - char *p; - - - if (!filename) - return (1); /* nothing to do */ - fp = fopen(filename, "r"); - if (!fp) - return (1); /* bad filename */ - i = fread(buf, 1, sizeof(buf) - 1, fp); - fclose(fp); - buf[i] = '\0'; - p = buf; - while (*p) { - *p = tolower((int) *p); - p++; - } - p = strstr(buf, "edif"); - if (!p) - return ReadNetlist(filename); - else - return stub_ReadEdifNetlist(filename); -} Index: trunk/src/strflags.c =================================================================== --- trunk/src/strflags.c (revision 1760) +++ trunk/src/strflags.c (nonexistent) @@ -1,603 +0,0 @@ -/* $Id$ */ -/* - * COPYRIGHT - * - * PCB, interactive printed circuit board design - * Copyright (C) 2005 DJ Delorie - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Contact addresses for paper mail and Email: - * DJ Delorie, 334 North Road, Deerfield NH 03037-1110, USA - * dj@delorie.com - * - */ - -#include "config.h" - -#include -#include -#ifdef HAVE_STDLIB_H -#include -#endif -#ifdef HAVE_STRING_H -#include -#endif - -#include "globalconst.h" -#include "global.h" -#include "compat_misc.h" -#include "const.h" -#include "strflags.h" - - -RCSID("$Id$"); - -/* Because all the macros expect it, that's why. */ -typedef struct { - FlagType Flags; -} FlagHolder; - -/* Be careful to list more specific flags first, followed by general - * flags, when two flags use the same bit. For example, "onsolder" is - * for elements only, while "auto" is for everything else. They use - * the same bit, but onsolder is listed first so that elements will - * use it and not auto. - * - * Thermals are handled separately, as they're layer-selective. - */ - -typedef struct { - - /* This is the bit that we're setting. */ - int mask; - - /* The name used in the output file. */ - char *name; - int nlen; -#define N(x) x, sizeof(x)-1 - - /* If set, this entry won't be output unless the object type is one - of these. */ - int object_types; - -} FlagBitsType; - -static FlagBitsType object_flagbits[] = { - {PINFLAG, N("pin"), ALL_TYPES}, - {VIAFLAG, N("via"), ALL_TYPES}, - {FOUNDFLAG, N("found"), ALL_TYPES}, - {HOLEFLAG, N("hole"), PIN_TYPES}, - {RATFLAG, N("rat"), RATLINE_TYPE}, - {PININPOLYFLAG, N("pininpoly"), PIN_TYPES | PAD_TYPE}, - {CLEARPOLYFLAG, N("clearpoly"), POLYGON_TYPE}, - {HIDENAMEFLAG, N("hidename"), ELEMENT_TYPE}, - {SNAPOFFGRIDLINEFLAG, N("snapoffgridline"), ALL_TYPES}, - {HIGHLIGHTONPOINTFLAG, N("highlightonpoint"), ALL_TYPES}, - {DISPLAYNAMEFLAG, N("showname"), ELEMENT_TYPE}, - {CLEARLINEFLAG, N("clearline"), LINE_TYPE | ARC_TYPE | TEXT_TYPE}, - {SELECTEDFLAG, N("selected"), ALL_TYPES}, - {ONSOLDERFLAG, N("onsolder"), ELEMENT_TYPE | PAD_TYPE | TEXT_TYPE}, - {AUTOFLAG, N("auto"), ALL_TYPES}, - {SQUAREFLAG, N("square"), PIN_TYPES | PAD_TYPE}, - {RUBBERENDFLAG, N("rubberend"), LINE_TYPE | ARC_TYPE}, - {WARNFLAG, N("warn"), PIN_TYPES | PAD_TYPE}, - {USETHERMALFLAG, N("usetherm"), PIN_TYPES | LINE_TYPE | ARC_TYPE}, - {OCTAGONFLAG, N("octagon"), PIN_TYPES | PAD_TYPE}, - {DRCFLAG, N("drc"), ALL_TYPES}, - {LOCKFLAG, N("lock"), ALL_TYPES}, - {EDGE2FLAG, N("edge2"), ALL_TYPES}, - {FULLPOLYFLAG, N("fullpoly"), POLYGON_TYPE}, - {NOPASTEFLAG, N("nopaste"), PAD_TYPE}, - {NONETLISTFLAG, N("nonetlist"), ALL_TYPES} -}; - -static FlagBitsType pcb_flagbits[] = { - {SHOWNUMBERFLAG, N("shownumber"), 1}, - {LOCALREFFLAG, N("localref"), 1}, - {CHECKPLANESFLAG, N("checkplanes"), 1}, - {SHOWDRCFLAG, N("showdrc"), 1}, - {RUBBERBANDFLAG, N("rubberband"), 1}, - {DESCRIPTIONFLAG, N("description"), 1}, - {NAMEONPCBFLAG, N("nameonpcb"), 1}, - {AUTODRCFLAG, N("autodrc"), 1}, - {ALLDIRECTIONFLAG, N("alldirection"), 1}, - {SWAPSTARTDIRFLAG, N("swapstartdir"), 1}, - {UNIQUENAMEFLAG, N("uniquename"), 1}, - {CLEARNEWFLAG, N("clearnew"), 1}, - {NEWFULLPOLYFLAG, N("newfullpoly"), 1}, - {SNAPPINFLAG, N("snappin"), 1}, - {SHOWMASKFLAG, N("showmask"), 1}, - {THINDRAWFLAG, N("thindraw"), 1}, - {ORTHOMOVEFLAG, N("orthomove"), 1}, - {LIVEROUTEFLAG, N("liveroute"), 1}, - {THINDRAWPOLYFLAG, N("thindrawpoly"), 1}, - {LOCKNAMESFLAG, N("locknames"), 1}, - {ONLYNAMESFLAG, N("onlynames"), 1}, - {HIDENAMESFLAG, N("hidenames"), 1}, - {ENABLEMINCUTFLAG, N("enablemincut"), 1}, - {ENABLESTROKEFLAG, N("enablestroke"), 1} -}; - -#undef N - -/* - * This helper function maintains a small list of buffers which are - * used by flags_to_string(). Each buffer is allocated from the heap, - * but the caller must not free them (they get realloced when they're - * reused, but never completely freed). - */ - -static struct { - char *ptr; - int len; -} buffers[10]; -static int bufptr = 0; -static char *alloc_buf(int len) -{ -#define B buffers[bufptr] - len++; - bufptr = (bufptr + 1) % 10; - if (B.len < len) { - if (B.ptr) - B.ptr = (char *) realloc(B.ptr, len); - else - B.ptr = (char *) malloc(len); - B.len = len; - } - return B.ptr; -#undef B -} - -void uninit_strflags_buf(void) -{ - int n; - for(n = 0; n < 10; n++) { - if (buffers[n].ptr != NULL) { - free(buffers[n].ptr); - buffers[n].ptr = NULL; - } - } -} - -/* - * This set of routines manages a list of layer-specific flags. - * Callers should call grow_layer_list(0) to reset the list, and - * set_layer_list(layer,1) to set bits in the layer list. The results - * are stored in layers[], which has num_layers valid entries. - */ - -static char *layers = 0; -static int max_layers = 0, num_layers = 0; - -static void grow_layer_list(int num) -{ - if (layers == 0) { - layers = (char *) calloc(num > 0 ? num : 1, 1); - max_layers = num; - } - else if (num > max_layers) { - max_layers = num; - layers = (char *) realloc(layers, max_layers); - } - if (num > num_layers) - memset(layers + num_layers, 0, num - num_layers - 1); - num_layers = num; - return; -} - -void uninit_strflags_layerlist(void) -{ - if (layers != NULL) { - free(layers); - layers = NULL; - num_layers = max_layers = 0; - } -} - -static inline void set_layer_list(int layer, int v) -{ - if (layer >= num_layers) - grow_layer_list(layer + 1); - layers[layer] = v; -} - -/* - * These next two convert between layer lists and strings. - * parse_layer_list() is passed a pointer to a string, and parses a - * list of integer which reflect layers to be flagged. It returns a - * pointer to the first character following the list. The syntax of - * the list is a paren-surrounded, comma-separated list of integers - * and/or pairs of integers separated by a dash (like "(1,2,3-7)"). - * Spaces and other punctuation are not allowed. The results are - * stored in layers[] defined above. - * - * print_layer_list() does the opposite - it uses the flags set in - * layers[] to build a string that represents them, using the syntax - * above. - * - */ - -/* Returns a pointer to the first character past the list. */ -static const char *parse_layer_list(const char *bp, int (*error) (const char *)) -{ - const char *orig_bp = bp; - int l = 0, range = -1; - int value = 1; - - grow_layer_list(0); - while (*bp) { - if (*bp == '+') - value = 2; - else if (*bp == 'S') - value = 3; - else if (*bp == 'X') - value = 4; - else if (*bp == 't') - value = 5; - else if (*bp == ')' || *bp == ',' || *bp == '-') { - if (range == -1) - range = l; - while (range <= l) - set_layer_list(range++, value); - if (*bp == '-') - range = l; - else - range = -1; - value = 1; - l = 0; - } - - else if (isdigit((int) *bp)) - l = l * 10 + (*bp - '0'); - - else if (error) { - char *fmt = "Syntax error parsing layer list \"%.*s\" at %c"; - char *msg = alloc_buf(strlen(fmt) + strlen(orig_bp)); - sprintf(msg, fmt, bp - orig_bp + 5, orig_bp, *bp); - error(msg); - error = NULL; - } - - if (*bp == ')') - return bp + 1; - - bp++; - } - return bp; -} - -/* Number of character the value "i" requires when printed. */ -static int printed_int_length(int i, int j) -{ - int rv; - - if (i < 10) - return 1 + (j ? 1 : 0); - if (i < 100) - return 2 + (j ? 1 : 0); - - for (rv = 1; i >= 10; rv++) - i /= 10; - return rv + (j ? 1 : 0); -} - -/* Returns a pointer to an internal buffer which is overwritten with - each new call. */ -static char *print_layer_list() -{ - static char *buf = 0; - static int buflen = 0; - int len, i, j; - char *bp; - - len = 2; - for (i = 0; i < num_layers; i++) - if (layers[i]) - len += 1 + printed_int_length(i, layers[i]); - if (buflen < len) { - if (buf) - buf = (char *) realloc(buf, len); - else - buf = (char *) malloc(len); - buflen = len; - } - - bp = buf; - *bp++ = '('; - - for (i = 0; i < num_layers; i++) - if (layers[i]) { - /* 0 0 1 1 1 0 0 */ - /* i j */ - for (j = i + 1; j < num_layers && layers[j] == 1; j++); - if (j > i + 2) { - sprintf(bp, "%d-%d,", i, j - 1); - i = j - 1; - } - else - switch (layers[i]) { - case 1: - sprintf(bp, "%d,", i); - break; - case 2: - sprintf(bp, "%d+,", i); - break; - case 3: - sprintf(bp, "%dS,", i); - break; - case 4: - sprintf(bp, "%dX,", i); - break; - case 5: - default: - sprintf(bp, "%dt,", i); - break; - } - bp += strlen(bp); - } - bp[-1] = ')'; - *bp = 0; - return buf; -} - -/* - * Ok, now the two entry points to this file. The first, string_to_flags, - * is passed a string (usually from parse_y.y) and returns a "set of flags". - * In theory, this can be anything, but for now it's just an integer. Later - * it might be a structure, for example. - * - * Currently, there is no error handling :-P - */ - -static int error_ignore(const char *msg) -{ /* do nothing */ - return 0; -} - -static FlagType empty_flags; - -static FlagType -common_string_to_flags(const char *flagstring, int (*error) (const char *msg), FlagBitsType * flagbits, int n_flagbits) -{ - const char *fp, *ep; - int flen; - FlagHolder rv; - int i; - - rv.Flags = empty_flags; - - if (error == 0) - error = error_ignore; - - if (flagstring == NULL) - return empty_flags; - - fp = ep = flagstring; - - if (*fp == '"') - ep = ++fp; - - while (*ep && *ep != '"') { - int found = 0; - - for (ep = fp; *ep && *ep != ',' && *ep != '"' && *ep != '('; ep++); - flen = ep - fp; - if (*ep == '(') - ep = parse_layer_list(ep + 1, error); - - if (flen == 7 && memcmp(fp, "thermal", 7) == 0) { - for (i = 0; i < MAX_LAYER && i < num_layers; i++) - if (layers[i]) - ASSIGN_THERM(i, layers[i], &rv); - } - else if (flen == 5 && memcmp(fp, "shape", 5) == 0) { - rv.Flags.q = atoi(fp + 6); - } - else if (flen == 7 && memcmp(fp, "intconn", 7) == 0) { - rv.Flags.int_conn_grp = atoi(fp + 8); - } - else { - for (i = 0; i < n_flagbits; i++) - if (flagbits[i].nlen == flen && memcmp(flagbits[i].name, fp, flen) == 0) { - found = 1; - SET_FLAG(flagbits[i].mask, &rv); - break; - } - if (!found) { - const char *fmt = "Unknown flag: \"%.*s\" ignored"; - unknown_flag_t *u; - char *msg; - const char *s; - - /* include () */ - s = fp + flen; - if (*s == '(') { - while (*s != ')') { - flen++; - s++; - } - } - if (*s == ')') - flen++; - - msg = alloc_buf(strlen(fmt) + flen); - sprintf(msg, fmt, flen, fp); - error(msg); - - u = malloc(sizeof(unknown_flag_t)); - u->str = strndup(fp, flen); - u->next = NULL; - /* need to append, to keep order of flags */ - if (rv.Flags.unknowns != NULL) { - unknown_flag_t *n; - for (n = rv.Flags.unknowns; n->next != NULL; n = n->next); - n->next = u; - } - else - rv.Flags.unknowns = u; - } - } - fp = ep + 1; - } - return rv.Flags; -} - -FlagType string_to_flags(const char *flagstring, int (*error) (const char *msg)) -{ - return common_string_to_flags(flagstring, error, object_flagbits, ENTRIES(object_flagbits)); -} - -FlagType string_to_pcbflags(const char *flagstring, int (*error) (const char *msg)) -{ - return common_string_to_flags(flagstring, error, pcb_flagbits, ENTRIES(pcb_flagbits)); -} - - -/* - * Given a set of flags for a given type of object, return a string - * which reflects those flags. The only requirement is that this - * string be parseable by string_to_flags. - * - * Note that this function knows a little about what kinds of flags - * will be automatically set by parsing, so it won't (for example) - * include the "via" flag for VIA_TYPEs because it knows those get - * forcibly set when vias are parsed. - */ - -static char *common_flags_to_string(FlagType flags, int object_type, FlagBitsType * flagbits, int n_flagbits) -{ - int len; - int i; - FlagHolder fh, savef; - char *buf, *bp; - unknown_flag_t *u; - - fh.Flags = flags; - -#ifndef FLAG_TEST - switch (object_type) { - case VIA_TYPE: - CLEAR_FLAG(VIAFLAG, &fh); - break; - case RATLINE_TYPE: - CLEAR_FLAG(RATFLAG, &fh); - break; - case PIN_TYPE: - CLEAR_FLAG(PINFLAG, &fh); - break; - } -#endif - - savef = fh; - - len = 3; /* for "()\0" */ - - for (i = 0; i < n_flagbits; i++) - - if ((flagbits[i].object_types & object_type) - && (TEST_FLAG(flagbits[i].mask, &fh))) { - - len += flagbits[i].nlen + 1; - CLEAR_FLAG(flagbits[i].mask, &fh); - } - - if (TEST_ANY_THERMS(&fh)) { - len += sizeof("thermal()"); - for (i = 0; i < MAX_LAYER; i++) - if (TEST_THERM(i, &fh)) - len += printed_int_length(i, GET_THERM(i, &fh)) + 1; - } - - if (flags.q > 0) { - len += sizeof("shape(.)"); - if (flags.q > 9) - len += 2; - } - - if (flags.int_conn_grp > 0) { - len += sizeof("intconn(.)"); - if (flags.q > 9) - len++; - if (flags.q > 99) - len++; - } - - for (u = flags.unknowns; u != NULL; u = u->next) - len += strlen(u->str) + 1; - - bp = buf = alloc_buf(len + 2); - - *bp++ = '"'; - - fh = savef; - for (i = 0; i < n_flagbits; i++) - if (flagbits[i].object_types & object_type && (TEST_FLAG(flagbits[i].mask, &fh))) { - if (bp != buf + 1) - *bp++ = ','; - strcpy(bp, flagbits[i].name); - bp += flagbits[i].nlen; - CLEAR_FLAG(flagbits[i].mask, &fh); - } - - if (TEST_ANY_THERMS(&fh)) { - if (bp != buf + 1) - *bp++ = ','; - strcpy(bp, "thermal"); - bp += strlen("thermal"); - grow_layer_list(0); - for (i = 0; i < MAX_LAYER; i++) - if (TEST_THERM(i, &fh)) - set_layer_list(i, GET_THERM(i, &fh)); - strcpy(bp, print_layer_list()); - bp += strlen(bp); - } - - if (flags.q > 0) { - if (bp != buf + 1) - *bp++ = ','; - bp += sprintf(bp, "shape(%d)", flags.q); - } - - if (flags.int_conn_grp > 0) { - if (bp != buf + 1) - *bp++ = ','; - bp += sprintf(bp, "intconn(%d)", flags.int_conn_grp); - } - - for (u = flags.unknowns; u != NULL; u = u->next) { - int len; - len = strlen(u->str); - if (bp != buf + 1) - *bp++ = ','; - memcpy(bp, u->str, len); - bp += len; - } - - *bp++ = '"'; - *bp = 0; - return buf; -} - -char *flags_to_string(FlagType flags, int object_type) -{ - return common_flags_to_string(flags, object_type, object_flagbits, ENTRIES(object_flagbits)); -} - -char *pcbflags_to_string(FlagType flags) -{ - return common_flags_to_string(flags, ALL_TYPES, pcb_flagbits, ENTRIES(pcb_flagbits)); -} - Index: trunk/src/parse_y.c =================================================================== --- trunk/src/parse_y.c (revision 1760) +++ trunk/src/parse_y.c (nonexistent) @@ -1,3241 +0,0 @@ -/* A Bison parser, made by GNU Bison 3.0.2. */ - -/* Bison implementation for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* C LALR(1) parser skeleton written by Richard Stallman, by - simplifying the original so-called "semantic" parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Bison version. */ -#define YYBISON_VERSION "3.0.2" - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 0 - -/* Push parsers. */ -#define YYPUSH 0 - -/* Pull parsers. */ -#define YYPULL 1 - - - - -/* Copy the first part of user declarations. */ -#line 11 "parse_y.y" /* yacc.c:339 */ - -/* - * COPYRIGHT - * - * PCB, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Contact addresses for paper mail and Email: - * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany - * Thomas.Nau@rz.uni-ulm.de - * - */ - -/* grammar to parse ASCII input of PCB description - */ - -#include "config.h" -#include "conf_core.h" - -#include "global.h" -#include "create.h" -#include "data.h" -#include "error.h" -#include "file.h" -#include "mymem.h" -#include "misc.h" -#include "parse_l.h" -#include "polygon.h" -#include "remove.h" -#include "rtree.h" -#include "strflags.h" -#include "thermal.h" -#include "rats_patch.h" - -#ifdef HAVE_LIBDMALLOC -# include /* see http://dmalloc.com */ -#endif - -RCSID("$Id$"); - -static LayerTypePtr Layer; -static PolygonTypePtr Polygon; -static SymbolTypePtr Symbol; -static int pin_num; -static LibraryMenuTypePtr Menu; -static bool LayerFlag[MAX_LAYER + 2]; - -extern char *yytext; /* defined by LEX */ -extern PCBTypePtr yyPCB; -extern DataTypePtr yyData; -extern ElementTypePtr yyElement; -extern FontTypePtr yyFont; -extern int yylineno; /* linenumber */ -extern char *yyfilename; /* in this file */ - -static char *layer_group_string; - -static AttributeListTypePtr attr_list; - -int yyerror(const char *s); -int yylex(); -static int check_file_version (int); - -static void do_measure (PLMeasure *m, Coord i, double d, int u); -#define M(r,f,d) do_measure (&(r), f, d, 1) - -/* Macros for interpreting what "measure" means - integer value only, - old units (mil), or new units (cmil). */ -#define IV(m) integer_value (m) -#define OU(m) old_units (m) -#define NU(m) new_units (m) - -static int integer_value (PLMeasure m); -static Coord old_units (PLMeasure m); -static Coord new_units (PLMeasure m); - -#define YYDEBUG 1 -#define YYERROR_VERBOSE 1 - -#include "parse_y.h" - - -#line 163 "parse_y.tab.c" /* yacc.c:339 */ - -# ifndef YY_NULLPTR -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULLPTR nullptr -# else -# define YY_NULLPTR 0 -# endif -# endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -/* In a future release of Bison, this section will be replaced - by #include "parse_y.tab.h". */ -#ifndef YY_YY_PARSE_Y_TAB_H_INCLUDED -# define YY_YY_PARSE_Y_TAB_H_INCLUDED -/* Debug traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif -#if YYDEBUG -extern int yydebug; -#endif - -/* Token type. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - enum yytokentype - { - FLOATING = 258, - INTEGER = 259, - CHAR_CONST = 260, - STRING = 261, - T_FILEVERSION = 262, - T_PCB = 263, - T_LAYER = 264, - T_VIA = 265, - T_RAT = 266, - T_LINE = 267, - T_ARC = 268, - T_RECTANGLE = 269, - T_TEXT = 270, - T_ELEMENTLINE = 271, - T_ELEMENT = 272, - T_PIN = 273, - T_PAD = 274, - T_GRID = 275, - T_FLAGS = 276, - T_SYMBOL = 277, - T_SYMBOLLINE = 278, - T_CURSOR = 279, - T_ELEMENTARC = 280, - T_MARK = 281, - T_GROUPS = 282, - T_STYLES = 283, - T_POLYGON = 284, - T_POLYGON_HOLE = 285, - T_NETLIST = 286, - T_NET = 287, - T_CONN = 288, - T_NETLISTPATCH = 289, - T_ADD_CONN = 290, - T_DEL_CONN = 291, - T_CHANGE_ATTRIB = 292, - T_AREA = 293, - T_THERMAL = 294, - T_DRC = 295, - T_ATTRIBUTE = 296, - T_UMIL = 297, - T_CMIL = 298, - T_MIL = 299, - T_IN = 300, - T_NM = 301, - T_UM = 302, - T_MM = 303, - T_M = 304, - T_KM = 305 - }; -#endif - -/* Value type. */ -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE YYSTYPE; -union YYSTYPE -{ -#line 111 "parse_y.y" /* yacc.c:355 */ - - int integer; - double number; - char *string; - FlagType flagtype; - PLMeasure measure; - -#line 262 "parse_y.tab.c" /* yacc.c:355 */ -}; -# define YYSTYPE_IS_TRIVIAL 1 -# define YYSTYPE_IS_DECLARED 1 -#endif - - -extern YYSTYPE yylval; - -int yyparse (void); - -#endif /* !YY_YY_PARSE_Y_TAB_H_INCLUDED */ - -/* Copy the second part of user declarations. */ - -#line 277 "parse_y.tab.c" /* yacc.c:358 */ - -#ifdef short -# undef short -#endif - -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; -#else -typedef unsigned char yytype_uint8; -#endif - -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; -#else -typedef signed char yytype_int8; -#endif - -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; -#else -typedef unsigned short int yytype_uint16; -#endif - -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; -#else -typedef short int yytype_int16; -#endif - -#ifndef YYSIZE_T -# ifdef __SIZE_TYPE__ -# define YYSIZE_T __SIZE_TYPE__ -# elif defined size_t -# define YYSIZE_T size_t -# elif ! defined YYSIZE_T -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# else -# define YYSIZE_T unsigned int -# endif -#endif - -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) - -#ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS -# if ENABLE_NLS -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_(Msgid) dgettext ("bison-runtime", Msgid) -# endif -# endif -# ifndef YY_ -# define YY_(Msgid) Msgid -# endif -#endif - -#ifndef YY_ATTRIBUTE -# if (defined __GNUC__ \ - && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ - || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C -# define YY_ATTRIBUTE(Spec) __attribute__(Spec) -# else -# define YY_ATTRIBUTE(Spec) /* empty */ -# endif -#endif - -#ifndef YY_ATTRIBUTE_PURE -# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) -#endif - -#ifndef YY_ATTRIBUTE_UNUSED -# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) -#endif - -#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) -# else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) -# endif -#endif - -/* Suppress unused-variable warnings by "using" E. */ -#if ! defined lint || defined __GNUC__ -# define YYUSE(E) ((void) (E)) -#else -# define YYUSE(E) /* empty */ -#endif - -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ -/* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ - _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ - _Pragma ("GCC diagnostic pop") -#else -# define YY_INITIAL_VALUE(Value) Value -#endif -#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_END -#endif -#ifndef YY_INITIAL_VALUE -# define YY_INITIAL_VALUE(Value) /* Nothing. */ -#endif - - -#if ! defined yyoverflow || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# elif defined __BUILTIN_VA_ARG_INCR -# include /* INFRINGES ON USER NAME SPACE */ -# elif defined _AIX -# define YYSTACK_ALLOC __alloca -# elif defined _MSC_VER -# include /* INFRINGES ON USER NAME SPACE */ -# define alloca _alloca -# else -# define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS -# include /* INFRINGES ON USER NAME SPACE */ - /* Use EXIT_SUCCESS as a witness for stdlib.h. */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 -# endif -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's 'empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# ifndef YYSTACK_ALLOC_MAXIMUM - /* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ -# endif -# else -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM -# endif -# if (defined __cplusplus && ! defined EXIT_SUCCESS \ - && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 -# endif -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# if ! defined malloc && ! defined EXIT_SUCCESS -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifndef YYFREE -# define YYFREE free -# if ! defined free && ! defined EXIT_SUCCESS -void free (void *); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - - -#if (! defined yyoverflow \ - && (! defined __cplusplus \ - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - yytype_int16 yyss_alloc; - YYSTYPE yyvs_alloc; -}; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) - -# define YYCOPY_NEEDED 1 - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) - -#endif - -#if defined YYCOPY_NEEDED && YYCOPY_NEEDED -/* Copy COUNT objects from SRC to DST. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) -# else -# define YYCOPY(Dst, Src, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (Dst)[yyi] = (Src)[yyi]; \ - } \ - while (0) -# endif -# endif -#endif /* !YYCOPY_NEEDED */ - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 10 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 608 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 55 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 112 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 214 -/* YYNSTATES -- Number of states. */ -#define YYNSTATES 643 - -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 305 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ -static const yytype_uint8 yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 53, 54, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 51, 2, 52, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50 -}; - -#if YYDEBUG - /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = -{ - 0, 138, 138, 139, 140, 141, 165, 165, 223, 223, - 234, 234, 253, 254, 259, 259, 299, 301, 331, 337, - 343, 372, 373, 374, 377, 385, 398, 430, 436, 442, - 458, 460, 485, 487, 518, 520, 521, 522, 526, 536, - 547, 574, 578, 583, 611, 615, 659, 668, 677, 681, - 682, 686, 687, 691, 692, 692, 693, 694, 696, 696, - 703, 707, 708, 709, 710, 711, 747, 757, 768, 778, - 788, 824, 829, 861, 860, 888, 889, 893, 894, 898, - 899, 900, 901, 902, 903, 905, 910, 911, 912, 913, - 913, 914, 944, 953, 962, 1010, 1019, 1028, 1065, 1075, - 1093, 1143, 1142, 1181, 1183, 1188, 1187, 1194, 1196, 1201, - 1205, 1265, 1266, 1267, 1268, 1269, 1277, 1276, 1295, 1294, - 1313, 1312, 1333, 1331, 1355, 1353, 1434, 1435, 1439, 1440, - 1441, 1442, 1443, 1445, 1450, 1455, 1460, 1465, 1470, 1475, - 1475, 1479, 1480, 1484, 1485, 1486, 1487, 1489, 1495, 1502, - 1507, 1512, 1512, 1553, 1565, 1577, 1588, 1604, 1658, 1672, - 1685, 1696, 1707, 1708, 1712, 1713, 1735, 1737, 1753, 1772, - 1773, 1776, 1778, 1779, 1800, 1807, 1823, 1824, 1828, 1833, - 1834, 1838, 1839, 1863, 1862, 1872, 1873, 1877, 1878, 1897, - 1914, 1915, 1919, 1924, 1925, 1929, 1930, 1945, 1946, 1947, - 1974, 1982, 1983, 1987, 1988, 1993, 1994, 1995, 1996, 1997, - 1998, 1999, 2000, 2001, 2002 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE || 0 -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "FLOATING", "INTEGER", "CHAR_CONST", - "STRING", "T_FILEVERSION", "T_PCB", "T_LAYER", "T_VIA", "T_RAT", - "T_LINE", "T_ARC", "T_RECTANGLE", "T_TEXT", "T_ELEMENTLINE", "T_ELEMENT", - "T_PIN", "T_PAD", "T_GRID", "T_FLAGS", "T_SYMBOL", "T_SYMBOLLINE", - "T_CURSOR", "T_ELEMENTARC", "T_MARK", "T_GROUPS", "T_STYLES", - "T_POLYGON", "T_POLYGON_HOLE", "T_NETLIST", "T_NET", "T_CONN", - "T_NETLISTPATCH", "T_ADD_CONN", "T_DEL_CONN", "T_CHANGE_ATTRIB", - "T_AREA", "T_THERMAL", "T_DRC", "T_ATTRIBUTE", "T_UMIL", "T_CMIL", - "T_MIL", "T_IN", "T_NM", "T_UM", "T_MM", "T_M", "T_KM", "'['", "']'", - "'('", "')'", "$accept", "parse", "parsepcb", "$@1", "$@2", "parsedata", - "$@3", "pcbfont", "parsefont", "$@4", "pcbfileversion", "pcbname", - "pcbgrid", "pcbgridold", "pcbgridnew", "pcbhigrid", "pcbcursor", - "polyarea", "pcbthermal", "pcbdrc", "pcbdrc1", "pcbdrc2", "pcbdrc3", - "pcbflags", "pcbgroups", "pcbstyles", "pcbdata", "pcbdefinitions", - "pcbdefinition", "$@5", "$@6", "via", "via_hi_format", "via_2.0_format", - "via_1.7_format", "via_newformat", "via_oldformat", "rats", "layer", - "$@7", "layerdata", "layerdefinitions", "layerdefinition", "$@8", - "line_hi_format", "line_1.7_format", "line_oldformat", "arc_hi_format", - "arc_1.7_format", "arc_oldformat", "text_oldformat", "text_newformat", - "text_hi_format", "polygon_format", "$@9", "polygonholes", "polygonhole", - "$@10", "polygonpoints", "polygonpoint", "element", "element_oldformat", - "$@11", "element_1.3.4_format", "$@12", "element_newformat", "$@13", - "element_1.7_format", "$@14", "element_hi_format", "$@15", - "elementdefinitions", "elementdefinition", "$@16", "relementdefs", - "relementdef", "$@17", "pin_hi_format", "pin_1.7_format", - "pin_1.6.3_format", "pin_newformat", "pin_oldformat", "pad_hi_format", - "pad_1.7_format", "pad_newformat", "pad", "flags", "symbols", "symbol", - "symbolhead", "symbolid", "symboldata", "symboldefinition", - "hiressymbol", "pcbnetlist", "pcbnetdef", "nets", "netdefs", "net", - "$@18", "connections", "conndefs", "conn", "pcbnetlistpatch", - "pcbnetpatchdef", "netpatches", "netpatchdefs", "netpatch", "attribute", - "opt_string", "number", "measure", YY_NULLPTR -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[NUM] -- (External) token number corresponding to the - (internal) symbol number NUM (which must be that of a token). */ -static const yytype_uint16 yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 91, 93, 40, 41 -}; -# endif - -#define YYPACT_NINF -449 - -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-449))) - -#define YYTABLE_NINF -90 - -#define yytable_value_is_error(Yytable_value) \ - 0 - - /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -static const yytype_int16 yypact[] = -{ - 151, -449, 39, -449, 4, 30, -449, 23, -449, 56, - -449, 32, 97, -31, -449, -449, -449, -449, -449, -449, - -449, 73, -5, 26, -449, 169, -449, 88, 30, -449, - -449, -449, -449, -449, -449, -449, -449, 48, 56, -449, - -449, 129, 55, 116, 49, 113, 140, 63, 63, 63, - 63, -449, 95, -449, -449, 84, 84, -449, -16, 105, - 143, 157, 92, 147, -449, -449, -449, -449, -449, 158, - 161, 168, 176, -449, -449, 305, 63, 63, 63, 63, - 187, -449, -449, 63, 63, 134, -449, -449, -449, -449, - 63, 6, 63, 63, 160, 156, 191, 192, 63, 210, - -449, -449, -449, -449, -449, -449, -449, -449, -449, 63, - 63, 224, 229, 233, 196, 197, 63, 63, 63, -449, - 63, 63, 63, 63, 63, 218, 257, 272, 185, 63, - -449, 236, 63, 221, 63, 63, 245, 255, 270, 63, - 63, 274, 287, 63, 63, 63, 63, 63, 283, 302, - 63, 63, 63, 353, 312, 63, 362, 239, 63, 63, - -449, -449, -449, 63, 63, -449, -449, 378, 0, 63, - 63, 334, 63, 341, 372, -449, -449, -449, 63, 63, - 63, 342, -449, 63, 343, 394, 251, 397, 398, 63, - 63, 351, 350, -449, 354, 355, -449, 356, 63, 357, - 380, 63, 63, 63, 358, 260, 399, -449, 359, 408, - 409, 49, 410, 63, 63, -449, -449, -449, -449, -449, - 63, 228, 363, 389, 63, 63, 414, -449, 205, 226, - 366, 253, 367, 368, 260, -449, 88, -449, -449, -449, - -449, -449, -449, -449, -449, -449, -449, 49, -449, 369, - 417, 373, 370, 376, 375, 63, 379, 381, 424, 256, - 412, 63, 90, 384, 33, 63, 63, 63, 63, 63, - 63, 63, 49, -449, -449, -449, 385, -449, 386, -449, - -449, -449, -449, 11, -449, -449, 387, 433, 436, 195, - -449, 63, 390, 63, 393, 276, 403, 404, 279, 280, - 102, -449, 88, -449, -449, -449, -449, -449, 63, 63, - 63, 63, 63, 63, 63, 405, -449, -449, -449, 13, - -449, 391, 406, 416, 49, 411, 454, -449, 63, 63, - 63, 63, 63, 63, 63, 63, -449, -449, -449, 63, - 63, 63, 63, 63, 63, 63, 415, -449, 63, -449, - -449, 418, 427, -449, 413, -449, 419, 33, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 264, -449, 420, 421, 423, -449, -449, 425, - 33, 426, 121, 63, 63, 63, 63, 63, 63, 422, - 437, 63, 63, 63, 63, 458, 457, 465, 464, 320, - -449, 428, 438, -449, 183, -449, -449, 63, 63, 299, - 63, 63, 63, -449, -449, 63, 63, 63, 63, 439, - 49, 440, 473, 63, 63, -449, 320, 448, 442, 165, - -449, 165, 63, 63, 486, 490, 63, 63, 63, 49, - 2, 63, 63, -449, 445, -449, 444, 63, 63, -17, - -449, 446, 447, 448, -449, -10, 321, 326, 327, 330, - 222, -449, 88, -449, -449, -449, -449, 234, 450, 449, - 459, 352, 494, 63, 63, 460, 461, -449, 63, 110, - -449, -449, 462, 463, 466, -449, -449, 510, -449, -449, - 467, 468, 469, 478, -10, -449, 63, 63, 63, 63, - 63, 63, 63, 63, -449, -449, -449, -449, -449, -449, - -449, 479, 514, 383, 63, 63, -449, -449, 49, 480, - 519, -449, -449, -449, 529, 530, 531, 538, -449, -449, - 63, 63, 63, 63, 63, 63, 63, 63, -449, 493, - 495, 544, 502, 503, 506, -449, 505, 320, 507, 554, - 556, 557, 63, 63, 63, 63, 63, 63, 63, 63, - -449, -449, 515, -449, -449, -449, -449, 516, 518, 520, - 521, 562, 63, 63, 63, 63, 63, 63, 63, 63, - -449, -449, -449, -449, -449, 522, 63, 63, 63, 63, - 63, 63, 63, 63, 539, -449, 525, 524, 63, 63, - 63, 63, 63, 63, 526, 527, 539, -449, -449, -449, - 567, 574, 63, 63, 63, 63, 576, -449, -449, 577, - 578, 579, 580, 535, 534, 536, 49, 585, 586, 587, - -449, -449, -449, 542, 537, 49, 591, -449, -449, 545, - 546, -449, -449 -}; - - /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. - Performed when YYTABLE does not specify something else to do. Zero - means the default is an error. */ -static const yytype_uint8 yydefact[] = -{ - 0, 5, 0, 2, 16, 0, 3, 0, 4, 0, - 1, 0, 0, 0, 9, 111, 112, 113, 114, 115, - 60, 0, 0, 0, 11, 0, 51, 0, 0, 53, - 61, 62, 63, 64, 65, 56, 57, 0, 15, 164, - 171, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 52, 0, 55, 59, 0, 0, 165, 0, 0, - 0, 0, 0, 29, 21, 22, 23, 162, 163, 0, - 0, 0, 0, 203, 204, 205, 0, 0, 0, 0, - 0, 169, 170, 0, 0, 0, 166, 172, 173, 17, - 0, 0, 0, 0, 0, 30, 0, 0, 0, 202, - 206, 207, 208, 209, 210, 211, 212, 213, 214, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, - 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, - 201, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 34, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 200, 167, 168, 0, 0, 20, 19, 0, 0, 0, - 0, 0, 0, 0, 43, 35, 36, 37, 0, 0, - 0, 0, 73, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 24, 0, 0, 31, 0, 0, 0, - 45, 0, 0, 0, 0, 76, 0, 70, 0, 0, - 0, 0, 0, 0, 0, 26, 25, 28, 27, 33, - 0, 0, 0, 48, 0, 0, 0, 116, 0, 0, - 0, 0, 0, 0, 75, 77, 0, 79, 80, 81, - 82, 83, 84, 88, 87, 86, 91, 0, 69, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 13, 0, 0, 0, 139, 0, 0, 0, 0, 0, - 0, 0, 0, 74, 78, 90, 0, 68, 0, 71, - 72, 175, 174, 0, 41, 42, 0, 0, 0, 0, - 12, 0, 204, 0, 0, 0, 0, 0, 0, 0, - 139, 126, 0, 128, 129, 130, 131, 132, 0, 0, - 0, 0, 0, 0, 0, 0, 66, 67, 38, 0, - 44, 0, 0, 177, 0, 0, 0, 118, 0, 0, - 0, 0, 0, 0, 0, 0, 117, 127, 140, 0, - 0, 0, 0, 0, 0, 0, 0, 39, 0, 47, - 46, 0, 191, 176, 0, 120, 0, 139, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 101, 0, 0, 0, 7, 190, 0, - 139, 0, 139, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 107, - 40, 0, 0, 124, 139, 122, 119, 0, 0, 0, - 0, 0, 0, 137, 138, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 103, 107, 180, 0, 151, - 121, 151, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 85, 0, 98, 0, 0, 0, 0, - 108, 0, 0, 179, 181, 194, 0, 0, 0, 0, - 151, 141, 0, 144, 143, 146, 145, 151, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 94, 0, 0, - 100, 99, 0, 0, 0, 102, 104, 0, 178, 182, - 0, 0, 0, 0, 193, 195, 0, 0, 0, 0, - 0, 0, 0, 0, 125, 142, 152, 123, 133, 134, - 157, 0, 0, 0, 0, 0, 92, 93, 0, 204, - 0, 110, 109, 105, 0, 0, 0, 0, 192, 196, - 0, 0, 0, 0, 0, 0, 0, 0, 156, 0, - 0, 0, 0, 0, 0, 97, 0, 107, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 155, 161, 0, 135, 136, 95, 96, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 160, 106, 183, 197, 198, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 186, 199, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 185, 187, 147, 148, - 0, 0, 0, 0, 0, 0, 0, 184, 188, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 149, 150, 189, 0, 0, 0, 0, 153, 154, 0, - 0, 158, 159 -}; - - /* YYPGOTO[NTERM-NUM]. */ -static const yytype_int16 yypgoto[] = -{ - -449, -449, -449, -449, -449, -449, -449, -449, 336, -449, - -449, -449, -449, -449, -449, -449, -449, -449, -449, -449, - -449, -449, -449, -449, -449, -449, 309, -449, 581, -449, - -449, -449, -449, -449, -449, -449, -449, -449, -449, -449, - -449, -449, 365, -449, -449, -449, -449, -449, -449, -449, - -449, -449, -449, -449, -449, -449, -449, -449, -423, -449, - 573, -449, -449, -449, -449, -449, -449, -449, -449, -449, - -449, -339, -292, -449, 171, -448, -449, -449, -449, -449, - -449, -449, -449, -449, -449, -449, -190, -449, 565, -449, - 548, -449, -449, -449, -449, -449, -449, -449, 152, -449, - -449, -449, 1, -449, -449, -449, -449, 114, -231, -449, - -47, -48 -}; - - /* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int16 yydefgoto[] = -{ - -1, 2, 3, 4, 5, 6, 7, 289, 8, 9, - 12, 43, 63, 64, 65, 66, 95, 126, 149, 174, - 175, 176, 177, 200, 223, 260, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 205, - 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, - 243, 244, 245, 246, 399, 449, 486, 547, 425, 426, - 14, 15, 264, 16, 357, 17, 380, 18, 431, 19, - 429, 300, 301, 302, 460, 461, 462, 463, 464, 303, - 304, 305, 465, 466, 306, 307, 69, 38, 39, 40, - 83, 58, 87, 88, 352, 353, 452, 453, 454, 594, - 605, 606, 607, 377, 378, 493, 494, 495, 53, 131, - 75, 76 -}; - - /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule whose - number is the opposite. If YYTABLE_NINF, syntax error. */ -static const yytype_int16 yytable[] = -{ - 77, 78, 79, 450, 192, 275, 476, 85, 337, 73, - 74, 11, 505, 484, 73, 74, 73, 74, 382, 505, - 44, 251, 45, -50, 20, 490, 491, 492, 109, 110, - 111, 112, 21, 22, 23, 114, 115, 485, 86, 10, - -58, 404, 118, 120, 121, 122, 47, 13, 48, 295, - 129, 296, 297, 67, 193, 68, 477, 276, 298, 299, - 119, 132, 133, 318, -54, 347, 73, 74, 139, 140, - 141, 338, 142, 143, 144, 145, 146, 49, 37, 50, - 152, 153, 315, 41, 155, 157, 158, 159, 81, 82, - 337, 163, 164, 73, 292, 167, 168, 169, 170, 55, - 171, 56, 178, 179, 180, 42, 60, 183, 61, 186, - 187, 188, 337, 73, 519, 189, 190, 70, 295, 71, - 296, 297, 194, 195, 567, 197, 46, 298, 299, 52, - 201, 202, 203, 59, 354, 206, 62, 295, 210, 296, - 297, 213, 214, 92, 72, 93, 298, 299, 80, 90, - 220, -10, 1, 224, 225, 226, 336, 89, -6, -6, - -10, -10, -10, 91, 96, 253, 254, 97, -8, -49, - 20, 94, 255, -14, 98, 406, 261, 262, 21, 22, - 23, 456, 99, 457, 458, 116, -58, 117, 73, 74, - 459, 151, -10, 113, 125, -50, 20, 127, 128, 295, - -49, 296, 297, -49, 21, 22, 23, 283, 298, 299, - -54, 123, -58, 124, 291, 293, 130, 308, 309, 310, - 311, 312, 313, 314, 73, 74, -50, 156, 134, -50, - 444, 506, 256, 135, 257, 319, -54, 430, 456, 136, - 457, 458, 73, 74, 324, 185, 326, 459, 137, 475, - 456, 138, 457, 458, 73, 74, 265, 209, 266, 459, - 339, 340, 341, 342, 343, 344, 345, 73, 74, 147, - 397, 348, 228, 229, 230, 231, 504, 267, 150, 268, - 358, 359, 360, 361, 362, 363, 364, 365, 507, 232, - 154, 366, 367, 368, 369, 370, 148, 371, 372, 160, - 374, -89, 73, 74, 270, 434, 271, 287, 161, 288, - 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, - 393, 394, 395, 162, 396, 398, 165, 328, 544, 329, - 332, 334, 333, 335, 172, 407, 408, 409, 410, 411, - 412, 166, 173, 415, 416, 417, 418, 100, 101, 102, - 103, 104, 105, 106, 107, 108, 511, 181, 512, 432, - 433, 435, 436, 437, 438, 182, 184, 439, 440, 441, - 442, 423, 496, 424, 497, 447, 448, 498, 500, 499, - 501, 502, 191, 503, 468, 469, 196, 540, 472, 541, - 473, 474, 198, 199, 478, 479, 204, 207, 208, 482, - 483, 211, 212, 215, 216, 247, 217, 222, 219, 218, - 221, 227, 249, 248, 252, 250, 258, 259, 263, 269, - 272, 278, 273, 277, 280, 279, 514, 515, 281, 282, - 286, 518, 520, 284, -14, 285, 633, 316, 294, 321, - 317, 320, 322, 349, 325, 639, 327, 351, 530, 531, - 532, 533, 534, 535, 536, 537, 330, 331, 356, 346, - 350, 376, 419, 420, 355, 379, 542, 543, 373, 421, - 422, 375, 400, 381, 413, 401, 402, 446, 403, 405, - 451, 427, 552, 553, 554, 555, 556, 557, 558, 559, - 470, 414, 428, 443, 445, 455, 471, 480, 481, 487, - 513, 488, 508, 509, 572, 573, 574, 575, 576, 577, - 578, 579, 516, 510, 521, 517, 524, 522, 539, 523, - 525, 526, 527, 546, 586, 587, 588, 589, 590, 591, - 592, 593, 528, 538, 545, 548, 549, 550, 596, 597, - 598, 599, 600, 601, 551, 602, 603, 560, 562, 561, - 610, 611, 612, 613, 563, 614, 615, 564, 565, 566, - 569, 568, 570, 571, 621, 622, 623, 624, 585, 580, - 581, 582, 604, 619, 583, 584, 595, 608, 609, 616, - 620, 617, 625, 626, 627, 628, 629, 630, 631, 634, - 632, 638, 635, 636, 637, 640, 290, 641, 323, 274, - 642, 54, 467, 57, 84, 489, 51, 618, 529 -}; - -static const yytype_uint16 yycheck[] = -{ - 48, 49, 50, 426, 4, 236, 4, 23, 300, 3, - 4, 7, 460, 30, 3, 4, 3, 4, 357, 467, - 51, 211, 53, 0, 1, 35, 36, 37, 76, 77, - 78, 79, 9, 10, 11, 83, 84, 54, 54, 0, - 17, 380, 90, 91, 92, 93, 51, 17, 53, 16, - 98, 18, 19, 4, 54, 6, 54, 247, 25, 26, - 54, 109, 110, 52, 41, 52, 3, 4, 116, 117, - 118, 302, 120, 121, 122, 123, 124, 51, 22, 53, - 128, 129, 272, 51, 132, 133, 134, 135, 4, 5, - 382, 139, 140, 3, 4, 143, 144, 145, 146, 51, - 147, 53, 150, 151, 152, 8, 51, 155, 53, 157, - 158, 159, 404, 3, 4, 163, 164, 4, 16, 6, - 18, 19, 169, 170, 547, 172, 53, 25, 26, 41, - 178, 179, 180, 4, 324, 183, 20, 16, 186, 18, - 19, 189, 190, 51, 4, 53, 25, 26, 53, 6, - 198, 0, 1, 201, 202, 203, 54, 52, 7, 8, - 9, 10, 11, 6, 6, 213, 214, 6, 17, 0, - 1, 24, 220, 22, 6, 54, 224, 225, 9, 10, - 11, 16, 6, 18, 19, 51, 17, 53, 3, 4, - 25, 6, 41, 6, 38, 0, 1, 6, 6, 16, - 31, 18, 19, 34, 9, 10, 11, 255, 25, 26, - 41, 51, 17, 53, 261, 262, 6, 265, 266, 267, - 268, 269, 270, 271, 3, 4, 31, 6, 4, 34, - 420, 462, 4, 4, 6, 283, 41, 54, 16, 6, - 18, 19, 3, 4, 291, 6, 293, 25, 52, 439, - 16, 54, 18, 19, 3, 4, 51, 6, 53, 25, - 308, 309, 310, 311, 312, 313, 314, 3, 4, 51, - 6, 319, 12, 13, 14, 15, 54, 51, 6, 53, - 328, 329, 330, 331, 332, 333, 334, 335, 54, 29, - 54, 339, 340, 341, 342, 343, 39, 344, 345, 54, - 348, 41, 3, 4, 51, 6, 53, 51, 53, 53, - 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, - 368, 369, 370, 53, 371, 372, 52, 51, 518, 53, - 51, 51, 53, 53, 51, 383, 384, 385, 386, 387, - 388, 54, 40, 391, 392, 393, 394, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 4, 4, 6, 407, - 408, 409, 410, 411, 412, 53, 4, 415, 416, 417, - 418, 51, 51, 53, 53, 423, 424, 51, 51, 53, - 53, 51, 4, 53, 432, 433, 52, 4, 436, 6, - 437, 438, 51, 21, 441, 442, 54, 54, 4, 447, - 448, 4, 4, 52, 54, 6, 52, 27, 52, 54, - 53, 53, 4, 54, 4, 6, 53, 28, 4, 53, - 53, 4, 54, 54, 54, 52, 473, 474, 52, 54, - 6, 478, 479, 54, 22, 54, 626, 52, 54, 6, - 54, 54, 6, 52, 54, 635, 53, 31, 496, 497, - 498, 499, 500, 501, 502, 503, 53, 53, 4, 54, - 54, 34, 4, 6, 53, 52, 514, 515, 53, 4, - 6, 53, 52, 54, 52, 54, 53, 4, 53, 53, - 32, 53, 530, 531, 532, 533, 534, 535, 536, 537, - 4, 54, 54, 54, 54, 53, 6, 52, 54, 53, - 6, 54, 52, 54, 552, 553, 554, 555, 556, 557, - 558, 559, 52, 54, 52, 54, 6, 54, 4, 53, - 53, 53, 53, 4, 572, 573, 574, 575, 576, 577, - 578, 579, 54, 54, 54, 6, 6, 6, 586, 587, - 588, 589, 590, 591, 6, 592, 593, 54, 4, 54, - 598, 599, 600, 601, 52, 602, 603, 54, 52, 54, - 6, 54, 6, 6, 612, 613, 614, 615, 6, 54, - 54, 53, 33, 6, 54, 54, 54, 52, 54, 53, - 6, 54, 6, 6, 6, 6, 6, 52, 54, 4, - 54, 54, 6, 6, 52, 4, 260, 52, 289, 234, - 54, 28, 431, 38, 56, 453, 25, 606, 494 -}; - - /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = -{ - 0, 1, 56, 57, 58, 59, 60, 61, 63, 64, - 0, 7, 65, 17, 115, 116, 118, 120, 122, 124, - 1, 9, 10, 11, 81, 82, 83, 84, 85, 86, - 87, 88, 89, 90, 91, 92, 93, 22, 142, 143, - 144, 51, 8, 66, 51, 53, 53, 51, 53, 51, - 53, 83, 41, 163, 115, 51, 53, 143, 146, 4, - 51, 53, 20, 67, 68, 69, 70, 4, 6, 141, - 4, 6, 4, 3, 4, 165, 166, 166, 166, 166, - 53, 4, 5, 145, 145, 23, 54, 147, 148, 52, - 6, 6, 51, 53, 24, 71, 6, 6, 6, 6, - 42, 43, 44, 45, 46, 47, 48, 49, 50, 166, - 166, 166, 166, 6, 166, 166, 51, 53, 166, 54, - 166, 166, 166, 51, 53, 38, 72, 6, 6, 166, - 6, 164, 166, 166, 4, 4, 6, 52, 54, 166, - 166, 166, 166, 166, 166, 166, 166, 51, 39, 73, - 6, 6, 166, 166, 54, 166, 6, 166, 166, 166, - 54, 53, 53, 166, 166, 52, 54, 166, 166, 166, - 166, 165, 51, 40, 74, 75, 76, 77, 166, 166, - 166, 4, 53, 166, 4, 6, 166, 166, 166, 166, - 166, 4, 4, 54, 165, 165, 52, 165, 51, 21, - 78, 166, 166, 166, 54, 94, 166, 54, 4, 6, - 166, 4, 4, 166, 166, 52, 54, 52, 54, 52, - 166, 53, 27, 79, 166, 166, 166, 53, 12, 13, - 14, 15, 29, 95, 96, 97, 98, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 6, 54, 4, - 6, 141, 4, 166, 166, 166, 4, 6, 53, 28, - 80, 166, 166, 4, 117, 51, 53, 51, 53, 53, - 51, 53, 53, 54, 97, 163, 141, 54, 4, 52, - 54, 52, 54, 166, 54, 54, 6, 51, 53, 62, - 63, 165, 4, 165, 54, 16, 18, 19, 25, 26, - 126, 127, 128, 134, 135, 136, 139, 140, 166, 166, - 166, 166, 166, 166, 166, 141, 52, 54, 52, 166, - 54, 6, 6, 81, 165, 54, 165, 53, 51, 53, - 53, 53, 51, 53, 51, 53, 54, 127, 163, 166, - 166, 166, 166, 166, 166, 166, 54, 52, 166, 52, - 54, 31, 149, 150, 141, 53, 4, 119, 166, 166, - 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, - 166, 165, 165, 53, 166, 53, 34, 158, 159, 52, - 121, 54, 126, 166, 166, 166, 166, 166, 166, 166, - 166, 166, 166, 166, 166, 166, 165, 6, 165, 109, - 52, 54, 53, 53, 126, 53, 54, 166, 166, 166, - 166, 166, 166, 52, 54, 166, 166, 166, 166, 4, - 6, 4, 6, 51, 53, 113, 114, 53, 54, 125, - 54, 123, 166, 166, 6, 166, 166, 166, 166, 166, - 166, 166, 166, 54, 141, 54, 4, 166, 166, 110, - 113, 32, 151, 152, 153, 53, 16, 18, 19, 25, - 129, 130, 131, 132, 133, 137, 138, 129, 166, 166, - 4, 6, 166, 165, 165, 141, 4, 54, 165, 165, - 52, 54, 166, 166, 30, 54, 111, 53, 54, 153, - 35, 36, 37, 160, 161, 162, 51, 53, 51, 53, - 51, 53, 51, 53, 54, 130, 163, 54, 52, 54, - 54, 4, 6, 6, 165, 165, 52, 54, 165, 4, - 165, 52, 54, 53, 6, 53, 53, 53, 54, 162, - 166, 166, 166, 166, 166, 166, 166, 166, 54, 4, - 4, 6, 166, 166, 141, 54, 4, 112, 6, 6, - 6, 6, 166, 166, 166, 166, 166, 166, 166, 166, - 54, 54, 4, 52, 54, 52, 54, 113, 54, 6, - 6, 6, 166, 166, 166, 166, 166, 166, 166, 166, - 54, 54, 53, 54, 54, 6, 166, 166, 166, 166, - 166, 166, 166, 166, 154, 54, 166, 166, 166, 166, - 166, 166, 165, 165, 33, 155, 156, 157, 52, 54, - 166, 166, 166, 166, 165, 165, 53, 54, 157, 6, - 6, 166, 166, 166, 166, 6, 6, 6, 6, 6, - 52, 54, 54, 141, 4, 6, 6, 52, 54, 141, - 4, 52, 54 -}; - - /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = -{ - 0, 55, 56, 56, 56, 56, 58, 57, 59, 57, - 61, 60, 62, 62, 64, 63, 65, 65, 66, 66, - 66, 67, 67, 67, 68, 69, 70, 71, 71, 71, - 72, 72, 73, 73, 74, 74, 74, 74, 75, 76, - 77, 78, 78, 78, 79, 79, 80, 80, 80, 81, - 81, 82, 82, 83, 84, 83, 83, 83, 85, 83, - 83, 86, 86, 86, 86, 86, 87, 88, 89, 90, - 91, 92, 92, 94, 93, 95, 95, 96, 96, 97, - 97, 97, 97, 97, 97, 97, 97, 97, 97, 98, - 97, 97, 99, 100, 101, 102, 103, 104, 105, 106, - 107, 109, 108, 110, 110, 112, 111, 113, 113, 114, - 114, 115, 115, 115, 115, 115, 117, 116, 119, 118, - 121, 120, 123, 122, 125, 124, 126, 126, 127, 127, - 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, - 127, 129, 129, 130, 130, 130, 130, 130, 130, 130, - 130, 131, 130, 132, 133, 134, 135, 136, 137, 138, - 139, 140, 141, 141, 142, 142, 143, 144, 144, 145, - 145, 146, 146, 146, 147, 148, 149, 149, 150, 151, - 151, 152, 152, 154, 153, 155, 155, 156, 156, 157, - 158, 158, 159, 160, 160, 161, 161, 162, 162, 162, - 163, 164, 164, 165, 165, 166, 166, 166, 166, 166, - 166, 166, 166, 166, 166 -}; - - /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 1, 1, 1, 1, 0, 15, 0, 2, - 0, 2, 1, 0, 0, 2, 0, 4, 4, 6, - 6, 1, 1, 1, 6, 7, 7, 6, 6, 0, - 0, 4, 0, 4, 0, 1, 1, 1, 6, 7, - 9, 4, 4, 0, 4, 0, 4, 4, 0, 1, - 0, 1, 2, 1, 0, 2, 1, 1, 0, 2, - 1, 1, 1, 1, 1, 1, 11, 11, 10, 9, - 8, 10, 10, 0, 10, 1, 0, 1, 2, 1, - 1, 1, 1, 1, 1, 8, 1, 1, 1, 0, - 2, 1, 10, 10, 9, 12, 12, 11, 8, 9, - 9, 0, 9, 0, 2, 0, 5, 0, 2, 4, - 4, 1, 1, 1, 1, 1, 0, 12, 0, 15, - 0, 16, 0, 18, 0, 18, 1, 2, 1, 1, - 1, 1, 1, 8, 8, 10, 10, 5, 5, 0, - 2, 1, 2, 1, 1, 1, 1, 8, 8, 10, - 10, 0, 2, 12, 12, 10, 9, 8, 13, 13, - 11, 10, 1, 1, 1, 2, 3, 6, 6, 1, - 1, 0, 2, 2, 8, 8, 1, 0, 6, 1, - 0, 1, 2, 0, 9, 1, 0, 1, 2, 4, - 1, 0, 6, 1, 0, 1, 2, 5, 5, 6, - 5, 1, 0, 1, 1, 1, 2, 2, 2, 2, - 2, 2, 2, 2, 2 -}; - - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) - -/* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 - - - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (0) - -/* This macro is provided for backward compatibility. */ -#ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -#endif - - -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) - - -/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ - -static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -{ - FILE *yyo = yyoutput; - YYUSE (yyo); - if (!yyvaluep) - return; -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - YYUSE (yytype); -} - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -{ - YYFPRINTF (yyoutput, "%s %s (", - yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); - - yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); -} - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ - -static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) -{ - YYFPRINTF (stderr, "Stack now"); - for (; yybottom <= yytop; yybottom++) - { - int yybot = *yybottom; - YYFPRINTF (stderr, " %d", yybot); - } - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (0) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -static void -yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) -{ - unsigned long int yylno = yyrline[yyrule]; - int yynrhs = yyr2[yyrule]; - int yyi; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); - /* The symbols being reduced. */ - for (yyi = 0; yyi < yynrhs; yyi++) - { - YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, - yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); - YYFPRINTF (stderr, "\n"); - } -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyssp, yyvsp, Rule); \ -} while (0) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -yystrlen (const char *yystr) -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif - -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -yystpcpy (char *yydest, const char *yysrc) -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP. - - Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return 2 if the - required number of bytes is too large to store. */ -static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, - yytype_int16 *yyssp, int yytoken) -{ - YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); - YYSIZE_T yysize = yysize0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - /* Internationalized format string. */ - const char *yyformat = YY_NULLPTR; - /* Arguments of yyformat. */ - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Number of reported tokens (one for the "unexpected", one per - "expected"). */ - int yycount = 0; - - /* There are many possibilities here to consider: - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yychar) is if - this state is a consistent state with a default action. Thus, - detecting the absence of a lookahead is sufficient to determine - that there is no unexpected or expected token to report. In that - case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is a - consistent state with a default action. There might have been a - previous inconsistent state, consistent state with a non-default - action, or user semantic action that manipulated yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state merging - (from LALR or IELR) and default reductions corrupt the expected - token list. However, the list is correct for canonical LR with - one exception: it will still contain any token that will not be - accepted due to an error action in a later state. - */ - if (yytoken != YYEMPTY) - { - int yyn = yypact[*yyssp]; - yyarg[yycount++] = yytname[yytoken]; - if (!yypact_value_is_default (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yyx; - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yytable_value_is_error (yytable[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - break; - } - yyarg[yycount++] = yytname[yyx]; - { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - } - } - } - - switch (yycount) - { -# define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -# undef YYCASE_ - } - - { - YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - - if (*yymsg_alloc < yysize) - { - *yymsg_alloc = 2 * yysize; - if (! (yysize <= *yymsg_alloc - && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) - *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return 1; - } - - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - { - char *yyp = *yymsg; - int yyi = 0; - while ((*yyp = *yyformat) != '\0') - if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyformat += 2; - } - else - { - yyp++; - yyformat++; - } - } - return 0; -} -#endif /* YYERROR_VERBOSE */ - -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) -{ - YYUSE (yyvaluep); - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - YYUSE (yytype); - YY_IGNORE_MAYBE_UNINITIALIZED_END -} - - - - -/* The lookahead symbol. */ -int yychar; - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; -/* Number of syntax errors so far. */ -int yynerrs; - - -/*----------. -| yyparse. | -`----------*/ - -int -yyparse (void) -{ - int yystate; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - - /* The stacks and their tools: - 'yyss': related to states. - 'yyvs': related to semantic values. - - Refer to the stacks through separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; - - YYSIZE_T yystacksize; - - int yyn; - int yyresult; - /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) - - /* The number of symbols on the RHS of the reduced rule. - Keep to zero when no symbol should be popped. */ - int yylen = 0; - - yyssp = yyss = yyssa; - yyvsp = yyvs = yyvsa; - yystacksize = YYINITDEPTH; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. So pushing a state here evens the stacks. */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - if (yystate == YYFINAL) - YYACCEPT; - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - - /* Do appropriate processing given the current state. Read a - lookahead token if we need one and don't already have one. */ - - /* First try to decide what to do without reference to lookahead token. */ - yyn = yypact[yystate]; - if (yypact_value_is_default (yyn)) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = yylex (); - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yytable_value_is_error (yyn)) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - /* Shift the lookahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token. */ - yychar = YYEMPTY; - - yystate = yyn; - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - *++yyvsp = yylval; - YY_IGNORE_MAYBE_UNINITIALIZED_END - - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - '$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 5: -#line 141 "parse_y.y" /* yacc.c:1646 */ - { YYABORT; } -#line 1779 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 6: -#line 165 "parse_y.y" /* yacc.c:1646 */ - { - /* reset flags for 'used layers'; - * init font and data pointers - */ - int i; - - if (!yyPCB) - { - Message("illegal fileformat\n"); - YYABORT; - } - for (i = 0; i < MAX_LAYER + 2; i++) - LayerFlag[i] = false; - yyFont = &yyPCB->Font; - yyData = yyPCB->Data; - yyData->pcb = yyPCB; - yyData->LayerN = 0; - yyPCB->NetlistPatches = yyPCB->NetlistPatchLast = NULL; - layer_group_string = NULL; - } -#line 1804 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 7: -#line 199 "parse_y.y" /* yacc.c:1646 */ - { - PCBTypePtr pcb_save = PCB; - - if (layer_group_string == NULL) - layer_group_string = strdup(conf_core.design.groups); - CreateNewPCBPost (yyPCB, 0); - if (ParseGroupString(layer_group_string, &yyPCB->LayerGroups, yyData->LayerN)) - { - Message("illegal layer-group string\n"); - YYABORT; - } - /* initialize the polygon clipping now since - * we didn't know the layer grouping before. - */ - free(layer_group_string); - PCB = yyPCB; - ALLPOLYGON_LOOP (yyData); - { - InitClip (yyData, layer, polygon); - } - ENDALL_LOOP; - PCB = pcb_save; - } -#line 1832 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 8: -#line 223 "parse_y.y" /* yacc.c:1646 */ - { PreLoadElementPCB (); - layer_group_string = NULL; } -#line 1839 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 9: -#line 226 "parse_y.y" /* yacc.c:1646 */ - { LayerFlag[0] = true; - LayerFlag[1] = true; - yyData->LayerN = 2; - PostLoadElementPCB (); - } -#line 1849 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 10: -#line 234 "parse_y.y" /* yacc.c:1646 */ - { - /* reset flags for 'used layers'; - * init font and data pointers - */ - int i; - - if (!yyData || !yyFont) - { - Message("illegal fileformat\n"); - YYABORT; - } - for (i = 0; i < MAX_LAYER + 2; i++) - LayerFlag[i] = false; - yyData->LayerN = 0; - } -#line 1869 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 14: -#line 259 "parse_y.y" /* yacc.c:1646 */ - { - /* mark all symbols invalid */ - int i; - - if (!yyFont) - { - Message("illegal fileformat\n"); - YYABORT; - } - yyFont->Valid = false; - for (i = 0; i <= MAX_FONTPOSITION; i++) - free (yyFont->Symbol[i].Line); - bzero(yyFont->Symbol, sizeof(yyFont->Symbol)); - } -#line 1888 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 15: -#line 274 "parse_y.y" /* yacc.c:1646 */ - { - yyFont->Valid = true; - SetFontInfo(yyFont); - } -#line 1897 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 17: -#line 302 "parse_y.y" /* yacc.c:1646 */ - { - if (check_file_version ((yyvsp[-1].integer)) != 0) - { - YYABORT; - } -} -#line 1908 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 18: -#line 332 "parse_y.y" /* yacc.c:1646 */ - { - yyPCB->Name = (yyvsp[-1].string); - yyPCB->MaxWidth = MAX_COORD; - yyPCB->MaxHeight = MAX_COORD; - } -#line 1918 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 19: -#line 338 "parse_y.y" /* yacc.c:1646 */ - { - yyPCB->Name = (yyvsp[-3].string); - yyPCB->MaxWidth = OU ((yyvsp[-2].measure)); - yyPCB->MaxHeight = OU ((yyvsp[-1].measure)); - } -#line 1928 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 20: -#line 344 "parse_y.y" /* yacc.c:1646 */ - { - yyPCB->Name = (yyvsp[-3].string); - yyPCB->MaxWidth = NU ((yyvsp[-2].measure)); - yyPCB->MaxHeight = NU ((yyvsp[-1].measure)); - } -#line 1938 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 24: -#line 378 "parse_y.y" /* yacc.c:1646 */ - { - yyPCB->Grid = OU ((yyvsp[-3].measure)); - yyPCB->GridOffsetX = OU ((yyvsp[-2].measure)); - yyPCB->GridOffsetY = OU ((yyvsp[-1].measure)); - } -#line 1948 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 25: -#line 386 "parse_y.y" /* yacc.c:1646 */ - { - yyPCB->Grid = OU ((yyvsp[-4].measure)); - yyPCB->GridOffsetX = OU ((yyvsp[-3].measure)); - yyPCB->GridOffsetY = OU ((yyvsp[-2].measure)); - if ((yyvsp[-1].integer)) - conf_core.editor.draw_grid = true; - else - conf_core.editor.draw_grid = false; - } -#line 1962 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 26: -#line 399 "parse_y.y" /* yacc.c:1646 */ - { - yyPCB->Grid = NU ((yyvsp[-4].measure)); - yyPCB->GridOffsetX = NU ((yyvsp[-3].measure)); - yyPCB->GridOffsetY = NU ((yyvsp[-2].measure)); - if ((yyvsp[-1].integer)) - conf_core.editor.draw_grid = true; - else - conf_core.editor.draw_grid = false; - } -#line 1976 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 27: -#line 431 "parse_y.y" /* yacc.c:1646 */ - { - yyPCB->CursorX = OU ((yyvsp[-3].measure)); - yyPCB->CursorY = OU ((yyvsp[-2].measure)); - yyPCB->Zoom = (yyvsp[-1].number)*2; - } -#line 1986 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 28: -#line 437 "parse_y.y" /* yacc.c:1646 */ - { - yyPCB->CursorX = NU ((yyvsp[-3].measure)); - yyPCB->CursorY = NU ((yyvsp[-2].measure)); - yyPCB->Zoom = (yyvsp[-1].number); - } -#line 1996 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 31: -#line 461 "parse_y.y" /* yacc.c:1646 */ - { - /* Read in cmil^2 for now; in future this should be a noop. */ - yyPCB->IsleArea = MIL_TO_COORD (MIL_TO_COORD ((yyvsp[-1].number)) / 100.0) / 100.0; - } -#line 2005 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 33: -#line 488 "parse_y.y" /* yacc.c:1646 */ - { - yyPCB->ThermScale = (yyvsp[-1].number); - } -#line 2013 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 38: -#line 527 "parse_y.y" /* yacc.c:1646 */ - { - yyPCB->Bloat = NU ((yyvsp[-3].measure)); - yyPCB->Shrink = NU ((yyvsp[-2].measure)); - yyPCB->minWid = NU ((yyvsp[-1].measure)); - yyPCB->minRing = NU ((yyvsp[-1].measure)); - } -#line 2024 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 39: -#line 537 "parse_y.y" /* yacc.c:1646 */ - { - yyPCB->Bloat = NU ((yyvsp[-4].measure)); - yyPCB->Shrink = NU ((yyvsp[-3].measure)); - yyPCB->minWid = NU ((yyvsp[-2].measure)); - yyPCB->minSlk = NU ((yyvsp[-1].measure)); - yyPCB->minRing = NU ((yyvsp[-2].measure)); - } -#line 2036 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 40: -#line 548 "parse_y.y" /* yacc.c:1646 */ - { - yyPCB->Bloat = NU ((yyvsp[-6].measure)); - yyPCB->Shrink = NU ((yyvsp[-5].measure)); - yyPCB->minWid = NU ((yyvsp[-4].measure)); - yyPCB->minSlk = NU ((yyvsp[-3].measure)); - yyPCB->minDrill = NU ((yyvsp[-2].measure)); - yyPCB->minRing = NU ((yyvsp[-1].measure)); - } -#line 2049 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 41: -#line 575 "parse_y.y" /* yacc.c:1646 */ - { - yyPCB->Flags = MakeFlags ((yyvsp[-1].integer) & PCB_FLAGS); - } -#line 2057 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 42: -#line 579 "parse_y.y" /* yacc.c:1646 */ - { - yyPCB->Flags = string_to_pcbflags ((yyvsp[-1].string), yyerror); - free((yyvsp[-1].string)); - } -#line 2066 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 44: -#line 612 "parse_y.y" /* yacc.c:1646 */ - { - layer_group_string = (yyvsp[-1].string); - } -#line 2074 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 46: -#line 660 "parse_y.y" /* yacc.c:1646 */ - { - if (ParseRouteString((yyvsp[-1].string), &yyPCB->RouteStyle[0], "mil")) - { - Message("illegal route-style string\n"); - YYABORT; - } - free((yyvsp[-1].string)); - } -#line 2087 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 47: -#line 669 "parse_y.y" /* yacc.c:1646 */ - { - if (ParseRouteString((yyvsp[-1].string), &yyPCB->RouteStyle[0], "cmil")) - { - Message("illegal route-style string\n"); - YYABORT; - } - free((yyvsp[-1].string)); - } -#line 2100 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 54: -#line 692 "parse_y.y" /* yacc.c:1646 */ - { attr_list = & yyPCB->Attributes; } -#line 2106 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 58: -#line 696 "parse_y.y" /* yacc.c:1646 */ - { - /* clear pointer to force memory allocation by - * the appropriate subroutine - */ - yyElement = NULL; - } -#line 2117 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 60: -#line 703 "parse_y.y" /* yacc.c:1646 */ - { YYABORT; } -#line 2123 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 66: -#line 748 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewVia(yyData, NU ((yyvsp[-8].measure)), NU ((yyvsp[-7].measure)), NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), - NU ((yyvsp[-3].measure)), (yyvsp[-2].string), (yyvsp[-1].flagtype)); - free ((yyvsp[-2].string)); - } -#line 2133 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 67: -#line 758 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewVia(yyData, OU ((yyvsp[-8].measure)), OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), (yyvsp[-2].string), - OldFlags((yyvsp[-1].integer))); - free ((yyvsp[-2].string)); - } -#line 2143 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 68: -#line 769 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewVia(yyData, OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), - OU ((yyvsp[-5].measure)) + OU((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), (yyvsp[-2].string), OldFlags((yyvsp[-1].integer))); - free ((yyvsp[-2].string)); - } -#line 2153 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 69: -#line 779 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewVia(yyData, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), 2*GROUNDPLANEFRAME, - OU((yyvsp[-4].measure)) + 2*MASKFRAME, OU ((yyvsp[-3].measure)), (yyvsp[-2].string), OldFlags((yyvsp[-1].integer))); - free ((yyvsp[-2].string)); - } -#line 2163 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 70: -#line 789 "parse_y.y" /* yacc.c:1646 */ - { - Coord hole = (OU((yyvsp[-3].measure)) * DEFAULT_DRILLINGHOLE); - - /* make sure that there's enough copper left */ - if (OU((yyvsp[-3].measure)) - hole < MIN_PINORVIACOPPER && - OU((yyvsp[-3].measure)) > MIN_PINORVIACOPPER) - hole = OU((yyvsp[-3].measure)) - MIN_PINORVIACOPPER; - - CreateNewVia(yyData, OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), 2*GROUNDPLANEFRAME, - OU((yyvsp[-3].measure)) + 2*MASKFRAME, hole, (yyvsp[-2].string), OldFlags((yyvsp[-1].integer))); - free ((yyvsp[-2].string)); - } -#line 2180 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 71: -#line 825 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewRat(yyData, NU ((yyvsp[-7].measure)), NU ((yyvsp[-6].measure)), NU ((yyvsp[-4].measure)), NU ((yyvsp[-3].measure)), (yyvsp[-5].integer), (yyvsp[-2].integer), - conf_core.appearance.rat_thickness, (yyvsp[-1].flagtype)); - } -#line 2189 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 72: -#line 830 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewRat(yyData, OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), (yyvsp[-5].integer), (yyvsp[-2].integer), - conf_core.appearance.rat_thickness, OldFlags((yyvsp[-1].integer))); - } -#line 2198 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 73: -#line 861 "parse_y.y" /* yacc.c:1646 */ - { - if ((yyvsp[-4].integer) <= 0 || (yyvsp[-4].integer) > MAX_LAYER + 2) - { - yyerror("Layernumber out of range"); - YYABORT; - } - if (LayerFlag[(yyvsp[-4].integer)-1]) - { - yyerror("Layernumber used twice"); - YYABORT; - } - Layer = &yyData->Layer[(yyvsp[-4].integer)-1]; - - /* memory for name is already allocated */ - if (Layer->Name != NULL) - free(Layer->Name); - Layer->Name = (yyvsp[-3].string); - LayerFlag[(yyvsp[-4].integer)-1] = true; - if (yyData->LayerN + 2 < (yyvsp[-4].integer)) - yyData->LayerN = (yyvsp[-4].integer) - 2; - if ((yyvsp[-2].string) != NULL) - free((yyvsp[-2].string)); - } -#line 2226 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 85: -#line 906 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewPolygonFromRectangle(Layer, - OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-5].measure)) + OU ((yyvsp[-3].measure)), OU ((yyvsp[-4].measure)) + OU ((yyvsp[-2].measure)), OldFlags((yyvsp[-1].integer))); - } -#line 2235 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 89: -#line 913 "parse_y.y" /* yacc.c:1646 */ - { attr_list = & Layer->Attributes; } -#line 2241 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 92: -#line 945 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewLineOnLayer(Layer, NU ((yyvsp[-7].measure)), NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), - NU ((yyvsp[-3].measure)), NU ((yyvsp[-2].measure)), (yyvsp[-1].flagtype)); - } -#line 2250 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 93: -#line 954 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewLineOnLayer(Layer, OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), - OU ((yyvsp[-3].measure)), OU ((yyvsp[-2].measure)), OldFlags((yyvsp[-1].integer))); - } -#line 2259 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 94: -#line 963 "parse_y.y" /* yacc.c:1646 */ - { - /* eliminate old-style rat-lines */ - if ((IV ((yyvsp[-1].measure)) & RATFLAG) == 0) - CreateNewLineOnLayer(Layer, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), OU ((yyvsp[-2].measure)), - 200*GROUNDPLANEFRAME, OldFlags(IV ((yyvsp[-1].measure)))); - } -#line 2270 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 95: -#line 1011 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewArcOnLayer(Layer, NU ((yyvsp[-9].measure)), NU ((yyvsp[-8].measure)), NU ((yyvsp[-7].measure)), NU ((yyvsp[-6].measure)), (yyvsp[-3].number), (yyvsp[-2].number), - NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), (yyvsp[-1].flagtype)); - } -#line 2279 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 96: -#line 1020 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewArcOnLayer(Layer, OU ((yyvsp[-9].measure)), OU ((yyvsp[-8].measure)), OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), (yyvsp[-3].number), (yyvsp[-2].number), - OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OldFlags((yyvsp[-1].integer))); - } -#line 2288 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 97: -#line 1029 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewArcOnLayer(Layer, OU ((yyvsp[-8].measure)), OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-6].measure)), IV ((yyvsp[-3].measure)), (yyvsp[-2].number), - OU ((yyvsp[-4].measure)), 200*GROUNDPLANEFRAME, OldFlags((yyvsp[-1].integer))); - } -#line 2297 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 98: -#line 1066 "parse_y.y" /* yacc.c:1646 */ - { - /* use a default scale of 100% */ - CreateNewText(Layer,yyFont,OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), (yyvsp[-3].number), 100, (yyvsp[-2].string), OldFlags((yyvsp[-1].integer))); - free ((yyvsp[-2].string)); - } -#line 2307 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 99: -#line 1076 "parse_y.y" /* yacc.c:1646 */ - { - if ((yyvsp[-1].integer) & ONSILKFLAG) - { - LayerTypePtr lay = &yyData->Layer[yyData->LayerN + - (((yyvsp[-1].integer) & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)]; - - CreateNewText(lay ,yyFont, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), (yyvsp[-4].number), (yyvsp[-3].number), (yyvsp[-2].string), - OldFlags((yyvsp[-1].integer))); - } - else - CreateNewText(Layer, yyFont, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), (yyvsp[-4].number), (yyvsp[-3].number), (yyvsp[-2].string), - OldFlags((yyvsp[-1].integer))); - free ((yyvsp[-2].string)); - } -#line 2326 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 100: -#line 1094 "parse_y.y" /* yacc.c:1646 */ - { - /* FIXME: shouldn't know about .f */ - /* I don't think this matters because anything with hi_format - * will have the silk on its own layer in the file rather - * than using the ONSILKFLAG and having it in a copper layer. - * Thus there is no need for anything besides the 'else' - * part of this code. - */ - if ((yyvsp[-1].flagtype).f & ONSILKFLAG) - { - LayerTypePtr lay = &yyData->Layer[yyData->LayerN + - (((yyvsp[-1].flagtype).f & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)]; - - CreateNewText(lay, yyFont, NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), (yyvsp[-4].number), (yyvsp[-3].number), (yyvsp[-2].string), (yyvsp[-1].flagtype)); - } - else - CreateNewText(Layer, yyFont, NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), (yyvsp[-4].number), (yyvsp[-3].number), (yyvsp[-2].string), (yyvsp[-1].flagtype)); - free ((yyvsp[-2].string)); - } -#line 2350 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 101: -#line 1143 "parse_y.y" /* yacc.c:1646 */ - { - Polygon = CreateNewPolygon(Layer, (yyvsp[-2].flagtype)); - } -#line 2358 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 102: -#line 1148 "parse_y.y" /* yacc.c:1646 */ - { - Cardinal contour, contour_start, contour_end; - bool bad_contour_found = false; - /* ignore junk */ - for (contour = 0; contour <= Polygon->HoleIndexN; contour++) - { - contour_start = (contour == 0) ? - 0 : Polygon->HoleIndex[contour - 1]; - contour_end = (contour == Polygon->HoleIndexN) ? - Polygon->PointN : - Polygon->HoleIndex[contour]; - if (contour_end - contour_start < 3) - bad_contour_found = true; - } - - if (bad_contour_found) - { - Message("WARNING parsing file '%s'\n" - " line: %i\n" - " description: 'ignored polygon (< 3 points in a contour)'\n", - yyfilename, yylineno); - DestroyObject(yyData, POLYGON_TYPE, Layer, Polygon, Polygon); - } - else - { - SetPolygonBoundingBox (Polygon); - if (!Layer->polygon_tree) - Layer->polygon_tree = r_create_tree (NULL, 0, 0); - r_insert_entry (Layer->polygon_tree, (BoxType *) Polygon, 0); - } - } -#line 2394 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 105: -#line 1188 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewHoleInPolygon (Polygon); - } -#line 2402 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 109: -#line 1202 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewPointInPolygon(Polygon, OU ((yyvsp[-2].measure)), OU ((yyvsp[-1].measure))); - } -#line 2410 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 110: -#line 1206 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewPointInPolygon(Polygon, NU ((yyvsp[-2].measure)), NU ((yyvsp[-1].measure))); - } -#line 2418 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 116: -#line 1277 "parse_y.y" /* yacc.c:1646 */ - { - yyElement = CreateNewElement(yyData, yyElement, yyFont, NoFlags(), - (yyvsp[-6].string), (yyvsp[-5].string), NULL, OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), (yyvsp[-2].integer), 100, NoFlags(), false); - free ((yyvsp[-6].string)); - free ((yyvsp[-5].string)); - pin_num = 1; - } -#line 2430 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 117: -#line 1285 "parse_y.y" /* yacc.c:1646 */ - { - SetElementBoundingBox(yyData, yyElement, yyFont); - } -#line 2438 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 118: -#line 1295 "parse_y.y" /* yacc.c:1646 */ - { - yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags((yyvsp[-9].integer)), - (yyvsp[-8].string), (yyvsp[-7].string), NULL, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), IV ((yyvsp[-4].measure)), IV ((yyvsp[-3].measure)), OldFlags((yyvsp[-2].integer)), false); - free ((yyvsp[-8].string)); - free ((yyvsp[-7].string)); - pin_num = 1; - } -#line 2450 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 119: -#line 1303 "parse_y.y" /* yacc.c:1646 */ - { - SetElementBoundingBox(yyData, yyElement, yyFont); - } -#line 2458 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 120: -#line 1313 "parse_y.y" /* yacc.c:1646 */ - { - yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags((yyvsp[-10].integer)), - (yyvsp[-9].string), (yyvsp[-8].string), (yyvsp[-7].string), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), IV ((yyvsp[-4].measure)), IV ((yyvsp[-3].measure)), OldFlags((yyvsp[-2].integer)), false); - free ((yyvsp[-9].string)); - free ((yyvsp[-8].string)); - free ((yyvsp[-7].string)); - pin_num = 1; - } -#line 2471 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 121: -#line 1322 "parse_y.y" /* yacc.c:1646 */ - { - SetElementBoundingBox(yyData, yyElement, yyFont); - } -#line 2479 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 122: -#line 1333 "parse_y.y" /* yacc.c:1646 */ - { - yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags((yyvsp[-12].integer)), - (yyvsp[-11].string), (yyvsp[-10].string), (yyvsp[-9].string), OU ((yyvsp[-8].measure)) + OU ((yyvsp[-6].measure)), OU ((yyvsp[-7].measure)) + OU ((yyvsp[-5].measure)), - (yyvsp[-4].number), (yyvsp[-3].number), OldFlags((yyvsp[-2].integer)), false); - yyElement->MarkX = OU ((yyvsp[-8].measure)); - yyElement->MarkY = OU ((yyvsp[-7].measure)); - free ((yyvsp[-11].string)); - free ((yyvsp[-10].string)); - free ((yyvsp[-9].string)); - } -#line 2494 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 123: -#line 1344 "parse_y.y" /* yacc.c:1646 */ - { - SetElementBoundingBox(yyData, yyElement, yyFont); - } -#line 2502 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 124: -#line 1355 "parse_y.y" /* yacc.c:1646 */ - { - yyElement = CreateNewElement(yyData, yyElement, yyFont, (yyvsp[-12].flagtype), - (yyvsp[-11].string), (yyvsp[-10].string), (yyvsp[-9].string), NU ((yyvsp[-8].measure)) + NU ((yyvsp[-6].measure)), NU ((yyvsp[-7].measure)) + NU ((yyvsp[-5].measure)), - (yyvsp[-4].number), (yyvsp[-3].number), (yyvsp[-2].flagtype), false); - yyElement->MarkX = NU ((yyvsp[-8].measure)); - yyElement->MarkY = NU ((yyvsp[-7].measure)); - free ((yyvsp[-11].string)); - free ((yyvsp[-10].string)); - free ((yyvsp[-9].string)); - } -#line 2517 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 125: -#line 1366 "parse_y.y" /* yacc.c:1646 */ - { - SetElementBoundingBox(yyData, yyElement, yyFont); - } -#line 2525 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 133: -#line 1446 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewLineInElement(yyElement, NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), NU ((yyvsp[-3].measure)), NU ((yyvsp[-2].measure)), NU ((yyvsp[-1].measure))); - } -#line 2533 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 134: -#line 1451 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewLineInElement(yyElement, OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), OU ((yyvsp[-2].measure)), OU ((yyvsp[-1].measure))); - } -#line 2541 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 135: -#line 1456 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewArcInElement(yyElement, NU ((yyvsp[-7].measure)), NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), (yyvsp[-3].number), (yyvsp[-2].number), NU ((yyvsp[-1].measure))); - } -#line 2549 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 136: -#line 1461 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewArcInElement(yyElement, OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), (yyvsp[-3].number), (yyvsp[-2].number), OU ((yyvsp[-1].measure))); - } -#line 2557 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 137: -#line 1466 "parse_y.y" /* yacc.c:1646 */ - { - yyElement->MarkX = NU ((yyvsp[-2].measure)); - yyElement->MarkY = NU ((yyvsp[-1].measure)); - } -#line 2566 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 138: -#line 1471 "parse_y.y" /* yacc.c:1646 */ - { - yyElement->MarkX = OU ((yyvsp[-2].measure)); - yyElement->MarkY = OU ((yyvsp[-1].measure)); - } -#line 2575 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 139: -#line 1475 "parse_y.y" /* yacc.c:1646 */ - { attr_list = & yyElement->Attributes; } -#line 2581 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 147: -#line 1490 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewLineInElement(yyElement, NU ((yyvsp[-5].measure)) + yyElement->MarkX, - NU ((yyvsp[-4].measure)) + yyElement->MarkY, NU ((yyvsp[-3].measure)) + yyElement->MarkX, - NU ((yyvsp[-2].measure)) + yyElement->MarkY, NU ((yyvsp[-1].measure))); - } -#line 2591 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 148: -#line 1496 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewLineInElement(yyElement, OU ((yyvsp[-5].measure)) + yyElement->MarkX, - OU ((yyvsp[-4].measure)) + yyElement->MarkY, OU ((yyvsp[-3].measure)) + yyElement->MarkX, - OU ((yyvsp[-2].measure)) + yyElement->MarkY, OU ((yyvsp[-1].measure))); - } -#line 2601 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 149: -#line 1503 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewArcInElement(yyElement, NU ((yyvsp[-7].measure)) + yyElement->MarkX, - NU ((yyvsp[-6].measure)) + yyElement->MarkY, NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), (yyvsp[-3].number), (yyvsp[-2].number), NU ((yyvsp[-1].measure))); - } -#line 2610 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 150: -#line 1508 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewArcInElement(yyElement, OU ((yyvsp[-7].measure)) + yyElement->MarkX, - OU ((yyvsp[-6].measure)) + yyElement->MarkY, OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), (yyvsp[-3].number), (yyvsp[-2].number), OU ((yyvsp[-1].measure))); - } -#line 2619 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 151: -#line 1512 "parse_y.y" /* yacc.c:1646 */ - { attr_list = & yyElement->Attributes; } -#line 2625 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 153: -#line 1554 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewPin(yyElement, NU ((yyvsp[-9].measure)) + yyElement->MarkX, - NU ((yyvsp[-8].measure)) + yyElement->MarkY, NU ((yyvsp[-7].measure)), NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), (yyvsp[-3].string), - (yyvsp[-2].string), (yyvsp[-1].flagtype)); - free ((yyvsp[-3].string)); - free ((yyvsp[-2].string)); - } -#line 2637 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 154: -#line 1566 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewPin(yyElement, OU ((yyvsp[-9].measure)) + yyElement->MarkX, - OU ((yyvsp[-8].measure)) + yyElement->MarkY, OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), (yyvsp[-3].string), - (yyvsp[-2].string), OldFlags((yyvsp[-1].integer))); - free ((yyvsp[-3].string)); - free ((yyvsp[-2].string)); - } -#line 2649 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 155: -#line 1578 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewPin(yyElement, OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), 2*GROUNDPLANEFRAME, - OU ((yyvsp[-5].measure)) + 2*MASKFRAME, OU ((yyvsp[-4].measure)), (yyvsp[-3].string), (yyvsp[-2].string), OldFlags((yyvsp[-1].integer))); - free ((yyvsp[-3].string)); - free ((yyvsp[-2].string)); - } -#line 2660 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 156: -#line 1589 "parse_y.y" /* yacc.c:1646 */ - { - char p_number[8]; - - sprintf(p_number, "%d", pin_num++); - CreateNewPin(yyElement, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), 2*GROUNDPLANEFRAME, - OU ((yyvsp[-4].measure)) + 2*MASKFRAME, OU ((yyvsp[-3].measure)), (yyvsp[-2].string), p_number, OldFlags((yyvsp[-1].integer))); - - free ((yyvsp[-2].string)); - } -#line 2674 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 157: -#line 1605 "parse_y.y" /* yacc.c:1646 */ - { - Coord hole = OU ((yyvsp[-3].measure)) * DEFAULT_DRILLINGHOLE; - char p_number[8]; - - /* make sure that there's enough copper left */ - if (OU ((yyvsp[-3].measure)) - hole < MIN_PINORVIACOPPER && - OU ((yyvsp[-3].measure)) > MIN_PINORVIACOPPER) - hole = OU ((yyvsp[-3].measure)) - MIN_PINORVIACOPPER; - - sprintf(p_number, "%d", pin_num++); - CreateNewPin(yyElement, OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), 2*GROUNDPLANEFRAME, - OU ((yyvsp[-3].measure)) + 2*MASKFRAME, hole, (yyvsp[-2].string), p_number, OldFlags((yyvsp[-1].integer))); - free ((yyvsp[-2].string)); - } -#line 2693 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 158: -#line 1659 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewPad(yyElement, NU ((yyvsp[-10].measure)) + yyElement->MarkX, - NU ((yyvsp[-9].measure)) + yyElement->MarkY, - NU ((yyvsp[-8].measure)) + yyElement->MarkX, - NU ((yyvsp[-7].measure)) + yyElement->MarkY, NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), - (yyvsp[-3].string), (yyvsp[-2].string), (yyvsp[-1].flagtype)); - free ((yyvsp[-3].string)); - free ((yyvsp[-2].string)); - } -#line 2707 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 159: -#line 1673 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewPad(yyElement,OU ((yyvsp[-10].measure)) + yyElement->MarkX, - OU ((yyvsp[-9].measure)) + yyElement->MarkY, OU ((yyvsp[-8].measure)) + yyElement->MarkX, - OU ((yyvsp[-7].measure)) + yyElement->MarkY, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), - (yyvsp[-3].string), (yyvsp[-2].string), OldFlags((yyvsp[-1].integer))); - free ((yyvsp[-3].string)); - free ((yyvsp[-2].string)); - } -#line 2720 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 160: -#line 1686 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewPad(yyElement,OU ((yyvsp[-8].measure)),OU ((yyvsp[-7].measure)),OU ((yyvsp[-6].measure)),OU ((yyvsp[-5].measure)),OU ((yyvsp[-4].measure)), 2*GROUNDPLANEFRAME, - OU ((yyvsp[-4].measure)) + 2*MASKFRAME, (yyvsp[-3].string), (yyvsp[-2].string), OldFlags((yyvsp[-1].integer))); - free ((yyvsp[-3].string)); - free ((yyvsp[-2].string)); - } -#line 2731 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 161: -#line 1697 "parse_y.y" /* yacc.c:1646 */ - { - char p_number[8]; - - sprintf(p_number, "%d", pin_num++); - CreateNewPad(yyElement,OU ((yyvsp[-7].measure)),OU ((yyvsp[-6].measure)),OU ((yyvsp[-5].measure)),OU ((yyvsp[-4].measure)),OU ((yyvsp[-3].measure)), 2*GROUNDPLANEFRAME, - OU ((yyvsp[-3].measure)) + 2*MASKFRAME, (yyvsp[-2].string),p_number, OldFlags((yyvsp[-1].integer))); - free ((yyvsp[-2].string)); - } -#line 2744 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 162: -#line 1707 "parse_y.y" /* yacc.c:1646 */ - { (yyval.flagtype) = OldFlags((yyvsp[0].integer)); } -#line 2750 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 163: -#line 1708 "parse_y.y" /* yacc.c:1646 */ - { (yyval.flagtype) = string_to_flags ((yyvsp[0].string), yyerror); free((yyvsp[0].string)); } -#line 2756 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 167: -#line 1738 "parse_y.y" /* yacc.c:1646 */ - { - if ((yyvsp[-3].integer) <= 0 || (yyvsp[-3].integer) > MAX_FONTPOSITION) - { - yyerror("fontposition out of range"); - YYABORT; - } - Symbol = &yyFont->Symbol[(yyvsp[-3].integer)]; - if (Symbol->Valid) - { - yyerror("symbol ID used twice"); - YYABORT; - } - Symbol->Valid = true; - Symbol->Delta = NU ((yyvsp[-2].measure)); - } -#line 2776 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 168: -#line 1754 "parse_y.y" /* yacc.c:1646 */ - { - if ((yyvsp[-3].integer) <= 0 || (yyvsp[-3].integer) > MAX_FONTPOSITION) - { - yyerror("fontposition out of range"); - YYABORT; - } - Symbol = &yyFont->Symbol[(yyvsp[-3].integer)]; - if (Symbol->Valid) - { - yyerror("symbol ID used twice"); - YYABORT; - } - Symbol->Valid = true; - Symbol->Delta = OU ((yyvsp[-2].measure)); - } -#line 2796 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 174: -#line 1801 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewLineInSymbol(Symbol, OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), OU ((yyvsp[-2].measure)), OU ((yyvsp[-1].measure))); - } -#line 2804 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 175: -#line 1808 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewLineInSymbol(Symbol, NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), NU ((yyvsp[-3].measure)), NU ((yyvsp[-2].measure)), NU ((yyvsp[-1].measure))); - } -#line 2812 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 183: -#line 1863 "parse_y.y" /* yacc.c:1646 */ - { - Menu = CreateNewNet((LibraryTypePtr)&yyPCB->NetlistLib, (yyvsp[-3].string), (yyvsp[-2].string)); - free ((yyvsp[-3].string)); - free ((yyvsp[-2].string)); - } -#line 2822 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 189: -#line 1898 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewConnection(Menu, (yyvsp[-1].string)); - free ((yyvsp[-1].string)); - } -#line 2831 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 197: -#line 1945 "parse_y.y" /* yacc.c:1646 */ - { rats_patch_append(yyPCB, RATP_ADD_CONN, (yyvsp[-2].string), (yyvsp[-1].string), NULL); free((yyvsp[-2].string)); free((yyvsp[-1].string)); } -#line 2837 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 198: -#line 1946 "parse_y.y" /* yacc.c:1646 */ - { rats_patch_append(yyPCB, RATP_DEL_CONN, (yyvsp[-2].string), (yyvsp[-1].string), NULL); free((yyvsp[-2].string)); free((yyvsp[-1].string)); } -#line 2843 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 199: -#line 1947 "parse_y.y" /* yacc.c:1646 */ - { rats_patch_append(yyPCB, RATP_CHANGE_ATTRIB, (yyvsp[-3].string), (yyvsp[-2].string), (yyvsp[-1].string)); free((yyvsp[-3].string)); free((yyvsp[-2].string)); free((yyvsp[-1].string)); } -#line 2849 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 200: -#line 1975 "parse_y.y" /* yacc.c:1646 */ - { - CreateNewAttribute (attr_list, (yyvsp[-2].string), (yyvsp[-1].string) ? (yyvsp[-1].string) : (char *)""); - free ((yyvsp[-2].string)); - free ((yyvsp[-1].string)); - } -#line 2859 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 201: -#line 1982 "parse_y.y" /* yacc.c:1646 */ - { (yyval.string) = (yyvsp[0].string); } -#line 2865 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 202: -#line 1983 "parse_y.y" /* yacc.c:1646 */ - { (yyval.string) = 0; } -#line 2871 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 203: -#line 1987 "parse_y.y" /* yacc.c:1646 */ - { (yyval.number) = (yyvsp[0].number); } -#line 2877 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 204: -#line 1988 "parse_y.y" /* yacc.c:1646 */ - { (yyval.number) = (yyvsp[0].integer); } -#line 2883 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 205: -#line 1993 "parse_y.y" /* yacc.c:1646 */ - { do_measure(&(yyval.measure), (yyvsp[0].number), MIL_TO_COORD ((yyvsp[0].number)) / 100.0, 0); } -#line 2889 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 206: -#line 1994 "parse_y.y" /* yacc.c:1646 */ - { M ((yyval.measure), (yyvsp[-1].number), MIL_TO_COORD ((yyvsp[-1].number)) / 100000.0); } -#line 2895 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 207: -#line 1995 "parse_y.y" /* yacc.c:1646 */ - { M ((yyval.measure), (yyvsp[-1].number), MIL_TO_COORD ((yyvsp[-1].number)) / 100.0); } -#line 2901 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 208: -#line 1996 "parse_y.y" /* yacc.c:1646 */ - { M ((yyval.measure), (yyvsp[-1].number), MIL_TO_COORD ((yyvsp[-1].number))); } -#line 2907 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 209: -#line 1997 "parse_y.y" /* yacc.c:1646 */ - { M ((yyval.measure), (yyvsp[-1].number), INCH_TO_COORD ((yyvsp[-1].number))); } -#line 2913 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 210: -#line 1998 "parse_y.y" /* yacc.c:1646 */ - { M ((yyval.measure), (yyvsp[-1].number), MM_TO_COORD ((yyvsp[-1].number)) / 1000000.0); } -#line 2919 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 211: -#line 1999 "parse_y.y" /* yacc.c:1646 */ - { M ((yyval.measure), (yyvsp[-1].number), MM_TO_COORD ((yyvsp[-1].number)) / 1000.0); } -#line 2925 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 212: -#line 2000 "parse_y.y" /* yacc.c:1646 */ - { M ((yyval.measure), (yyvsp[-1].number), MM_TO_COORD ((yyvsp[-1].number))); } -#line 2931 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 213: -#line 2001 "parse_y.y" /* yacc.c:1646 */ - { M ((yyval.measure), (yyvsp[-1].number), MM_TO_COORD ((yyvsp[-1].number)) * 1000.0); } -#line 2937 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - case 214: -#line 2002 "parse_y.y" /* yacc.c:1646 */ - { M ((yyval.measure), (yyvsp[-1].number), MM_TO_COORD ((yyvsp[-1].number)) * 1000000.0); } -#line 2943 "parse_y.tab.c" /* yacc.c:1646 */ - break; - - -#line 2947 "parse_y.tab.c" /* yacc.c:1646 */ - default: break; - } - /* User semantic actions sometimes alter yychar, and that requires - that yytoken be updated with the new translation. We take the - approach of translating immediately before every use of yytoken. - One alternative is translating here after every semantic action, - but that translation would be missed if the semantic action invokes - YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or - if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an - incorrect destructor might then be invoked immediately. In the - case of YYERROR or YYBACKUP, subsequent parser actions might lead - to an incorrect destructor call or verbose syntax error message - before the lookahead is translated. */ - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); - - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - - *++yyvsp = yyval; - - /* Now 'shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*--------------------------------------. -| yyerrlab -- here on detecting error. | -`--------------------------------------*/ -yyerrlab: - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); - - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if ! YYERROR_VERBOSE - yyerror (YY_("syntax error")); -#else -# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ - yyssp, yytoken) - { - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - yysyntax_error_status = YYSYNTAX_ERROR; - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == 1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); - if (!yymsg) - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = 2; - } - else - { - yysyntax_error_status = YYSYNTAX_ERROR; - yymsgp = yymsg; - } - } - yyerror (yymsgp); - if (yysyntax_error_status == 2) - goto yyexhaustedlab; - } -# undef YYSYNTAX_ERROR -#endif - } - - - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } - else - { - yydestruct ("Error: discarding", - yytoken, &yylval); - yychar = YYEMPTY; - } - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; - - /* Do not reclaim the symbols of the rule whose action triggered - this YYERROR. */ - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - yystate = *yyssp; - goto yyerrlab1; - - -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (!yypact_value_is_default (yyn)) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - - yydestruct ("Error: popping", - yystos[yystate], yyvsp); - YYPOPSTACK (1); - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); - } - - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - *++yyvsp = yylval; - YY_IGNORE_MAYBE_UNINITIALIZED_END - - - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#if !defined yyoverflow || YYERROR_VERBOSE -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ -yyexhaustedlab: - yyerror (YY_("memory exhausted")); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: - if (yychar != YYEMPTY) - { - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = YYTRANSLATE (yychar); - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); - } - /* Do not reclaim the symbols of the rule whose action triggered - this YYABORT or YYACCEPT. */ - YYPOPSTACK (yylen); - YY_STACK_PRINT (yyss, yyssp); - while (yyssp != yyss) - { - yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); - YYPOPSTACK (1); - } -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif - return yyresult; -} -#line 2005 "parse_y.y" /* yacc.c:1906 */ - - -/* --------------------------------------------------------------------------- - * error routine called by parser library - */ -int yyerror(const char * s) -{ - Message("ERROR parsing file '%s'\n" - " line: %i\n" - " description: '%s'\n", - yyfilename, yylineno, s); - return(0); -} - -int yywrap() -{ - return 1; -} - -static int -check_file_version (int ver) -{ - if ( ver > PCB_FILE_VERSION ) { - Message ("ERROR: The file you are attempting to load is in a format\n" - "which is too new for this version of pcb. To load this file\n" - "you need a version of pcb which is >= %d. If you are\n" - "using a version built from git source, the source date\n" - "must be >= %d. This copy of pcb can only read files\n" - "up to file version %d.\n", ver, ver, PCB_FILE_VERSION); - return 1; - } - - return 0; -} - -static void -do_measure (PLMeasure *m, Coord i, double d, int u) -{ - m->ival = i; - m->bval = round (d); - m->dval = d; - m->has_units = u; -} - -static int -integer_value (PLMeasure m) -{ - if (m.has_units) - yyerror("units ignored here"); - return m.ival; -} - -static Coord -old_units (PLMeasure m) -{ - if (m.has_units) - return m.bval; - return round (MIL_TO_COORD (m.ival)); -} - -static Coord -new_units (PLMeasure m) -{ - if (m.has_units) - return m.bval; - return round (MIL_TO_COORD (m.ival) / 100.0); -} Index: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in (revision 1760) +++ trunk/src/Makefile.in (revision 1761) @@ -32,7 +32,6 @@ drill.o error.o event.o - file.o file_act.o find.o find_act.o @@ -92,7 +91,6 @@ select.o select_act.o set.o - strflags.o stub_edif.o stub_mincut.o stub_stroke.o @@ -103,8 +101,6 @@ vtlibrary.o vtonpoint.o vtptr.o - parse_y.o - parse_l.o buildin.o ../src_3rd/liblihata/parser.o ../src_3rd/liblihata/dom.o @@ -128,10 +124,6 @@ ../src_3rd/genvector/vtp0.o @] -# main: language generator files -put /local/pcb/YACC {parse_y} -put /local/pcb/LEX {parse_l} - # main: action registrations put /local/pcb/ACTION_REG_SRC { action_act.c buffer.c change_act.c conf_act.c file_act.c find_act.c @@ -156,10 +148,13 @@ put /local/pcb/mod/CONF {} put /local/pcb/mod/LDFLAGS {} put /local/pcb/mod/CFLAGS {} +put /local/pcb/mod/YACC {} +put /local/pcb/mod/LEX {} -put /local/pcb/tmpasm/buildin {../src_plugins/Buildin.tmpasm} -put /local/pcb/tmpasm/plugin {../src_plugins/Plugin.tmpasm} -put /local/pcb/tmpasm/disable {../src_plugins/Disable.tmpasm} +put /local/pcb/tmpasm/buildin {../src_plugins/Buildin.tmpasm} +put /local/pcb/tmpasm/plugin {../src_plugins/Plugin.tmpasm} +put /local/pcb/tmpasm/disable {../src_plugins/Disable.tmpasm} +put /local/pcb/tmpasm/common_enabled {../src_plugins/Common_enabled.tmpasm} include {../src_plugins/plugins_ALL.tmpasm} @@ -208,38 +203,7 @@ $(CC) $(LDFLAGS) $(OBJS) -o pcb-rnd $(LIBS) @] -# explicit rules: .y -> .c -# do not assume old yacc to work to different file names, do the generation -# in a separate directory to allow parallel compilation with -j -foreach /local/n in /local/pcb/YACC print [@ -@/local/n@.c @/local/n@.h: @/local/n@.y - mkdir tmp.@/local/n@.y - cp @/local/n@.y tmp.@/local/n@.y - cd tmp.@/local/n@.y && bison -d @/local/n@.y - mv tmp.@/local/n@.y/@/local/n@.tab.h @/local/n@.h - mv tmp.@/local/n@.y/@/local/n@.tab.c @/local/n@.c - -mv tmp.@/local/n@.y/@/local/n@.output @/local/n@.output - rm -rf tmp.@/local/n@.y -@] -end - -# explicit rules: .l -> .c -# do not assume old lex to work to different file names, do the generation -# in a separate directory to allow parallel compilation with -j -foreach /local/n in /local/pcb/LEX -print [@ -@/local/n@.c: @/local/n@.l - mkdir tmp.@/local/n@.l - cp @/local/n@.l tmp.@/local/n@.l - cd tmp.@/local/n@.l && flex @/local/n@.l - mv tmp.@/local/n@.l/lex.yy.c @/local/n@.c - rm -rf tmp.@/local/n@.l -@] -end - - -print [@ ##### module rules begin ##### @/local/pcb/RULES@ Index: trunk/src/file.h =================================================================== --- trunk/src/file.h (revision 1760) +++ trunk/src/file.h (revision 1761) @@ -1,81 +1,2 @@ -/* - * COPYRIGHT - * - * PCB, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Contact addresses for paper mail and Email: - * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany - * Thomas.Nau@rz.uni-ulm.de - * - */ - -/* prototypes for file routines - */ - -#ifndef PCB_FILE_H -#define PCB_FILE_H - -#include /* needed to define 'FILE *' */ -#include "global.h" - -FILE *CheckAndOpenFile(char *, bool, bool, bool *, bool *); -FILE *OpenConnectionDataFile(void); -int SavePCB(char *); -int LoadPCB(char *, bool, bool); -int RevertPCB(void); -void EnableAutosave(void); -void Backup(void); -void SaveInTMP(void); -void EmergencySave(void); -void DisableEmergencySave(void); -int ImportNetlist(char *); -int SaveBufferElements(char *); -void PreLoadElementPCB(void); -void PostLoadElementPCB(void); -void sort_netlist(void); - -/* - * Whenever the pcb file format is modified, this version number - * should be updated to the date when the new code is committed. - * It will be written out to the file and also used by pcb to give - * guidance to the user as to what the minimum version of pcb required - * is. - */ - -/* This is the version needed by the file we're saving. */ -int PCBFileVersionNeeded(void); - -/* This is the version we support. */ -#define PCB_FILE_VERSION 20110603 - - -#ifndef HAS_ATEXIT -#ifdef HAS_ON_EXIT -void GlueEmergencySave(int, caddr_t); -#else -void SaveTMPData(void); -void RemoveTMPData(void); -#endif -#endif - -void PrintQuotedString(FILE *, const char *); - -void file_uninit(); -void sort_library(LibraryTypePtr lib); - -#endif +#warning TODO: this should be gone once io_pcb is really a plugin +#include "../src_plugins/io_pcb/file.h" Index: trunk/src/parse_l.h =================================================================== --- trunk/src/parse_l.h (revision 1760) +++ trunk/src/parse_l.h (revision 1761) @@ -1,40 +1,2 @@ -/* - * COPYRIGHT - * - * PCB, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Contact addresses for paper mail and Email: - * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany - * Thomas.Nau@rz.uni-ulm.de - * - * RCS: $Id$ - */ - -/* just defines common parser identifiers - */ - -#ifndef PCB_LEX_H -#define PCB_LEX_H - -#include "global.h" - -int ParsePCB(PCBTypePtr, char *); -int ParseElement(DataTypePtr, const char *); -int ParseFont(FontTypePtr, char *); - -#endif +#warning TODO: this should be gone once io_pcb is really a plugin +#include "../src_plugins/io_pcb/parse_l.h" Index: trunk/src/parse_y.h =================================================================== --- trunk/src/parse_y.h (revision 1760) +++ trunk/src/parse_y.h (revision 1761) @@ -1,123 +1,2 @@ -/* A Bison parser, made by GNU Bison 3.0.2. */ - -/* Bison interface for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -#ifndef YY_YY_PARSE_Y_TAB_H_INCLUDED -# define YY_YY_PARSE_Y_TAB_H_INCLUDED -/* Debug traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif -#if YYDEBUG -extern int yydebug; -#endif - -/* Token type. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - enum yytokentype - { - FLOATING = 258, - INTEGER = 259, - CHAR_CONST = 260, - STRING = 261, - T_FILEVERSION = 262, - T_PCB = 263, - T_LAYER = 264, - T_VIA = 265, - T_RAT = 266, - T_LINE = 267, - T_ARC = 268, - T_RECTANGLE = 269, - T_TEXT = 270, - T_ELEMENTLINE = 271, - T_ELEMENT = 272, - T_PIN = 273, - T_PAD = 274, - T_GRID = 275, - T_FLAGS = 276, - T_SYMBOL = 277, - T_SYMBOLLINE = 278, - T_CURSOR = 279, - T_ELEMENTARC = 280, - T_MARK = 281, - T_GROUPS = 282, - T_STYLES = 283, - T_POLYGON = 284, - T_POLYGON_HOLE = 285, - T_NETLIST = 286, - T_NET = 287, - T_CONN = 288, - T_NETLISTPATCH = 289, - T_ADD_CONN = 290, - T_DEL_CONN = 291, - T_CHANGE_ATTRIB = 292, - T_AREA = 293, - T_THERMAL = 294, - T_DRC = 295, - T_ATTRIBUTE = 296, - T_UMIL = 297, - T_CMIL = 298, - T_MIL = 299, - T_IN = 300, - T_NM = 301, - T_UM = 302, - T_MM = 303, - T_M = 304, - T_KM = 305 - }; -#endif - -/* Value type. */ -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE YYSTYPE; -union YYSTYPE -{ -#line 111 "parse_y.y" /* yacc.c:1909 */ - - int integer; - double number; - char *string; - FlagType flagtype; - PLMeasure measure; - -#line 113 "parse_y.tab.h" /* yacc.c:1909 */ -}; -# define YYSTYPE_IS_TRIVIAL 1 -# define YYSTYPE_IS_DECLARED 1 -#endif - - -extern YYSTYPE yylval; - -int yyparse (void); - -#endif /* !YY_YY_PARSE_Y_TAB_H_INCLUDED */ +#warning TODO: this should be gone once io_pcb is really a plugin +#include "../src_plugins/io_pcb/parse_y.h" Index: trunk/src/strflags.h =================================================================== --- trunk/src/strflags.h (revision 1760) +++ trunk/src/strflags.h (revision 1761) @@ -1,52 +1,2 @@ -/* $Id$ */ -/* - * COPYRIGHT - * - * PCB, interactive printed circuit board design - * Copyright (C) 2005 DJ Delorie - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Contact addresses for paper mail and Email: - * DJ Delorie, 334 North Road, Deerfield NH 03037-1110, USA - * dj@delorie.com - * - */ - -#ifndef PCB_STRFLAGS_H -#define PCB_STRFLAGS_H - -/* The purpose of this interface is to make the file format able to - handle more than 32 flags, and to hide the internal details of - flags from the file format. */ - -/* When passed a string, parse it and return an appropriate set of - flags. Errors cause error() to be called with a suitable message; - if error is NULL, errors are ignored. */ -FlagType string_to_flags(const char *flagstring, int (*error) (const char *msg)); - -/* Given a set of flags for a given object type, return a string which - can be output to a file. The returned pointer must not be - freed. */ -char *flags_to_string(FlagType flags, int object_type); - -/* Same as above, but for pcb flags. */ -FlagType string_to_pcbflags(const char *flagstring, int (*error) (const char *msg)); -char *pcbflags_to_string(FlagType flags); - -void uninit_strflags_buf(void); -void uninit_strflags_layerlist(void); - -#endif +#warning TODO: this should be gone once io_pcb is really a plugin +#include "../src_plugins/io_pcb/strflags.h" Index: trunk/src_plugins/Buildin.tmpasm =================================================================== --- trunk/src_plugins/Buildin.tmpasm (revision 1760) +++ trunk/src_plugins/Buildin.tmpasm (revision 1761) @@ -19,20 +19,4 @@ @] -switch /local/pcb/mod/CONF - case {} end - default - put /local/pcb/mod/CONFOUT /local/pcb/mod/CONF - sub {/local/pcb/mod/CONFOUT} {.h$} {_fields.h} - append /local/pcb/RULES [@ -@/local/pcb/mod/CONFOUT@: @/local/pcb/mod/CONF@ - ../scconfig/gen_conf.sh < @/local/pcb/mod/CONF@ > @/local/pcb/mod/CONFOUT@ -@] - end -end - -put /local/pcb/mod/OBJS {} -put /local/pcb/mod/CONF {} -put /local/pcb/mod/LDFLAGS {} -put /local/pcb/mod/CFLAGS {} -put /local/pcb/mod {} +include /local/pcb/tmpasm/common_enabled Index: trunk/src_plugins/Common_enabled.tmpasm =================================================================== --- trunk/src_plugins/Common_enabled.tmpasm (nonexistent) +++ trunk/src_plugins/Common_enabled.tmpasm (revision 1761) @@ -0,0 +1,76 @@ +# explicit rules: .y -> .c +# do not assume old yacc to work to different file names, do the generation +# in a separate directory to allow parallel compilation with -j +switch /local/pcb/mod/YACC + case {^$} end + default + foreach /local/n in /local/pcb/mod/YACC + put /local/tmp /local/n + sub {/local/tmp} {^[^/]*/} {} + gsub {/local/tmp} {/} {_} + put /local/tmp [@tmp.@/local/tmp@.l@] + + put /local/bn /local/n + sub {/local/bn} {^.*/} {} + + append /local/pcb/RULES [@ +# yacc for @/local/pcb/mod@ +@/local/n@.c @/local/n@.h: @/local/n@.y + mkdir @/local/tmp@ + cp @/local/n@.y @/local/tmp@ + cd @/local/tmp@ && bison -d ../@/local/n@.y + mv @/local/tmp@/@/local/bn@.tab.h @/local/n@.h + mv @/local/tmp@/@/local/bn@.tab.c @/local/n@.c + -mv @/local/tmp@/@/local/bn@.output @/local/n@.output + rm -rf @/local/tmp@ +@] + end + end +end + +# explicit rules: .l -> .c +# do not assume old lex to work to different file names, do the generation +# in a separate directory to allow parallel compilation with -j +switch /local/pcb/mod/LEX + case {^$} end + default + foreach /local/n in /local/pcb/mod/LEX + put /local/tmp /local/n + sub {/local/tmp} {^[^/]*/} {} + gsub {/local/tmp} {/} {_} + put /local/tmp [@tmp.@/local/tmp@.l@] + + append /local/pcb/RULES [@ +# lex for @/local/pcb/mod@ +@/local/n@.c: @/local/n@.l + mkdir @/local/tmp@ + cp @/local/n@.l @/local/tmp@ + cd @/local/tmp@ && flex ../@/local/n@.l + mv @/local/tmp@/lex.yy.c @/local/n@.c + rm -rf @/local/tmp@ +@] + end + end +end + +switch /local/pcb/mod/CONF + case {^$} end + default + put /local/pcb/mod/CONFOUT /local/pcb/mod/CONF + sub {/local/pcb/mod/CONFOUT} {.h$} {_fields.h} + append /local/pcb/RULES [@ +# conf generation for @/local/pcb/mod@ '@/local/pcb/mod/CONF@' +@/local/pcb/mod/CONFOUT@: @/local/pcb/mod/CONF@ + ../scconfig/gen_conf.sh < @/local/pcb/mod/CONF@ > @/local/pcb/mod/CONFOUT@ +@] + end +end + +put /local/pcb/mod/OBJS {} +put /local/pcb/mod/CONF {} +put /local/pcb/mod/LDFLAGS {} +put /local/pcb/mod/CFLAGS {} +put /local/pcb/mod/YACC {} +put /local/pcb/mod/LEX {} +put /local/pcb/mod {} + Index: trunk/src_plugins/Plugin.tmpasm =================================================================== --- trunk/src_plugins/Plugin.tmpasm (revision 1760) +++ trunk/src_plugins/Plugin.tmpasm (revision 1761) @@ -40,20 +40,4 @@ ### Module @/local/pcb/mod@ end ### @] -switch /local/pcb/mod/CONF - case {} end - default - put /local/pcb/mod/CONFOUT /local/pcb/mod/CONF - sub {/local/pcb/mod/CONFOUT} {.h$} {_fields.h} - append /local/pcb/RULES [@ -@/local/pcb/mod/CONFOUT@: @/local/pcb/mod/CONF@ - ../scconfig/gen_conf.sh < @/local/pcb/mod/CONF@ > @/local/pcb/mod/CONFOUT@ -@] - end -end - -put /local/pcb/mod/OBJS {} -put /local/pcb/mod/CONF {} -put /local/pcb/mod/LDFLAGS {} -put /local/pcb/mod/CFLAGS {} -put /local/pcb/mod {} +include /local/pcb/tmpasm/common_enabled Index: trunk/src_plugins/io_pcb/Makefile =================================================================== --- trunk/src_plugins/io_pcb/Makefile (nonexistent) +++ trunk/src_plugins/io_pcb/Makefile (revision 1761) @@ -0,0 +1,5 @@ +all: + cd ../../src && make mod_io_pcb + +clean: + rm *.o *.so 2>/dev/null ; true Index: trunk/src_plugins/io_pcb/Plug.tmpasm =================================================================== --- trunk/src_plugins/io_pcb/Plug.tmpasm (nonexistent) +++ trunk/src_plugins/io_pcb/Plug.tmpasm (revision 1761) @@ -0,0 +1,10 @@ +put /local/pcb/mod {io_pcb} +put /local/pcb/mod/OBJS [@ $(PLUGDIR)/io_pcb/io_pcb.o $(PLUGDIR)/io_pcb/file.o $(PLUGDIR)/io_pcb/parse_y.o $(PLUGDIR)/io_pcb/parse_l.o $(PLUGDIR)/io_pcb/strflags.o @] +put /local/pcb/mod/YACC {$(PLUGDIR)/io_pcb/parse_y} +put /local/pcb/mod/LEX {$(PLUGDIR)/io_pcb/parse_l} + +switch /local/pcb/io_pcb/controls + case {buildin} include /local/pcb/tmpasm/buildin; end; + case {plugin} include /local/pcb/tmpasm/plugin; end; + case {disable} include /local/pcb/tmpasm/disable; end; +end Index: trunk/src_plugins/io_pcb/README =================================================================== --- trunk/src_plugins/io_pcb/README (nonexistent) +++ trunk/src_plugins/io_pcb/README (revision 1761) @@ -0,0 +1,6 @@ +Load and save the design and elements in the original pcb text format. + +#state: works +#default: buildin +#ldefault: must be builtin until the io plugin API is finished +#implements: io Index: trunk/src_plugins/io_pcb/file.c =================================================================== --- trunk/src_plugins/io_pcb/file.c (nonexistent) +++ trunk/src_plugins/io_pcb/file.c (revision 1761) @@ -0,0 +1,1209 @@ +/* $Id$ */ + +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 1994,1995,1996,1997,1998,2005,2006 Thomas Nau + * Copyright (C) 2015 Tibor 'Igor2' Palinkas + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Contact addresses for paper mail and Email: + * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany + * Thomas.Nau@rz.uni-ulm.de + * + */ + +/* file save, load, merge ... routines + * getpid() needs a cast to (int) to get rid of compiler warnings + * on several architectures + */ + +#include "config.h" +#include "conf_core.h" + +#include + +#ifdef HAVE_SYS_PARAM_H +#include +#endif + +#include "global.h" + +#include +#ifdef HAVE_PWD_H +#include +#endif +#include + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + +#include + +#ifdef HAVE_NETINET_IN_H +#include +#endif + +#ifdef HAVE_NETDB_H +#include +#endif + +#include + +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifdef HAVE_STRING_H +#include +#endif + +#ifdef HAVE_UNISTD_H +#include +#endif + + +#include "buffer.h" +#include "change.h" +#include "create.h" +#include "crosshair.h" +#include "data.h" +#include "error.h" +#include "file.h" +#include "hid.h" +#include "misc.h" +#include "move.h" +#include "mymem.h" +#include "parse_l.h" +#include "pcb-printf.h" +#include "polygon.h" +#include "rats.h" +#include "remove.h" +#include "set.h" +#include "strflags.h" +#include "compat_fs.h" +#include "paths.h" +#include "rats_patch.h" +#include "stub_edif.h" +#include "hid_actions.h" +#include "hid_flags.h" + +RCSID("$Id$"); + +#if !defined(HAS_ATEXIT) && !defined(HAS_ON_EXIT) +/* --------------------------------------------------------------------------- + * some local identifiers for OS without an atexit() or on_exit() + * call + */ +static char TMPFilename[80]; +#endif + +/* --------------------------------------------------------------------------- + * some local prototypes + */ +static void WritePCBInfoHeader(FILE *); +static void WritePCBDataHeader(FILE *); +static void WritePCBFontData(FILE *); +static void WriteViaData(FILE *, DataTypePtr); +static void WritePCBRatData(FILE *); +static void WriteElementData(FILE *, DataTypePtr); +static void WriteLayerData(FILE *, Cardinal, LayerTypePtr); +static int WritePCB(FILE *); +static int WritePCBFile(char *); +static int WritePipe(char *, bool); + +/* --------------------------------------------------------------------------- + * Flag helper functions + */ + +#define F2S(OBJ, TYPE) flags_to_string ((OBJ)->Flags, TYPE) + +/* --------------------------------------------------------------------------- */ + +/* The idea here is to avoid gratuitously breaking backwards + compatibility due to a new but rarely used feature. The first such + case, for example, was the polygon Hole - if your design included + polygon holes, you needed a newer PCB to read it, but if your + design didn't include holes, PCB would produce a file that older + PCBs could read, if only it had the correct version number in it. + + If, however, you have to add or change a feature that really does + require a new PCB version all the time, it's time to remove all the + tests below and just always output the new version. + + Note: Best practices here is to add support for a feature *first* + (and bump PCB_FILE_VERSION in file.h), and note the version that + added that support below, and *later* update the file format to + need that version (which may then be older than PCB_FILE_VERSION). + Hopefully, that allows for one release between adding support and + needing it, which should minimize breakage. Of course, that's not + *always* possible, practical, or desirable. + +*/ + +/* Hole[] in Polygon. */ +#define PCB_FILE_VERSION_HOLES 20100606 +/* First version ever saved. */ +#define PCB_FILE_VERSION_BASELINE 20070407 + +int PCBFileVersionNeeded(void) +{ + ALLPOLYGON_LOOP(PCB->Data); + { + if (polygon->HoleIndexN > 0) + return PCB_FILE_VERSION_HOLES; + } + ENDALL_LOOP; + + return PCB_FILE_VERSION_BASELINE; +} + +/* --------------------------------------------------------------------------- */ + +static int string_cmp(const char *a, const char *b) +{ + while (*a && *b) { + if (isdigit((int) *a) && isdigit((int) *b)) { + int ia = atoi(a); + int ib = atoi(b); + if (ia != ib) + return ia - ib; + while (isdigit((int) *a) && *(a + 1)) + a++; + while (isdigit((int) *b) && *(b + 1)) + b++; + } + else if (tolower((int) *a) != tolower((int) *b)) + return tolower((int) *a) - tolower((int) *b); + a++; + b++; + } + if (*a) + return 1; + if (*b) + return -1; + return 0; +} + +static int netlist_sort_offset = 0; + +static int netlist_sort(const void *va, const void *vb) +{ + LibraryMenuType *am = (LibraryMenuType *) va; + LibraryMenuType *bm = (LibraryMenuType *) vb; + char *a = am->Name; + char *b = bm->Name; + if (*a == '~') + a++; + if (*b == '~') + b++; + return string_cmp(a, b); +} + +static int netnode_sort(const void *va, const void *vb) +{ + LibraryEntryType *am = (LibraryEntryType *) va; + LibraryEntryType *bm = (LibraryEntryType *) vb; + char *a = am->ListEntry; + char *b = bm->ListEntry; + return string_cmp(a, b); +} + +void sort_library(LibraryTypePtr lib) +{ + int i; + qsort(lib->Menu, lib->MenuN, sizeof(lib->Menu[0]), netlist_sort); + for (i = 0; i < lib->MenuN; i++) + qsort(lib->Menu[i].Entry, lib->Menu[i].EntryN, sizeof(lib->Menu[i].Entry[0]), netnode_sort); +} + +void sort_netlist() +{ + netlist_sort_offset = 2; + sort_library(&(PCB->NetlistLib[NETLIST_INPUT])); + netlist_sort_offset = 0; +} + +/* --------------------------------------------------------------------------- + * opens a file and check if it exists + */ +FILE *CheckAndOpenFile(char *Filename, bool Confirm, bool AllButton, bool * WasAllButton, bool * WasCancelButton) +{ + FILE *fp = NULL; + struct stat buffer; + char message[MAXPATHLEN + 80]; + int response; + + if (Filename && *Filename) { + if (!stat(Filename, &buffer) && Confirm) { + sprintf(message, _("File '%s' exists, use anyway?"), Filename); + if (WasAllButton) + *WasAllButton = false; + if (WasCancelButton) + *WasCancelButton = false; + if (AllButton) + response = gui->confirm_dialog(message, "Cancel", "Ok", AllButton ? "Sequence OK" : 0); + else + response = gui->confirm_dialog(message, "Cancel", "Ok", "Sequence OK"); + + switch (response) { + case 2: + if (WasAllButton) + *WasAllButton = true; + break; + case 0: + if (WasCancelButton) + *WasCancelButton = true; + } + } + if ((fp = fopen(Filename, "w")) == NULL) + OpenErrorMessage(Filename); + } + return (fp); +} + +/* --------------------------------------------------------------------------- + * opens a file for saving connection data + */ +FILE *OpenConnectionDataFile(void) +{ + char *fname; + FILE *fp; + static char *default_file = NULL; + bool result; /* not used */ + + /* CheckAndOpenFile deals with the case where fname already exists */ + fname = gui->fileselect(_("Save Connection Data As ..."), + _("Choose a file to save all connection data to."), default_file, ".net", "connection_data", 0); + if (fname == NULL) + return NULL; + + if (default_file != NULL) { + free(default_file); + default_file = NULL; + } + + if (fname && *fname) + default_file = strdup(fname); + + fp = CheckAndOpenFile(fname, true, false, &result, NULL); + free(fname); + + return fp; +} + +/* --------------------------------------------------------------------------- + * save elements in the current buffer + */ +int SaveBufferElements(char *Filename) +{ + int result; + + if (SWAP_IDENT) + SwapBuffers(); + result = WritePipe(Filename, false); + if (SWAP_IDENT) + SwapBuffers(); + return (result); +} + +/* --------------------------------------------------------------------------- + * save PCB + */ +int SavePCB(char *file) +{ + int retcode; + + if (gui->notify_save_pcb == NULL) + return WritePipe(file, true); + + gui->notify_save_pcb(file, false); + retcode = WritePipe(file, true); + gui->notify_save_pcb(file, true); + + return retcode; +} + +/* --------------------------------------------------------------------------- + * set the route style to the first one, if the current one doesn't + * happen to match any. This way, "revert" won't change the route + * style. + */ +static void set_some_route_style() +{ + if (hid_get_flag("style")) + return; + SetLineSize(PCB->RouteStyle[0].Thick); + SetViaSize(PCB->RouteStyle[0].Diameter, true); + SetViaDrillingHole(PCB->RouteStyle[0].Hole, true); + SetKeepawayWidth(PCB->RouteStyle[0].Keepaway); +} + +/* --------------------------------------------------------------------------- + * load PCB + * parse the file with enabled 'PCB mode' (see parser) + * if successful, update some other stuff + * + * If revert is true, we pass "revert" as a parameter + * to the HID's PCBChanged action. + */ +static int real_load_pcb(char *Filename, bool revert, bool require_font, bool is_misc) +{ + const char *unit_suffix; + char *new_filename; + PCBTypePtr newPCB = CreateNewPCB_(false); + PCBTypePtr oldPCB; +#ifdef DEBUG + double elapsed; + clock_t start, end; + + start = clock(); +#endif + + resolve_path(Filename, &new_filename, 0); + + oldPCB = PCB; + PCB = newPCB; + + /* mark the default font invalid to know if the file has one */ + newPCB->Font.Valid = false; + + /* new data isn't added to the undo list */ + if (!ParsePCB(PCB, new_filename)) { + RemovePCB(oldPCB); + + CreateNewPCBPost(PCB, 0); + ResetStackAndVisibility(); + + if (!is_misc) { + /* update cursor location */ + Crosshair.X = PCB_CLAMP(PCB->CursorX, 0, PCB->MaxWidth); + Crosshair.Y = PCB_CLAMP(PCB->CursorY, 0, PCB->MaxHeight); + + /* update cursor confinement and output area (scrollbars) */ + ChangePCBSize(PCB->MaxWidth, PCB->MaxHeight); + } + + /* enable default font if necessary */ + if (!PCB->Font.Valid) { + if (require_font) + Message(_("File '%s' has no font information, using default font\n"), new_filename); + PCB->Font.Valid = true; + } + + /* clear 'changed flag' */ + SetChangedFlag(false); + PCB->Filename = new_filename; + /* just in case a bad file saved file is loaded */ + + /* Use attribute PCB::grid::unit as unit, if we can */ + unit_suffix = AttributeGet(PCB, "PCB::grid::unit"); + if (unit_suffix && *unit_suffix) { + const Unit *new_unit = get_unit_struct(unit_suffix); +#warning TODO: we MUST NOT overwrite this here; should be handled by pcb-local settings + if (new_unit) + conf_core.editor.grid_unit = new_unit; + } + AttributePut(PCB, "PCB::grid::unit", conf_core.editor.grid_unit->suffix); + + sort_netlist(); + rats_patch_make_edited(PCB); + + set_some_route_style(); + + if (!is_misc) { + if (revert) + hid_actionl("PCBChanged", "revert", NULL); + else + hid_action("PCBChanged"); + } + +#ifdef DEBUG + end = clock(); + elapsed = ((double) (end - start)) / CLOCKS_PER_SEC; + gui->log("Loading file %s took %f seconds of CPU time\n", new_filename, elapsed); +#endif + + return (0); + } + PCB = oldPCB; + hid_action("PCBChanged"); + + /* release unused memory */ + RemovePCB(newPCB); + return (1); +} + +/* --------------------------------------------------------------------------- + * Load PCB + */ +int LoadPCB(char *file, bool require_font, bool is_misc) +{ + return real_load_pcb(file, false, require_font, is_misc); +} + +/* --------------------------------------------------------------------------- + * Revert PCB + */ +int RevertPCB(void) +{ + return real_load_pcb(PCB->Filename, true, true, true); +} + +/* --------------------------------------------------------------------------- + * functions for loading elements-as-pcb + */ + +extern PCBTypePtr yyPCB; +extern DataTypePtr yyData; +extern FontTypePtr yyFont; + +void PreLoadElementPCB() +{ + + if (!yyPCB) + return; + + yyFont = &yyPCB->Font; + yyData = yyPCB->Data; + yyData->pcb = yyPCB; + yyData->LayerN = 0; +} + +void PostLoadElementPCB() +{ + PCBTypePtr pcb_save = PCB; + ElementTypePtr e; + + if (!yyPCB) + return; + + CreateNewPCBPost(yyPCB, 0); + ParseGroupString("1,c:2,s", &yyPCB->LayerGroups, yyData->LayerN); + e = elementlist_first(&yyPCB->Data->Element); /* we know there's only one */ + PCB = yyPCB; + MoveElementLowLevel(yyPCB->Data, e, -e->BoundingBox.X1, -e->BoundingBox.Y1); + PCB = pcb_save; + yyPCB->MaxWidth = e->BoundingBox.X2; + yyPCB->MaxHeight = e->BoundingBox.Y2; + yyPCB->is_footprint = 1; +} + +/* --------------------------------------------------------------------------- + * writes the quoted string created by another subroutine + */ +void PrintQuotedString(FILE * FP, const char *S) +{ + const char *start; + + fputc('"', FP); + for(start = S; *S != '\0'; S++) { + if (*S == '"' || *S == '\\') { + if (start != S) + fwrite(start, S-start, 1, FP); + fputc('\\', FP); + fputc(*S, FP); + start = S+1; + } + } + + if (start != S) + fwrite(start, S-start, 1, FP); + + fputc('"', FP); +} + +void file_uninit() +{ +} + +/* --------------------------------------------------------------------------- + * writes out an attribute list + */ +static void WriteAttributeList(FILE * FP, AttributeListTypePtr list, char *prefix) +{ + int i; + + for (i = 0; i < list->Number; i++) + fprintf(FP, "%sAttribute(\"%s\" \"%s\")\n", prefix, list->List[i].name, list->List[i].value); +} + +/* --------------------------------------------------------------------------- + * writes layout header information + */ +static void WritePCBInfoHeader(FILE * FP) +{ + /* write some useful comments */ + fprintf(FP, "# release: %s " VERSION "\n", Progname); + + /* avoid writing things like user name or date, as these cause merge + * conflicts in collaborative environments using version control systems + */ +} + +/* --------------------------------------------------------------------------- + * writes data header + * the name of the PCB, cursor location, zoom and grid + * layergroups and some flags + */ +static void WritePCBDataHeader(FILE * FP) +{ + Cardinal group; + + /* + * ************************** README ******************* + * ************************** README ******************* + * + * If the file format is modified in any way, update + * PCB_FILE_VERSION in file.h as well as PCBFileVersionNeeded() + * at the top of this file. + * + * ************************** README ******************* + * ************************** README ******************* + */ + + fprintf(FP, "\n# To read pcb files, the pcb version (or the git source date) must be >= the file version\n"); + fprintf(FP, "FileVersion[%i]\n", PCBFileVersionNeeded()); + + fputs("\nPCB[", FP); + PrintQuotedString(FP, (char *) EMPTY(PCB->Name)); + pcb_fprintf(FP, " %mr %mr]\n\n", PCB->MaxWidth, PCB->MaxHeight); + pcb_fprintf(FP, "Grid[%.1mr %mr %mr %d]\n", PCB->Grid, PCB->GridOffsetX, PCB->GridOffsetY, conf_core.editor.draw_grid); + pcb_fprintf(FP, "Cursor[%mr %mr %s]\n", Crosshair.X, Crosshair.Y, c_dtostr(PCB->Zoom)); + /* PolyArea should be output in square cmils, no suffix */ + fprintf(FP, "PolyArea[%s]\n", c_dtostr(COORD_TO_MIL(COORD_TO_MIL(PCB->IsleArea) * 100) * 100)); + pcb_fprintf(FP, "Thermal[%s]\n", c_dtostr(PCB->ThermScale)); + pcb_fprintf(FP, "DRC[%mr %mr %mr %mr %mr %mr]\n", PCB->Bloat, PCB->Shrink, + PCB->minWid, PCB->minSlk, PCB->minDrill, PCB->minRing); + fprintf(FP, "Flags(%s)\n", pcbflags_to_string(PCB->Flags)); + fprintf(FP, "Groups(\"%s\")\n", LayerGroupsToString(&PCB->LayerGroups)); + fputs("Styles[\"", FP); + for (group = 0; group < NUM_STYLES - 1; group++) + pcb_fprintf(FP, "%s,%mr,%mr,%mr,%mr:", PCB->RouteStyle[group].Name, + PCB->RouteStyle[group].Thick, + PCB->RouteStyle[group].Diameter, PCB->RouteStyle[group].Hole, PCB->RouteStyle[group].Keepaway); + pcb_fprintf(FP, "%s,%mr,%mr,%mr,%mr\"]\n\n", PCB->RouteStyle[group].Name, + PCB->RouteStyle[group].Thick, + PCB->RouteStyle[group].Diameter, PCB->RouteStyle[group].Hole, PCB->RouteStyle[group].Keepaway); +} + +/* --------------------------------------------------------------------------- + * writes font data of non empty symbols + */ +static void WritePCBFontData(FILE * FP) +{ + Cardinal i, j; + LineTypePtr line; + FontTypePtr font; + + for (font = &PCB->Font, i = 0; i <= MAX_FONTPOSITION; i++) { + if (!font->Symbol[i].Valid) + continue; + + if (isprint(i)) + pcb_fprintf(FP, "Symbol['%c' %mr]\n(\n", i, font->Symbol[i].Delta); + else + pcb_fprintf(FP, "Symbol[%i %mr]\n(\n", i, font->Symbol[i].Delta); + + line = font->Symbol[i].Line; + for (j = font->Symbol[i].LineN; j; j--, line++) + pcb_fprintf(FP, "\tSymbolLine[%mr %mr %mr %mr %mr]\n", + line->Point1.X, line->Point1.Y, line->Point2.X, line->Point2.Y, line->Thickness); + fputs(")\n", FP); + } +} + +/* --------------------------------------------------------------------------- + * writes via data + */ +static void WriteViaData(FILE * FP, DataTypePtr Data) +{ + gdl_iterator_t it; + PinType *via; + + /* write information about vias */ + pinlist_foreach(&Data->Via, &it, via) { + pcb_fprintf(FP, "Via[%mr %mr %mr %mr %mr %mr ", via->X, via->Y, + via->Thickness, via->Clearance, via->Mask, via->DrillingHole); + PrintQuotedString(FP, (char *) EMPTY(via->Name)); + fprintf(FP, " %s]\n", F2S(via, VIA_TYPE)); + } +} + +/* --------------------------------------------------------------------------- + * writes rat-line data + */ +static void WritePCBRatData(FILE * FP) +{ + gdl_iterator_t it; + RatType *line; + + /* write information about rats */ + ratlist_foreach(&PCB->Data->Rat, &it, line) { + pcb_fprintf(FP, "Rat[%mr %mr %d %mr %mr %d ", + line->Point1.X, line->Point1.Y, line->group1, line->Point2.X, line->Point2.Y, line->group2); + fprintf(FP, " %s]\n", F2S(line, RATLINE_TYPE)); + } +} + +/* --------------------------------------------------------------------------- + * writes netlist data + */ +static void WritePCBNetlistData(FILE * FP) +{ + /* write out the netlist if it exists */ + if (PCB->NetlistLib[NETLIST_INPUT].MenuN) { + int n, p; + fprintf(FP, "NetList()\n(\n"); + + for (n = 0; n < PCB->NetlistLib[NETLIST_INPUT].MenuN; n++) { + LibraryMenuTypePtr menu = &PCB->NetlistLib[NETLIST_INPUT].Menu[n]; + fprintf(FP, "\tNet("); + PrintQuotedString(FP, &menu->Name[2]); + fprintf(FP, " "); + PrintQuotedString(FP, (char *) UNKNOWN(menu->Style)); + fprintf(FP, ")\n\t(\n"); + for (p = 0; p < menu->EntryN; p++) { + LibraryEntryTypePtr entry = &menu->Entry[p]; + fprintf(FP, "\t\tConnect("); + PrintQuotedString(FP, entry->ListEntry); + fprintf(FP, ")\n"); + } + fprintf(FP, "\t)\n"); + } + fprintf(FP, ")\n"); + } +} + +/* --------------------------------------------------------------------------- + * writes netlist patch data + */ +static void WritePCBNetlistPatchData(FILE * FP) +{ + if (PCB->NetlistPatches != NULL) { + fprintf(FP, "NetListPatch()\n(\n"); + rats_patch_fexport(PCB, FP, 1); + fprintf(FP, ")\n"); + } +} + +/* --------------------------------------------------------------------------- + * writes element data + */ +static void WriteElementData(FILE * FP, DataTypePtr Data) +{ + gdl_iterator_t eit; + LineType *line; + ArcType *arc; + ElementType *element; + + elementlist_foreach(&Data->Element, &eit, element) { + gdl_iterator_t it; + PinType *pin; + PadType *pad; + + /* only non empty elements */ + if (!linelist_length(&element->Line) && !pinlist_length(&element->Pin) && !arclist_length(&element->Arc) && !padlist_length(&element->Pad)) + continue; + /* the coordinates and text-flags are the same for + * both names of an element + */ + fprintf(FP, "\nElement[%s ", F2S(element, ELEMENT_TYPE)); + PrintQuotedString(FP, (char *) EMPTY(DESCRIPTION_NAME(element))); + fputc(' ', FP); + PrintQuotedString(FP, (char *) EMPTY(NAMEONPCB_NAME(element))); + fputc(' ', FP); + PrintQuotedString(FP, (char *) EMPTY(VALUE_NAME(element))); + pcb_fprintf(FP, " %mr %mr %mr %mr %d %d %s]\n(\n", + element->MarkX, element->MarkY, + DESCRIPTION_TEXT(element).X - element->MarkX, + DESCRIPTION_TEXT(element).Y - element->MarkY, + DESCRIPTION_TEXT(element).Direction, + DESCRIPTION_TEXT(element).Scale, F2S(&(DESCRIPTION_TEXT(element)), ELEMENTNAME_TYPE)); + WriteAttributeList(FP, &element->Attributes, "\t"); + pinlist_foreach(&element->Pin, &it, pin) { + pcb_fprintf(FP, "\tPin[%mr %mr %mr %mr %mr %mr ", + pin->X - element->MarkX, + pin->Y - element->MarkY, pin->Thickness, pin->Clearance, pin->Mask, pin->DrillingHole); + PrintQuotedString(FP, (char *) EMPTY(pin->Name)); + fprintf(FP, " "); + PrintQuotedString(FP, (char *) EMPTY(pin->Number)); + fprintf(FP, " %s]\n", F2S(pin, PIN_TYPE)); + } + pinlist_foreach(&element->Pad, &it, pad) { + pcb_fprintf(FP, "\tPad[%mr %mr %mr %mr %mr %mr %mr ", + pad->Point1.X - element->MarkX, + pad->Point1.Y - element->MarkY, + pad->Point2.X - element->MarkX, pad->Point2.Y - element->MarkY, pad->Thickness, pad->Clearance, pad->Mask); + PrintQuotedString(FP, (char *) EMPTY(pad->Name)); + fprintf(FP, " "); + PrintQuotedString(FP, (char *) EMPTY(pad->Number)); + fprintf(FP, " %s]\n", F2S(pad, PAD_TYPE)); + } + linelist_foreach(&element->Line, &it, line) { + pcb_fprintf(FP, "\tElementLine [%mr %mr %mr %mr %mr]\n", + line->Point1.X - element->MarkX, + line->Point1.Y - element->MarkY, + line->Point2.X - element->MarkX, line->Point2.Y - element->MarkY, line->Thickness); + } + linelist_foreach(&element->Arc, &it, arc) { + pcb_fprintf(FP, "\tElementArc [%mr %mr %mr %mr %ma %ma %mr]\n", + arc->X - element->MarkX, + arc->Y - element->MarkY, arc->Width, arc->Height, arc->StartAngle, arc->Delta, arc->Thickness); + } + fputs("\n\t)\n", FP); + } +} + +/* --------------------------------------------------------------------------- + * writes layer data + */ +static void WriteLayerData(FILE * FP, Cardinal Number, LayerTypePtr layer) +{ + gdl_iterator_t it; + LineType *line; + ArcType *arc; + TextType *text; + PolygonType *polygon; + + /* write information about non empty layers */ + if (!LAYER_IS_EMPTY(layer) || (layer->Name && *layer->Name)) { + fprintf(FP, "Layer(%i ", (int) Number + 1); + PrintQuotedString(FP, (char *) EMPTY(layer->Name)); + fputs(")\n(\n", FP); + WriteAttributeList(FP, &layer->Attributes, "\t"); + + linelist_foreach(&layer->Line, &it, line) { + pcb_fprintf(FP, "\tLine[%mr %mr %mr %mr %mr %mr %s]\n", + line->Point1.X, line->Point1.Y, + line->Point2.X, line->Point2.Y, line->Thickness, line->Clearance, F2S(line, LINE_TYPE)); + } + arclist_foreach(&layer->Arc, &it, arc) { + pcb_fprintf(FP, "\tArc[%mr %mr %mr %mr %mr %mr %ma %ma %s]\n", + arc->X, arc->Y, arc->Width, + arc->Height, arc->Thickness, arc->Clearance, arc->StartAngle, arc->Delta, F2S(arc, ARC_TYPE)); + } + textlist_foreach(&layer->Text, &it, text) { + pcb_fprintf(FP, "\tText[%mr %mr %d %d ", text->X, text->Y, text->Direction, text->Scale); + PrintQuotedString(FP, (char *) EMPTY(text->TextString)); + fprintf(FP, " %s]\n", F2S(text, TEXT_TYPE)); + } + textlist_foreach(&layer->Polygon, &it, polygon) { + int p, i = 0; + Cardinal hole = 0; + fprintf(FP, "\tPolygon(%s)\n\t(", F2S(polygon, POLYGON_TYPE)); + for (p = 0; p < polygon->PointN; p++) { + PointTypePtr point = &polygon->Points[p]; + + if (hole < polygon->HoleIndexN && p == polygon->HoleIndex[hole]) { + if (hole > 0) + fputs("\n\t\t)", FP); + fputs("\n\t\tHole (", FP); + hole++; + i = 0; + } + + if (i++ % 5 == 0) { + fputs("\n\t\t", FP); + if (hole) + fputs("\t", FP); + } + pcb_fprintf(FP, "[%mr %mr] ", point->X, point->Y); + } + if (hole > 0) + fputs("\n\t\t)", FP); + fputs("\n\t)\n", FP); + } + fputs(")\n", FP); + } +} + +/* --------------------------------------------------------------------------- + * writes just the elements in the buffer to file + */ +static int WriteBuffer(FILE * FP) +{ + Cardinal i; + + WriteViaData(FP, PASTEBUFFER->Data); + WriteElementData(FP, PASTEBUFFER->Data); + for (i = 0; i < max_copper_layer + 2; i++) + WriteLayerData(FP, i, &(PASTEBUFFER->Data->Layer[i])); + return (STATUS_OK); +} + +/* --------------------------------------------------------------------------- + * writes PCB to file + */ +static int WritePCB(FILE * FP) +{ + Cardinal i; + + WritePCBInfoHeader(FP); + WritePCBDataHeader(FP); + WritePCBFontData(FP); + WriteAttributeList(FP, &PCB->Attributes, ""); + WriteViaData(FP, PCB->Data); + WriteElementData(FP, PCB->Data); + WritePCBRatData(FP); + for (i = 0; i < max_copper_layer + 2; i++) + WriteLayerData(FP, i, &(PCB->Data->Layer[i])); + WritePCBNetlistData(FP); + WritePCBNetlistPatchData(FP); + + return (STATUS_OK); +} + +/* --------------------------------------------------------------------------- + * writes PCB to file + */ +static int WritePCBFile(char *Filename) +{ + FILE *fp; + int result; + + if ((fp = fopen(Filename, "w")) == NULL) { + OpenErrorMessage(Filename); + return (STATUS_ERROR); + } + result = WritePCB(fp); + fclose(fp); + return (result); +} + +/* --------------------------------------------------------------------------- + * writes to pipe using the command defined by conf_core.rc.save_command + * %f are replaced by the passed filename + */ +static int WritePipe(char *Filename, bool thePcb) +{ + FILE *fp; + int result; + char *p; + static gds_t command; + int used_popen = 0; + + if (EMPTY_STRING_P(conf_core.rc.save_command)) { + fp = fopen(Filename, "w"); + if (fp == 0) { + Message("Unable to write to file %s\n", Filename); + return STATUS_ERROR; + } + } + else { + used_popen = 1; + /* setup commandline */ + gds_truncate(&command,0); + for (p = conf_core.rc.save_command; *p; p++) { + /* copy character if not special or add string to command */ + if (!(*p == '%' && *(p + 1) == 'f')) + gds_append(&command, *p); + else { + gds_append_str(&command, Filename); + + /* skip the character */ + p++; + } + } + printf("write to pipe \"%s\"\n", command.array); + if ((fp = popen(command.array, "w")) == NULL) { + PopenErrorMessage(command.array); + return (STATUS_ERROR); + } + } + if (thePcb) { + if (PCB->is_footprint) { + WriteElementData(fp, PCB->Data); + result = 0; + } + else + result = WritePCB(fp); + } + else + result = WriteBuffer(fp); + + if (used_popen) + return (pclose(fp) ? STATUS_ERROR : result); + return (fclose(fp) ? STATUS_ERROR : result); +} + +/* --------------------------------------------------------------------------- + * saves the layout in a temporary file + * this is used for fatal errors and does not call the program specified + * in 'saveCommand' for safety reasons + */ +void SaveInTMP(void) +{ + char filename[80]; + + /* memory might have been released before this function is called */ + if (PCB && PCB->Changed) { + sprintf(filename, EMERGENCY_NAME, (int) getpid()); + Message(_("Trying to save your layout in '%s'\n"), filename); + WritePCBFile(filename); + } +} + +/* --------------------------------------------------------------------------- + * front-end for 'SaveInTMP()' + * just makes sure that the routine is only called once + */ +static bool dont_save_any_more = false; +void EmergencySave(void) +{ + + if (!dont_save_any_more) { + SaveInTMP(); + dont_save_any_more = true; + } +} + +void DisableEmergencySave(void) +{ + dont_save_any_more = true; +} + +/* ---------------------------------------------------------------------- + * Callback for the autosave + */ + +static hidval backup_timer; + +/* + * If the backup interval is > 0 then set another timer. Otherwise + * we do nothing and it is up to the GUI to call EnableAutosave() + * after setting conf_core.rc.backup_interval > 0 again. + */ +static void backup_cb(hidval data) +{ + backup_timer.ptr = NULL; + Backup(); + if (conf_core.rc.backup_interval > 0 && gui->add_timer) + backup_timer = gui->add_timer(backup_cb, 1000 * conf_core.rc.backup_interval, data); +} + +void EnableAutosave(void) +{ + hidval x; + + x.ptr = NULL; + + /* If we already have a timer going, then cancel it out */ + if (backup_timer.ptr != NULL && gui->stop_timer) + gui->stop_timer(backup_timer); + + backup_timer.ptr = NULL; + /* Start up a new timer */ + if (conf_core.rc.backup_interval > 0 && gui->add_timer) + backup_timer = gui->add_timer(backup_cb, 1000 * conf_core.rc.backup_interval, x); +} + +/* --------------------------------------------------------------------------- + * creates backup file. The default is to use the pcb file name with + * a "-" appended (like "foo.pcb-") and if we don't have a pcb file name + * then use the template in BACKUP_NAME + */ +void Backup(void) +{ + char *filename = NULL; + + if (PCB && PCB->Filename) { + filename = (char *) malloc(sizeof(char) * (strlen(PCB->Filename) + 2)); + if (filename == NULL) { + fprintf(stderr, "Backup(): malloc failed\n"); + exit(1); + } + sprintf(filename, "%s-", PCB->Filename); + } + else { + /* BACKUP_NAME has %.8i which will be replaced by the process ID */ + filename = (char *) malloc(sizeof(char) * (strlen(BACKUP_NAME) + 8)); + if (filename == NULL) { + fprintf(stderr, "Backup(): malloc failed\n"); + exit(1); + } + sprintf(filename, BACKUP_NAME, (int) getpid()); + } + + WritePCBFile(filename); + free(filename); +} + +#if !defined(HAS_ATEXIT) && !defined(HAS_ON_EXIT) +/* --------------------------------------------------------------------------- + * makes a temporary copy of the data. This is useful for systems which + * doesn't support calling functions on exit. We use this to save the data + * before LEX and YACC functions are called because they are able to abort + * the program. + */ +void SaveTMPData(void) +{ + sprintf(TMPFilename, EMERGENCY_NAME, (int) getpid()); + WritePCBFile(TMPFilename); +} + +/* --------------------------------------------------------------------------- + * removes the temporary copy of the data file + */ +void RemoveTMPData(void) +{ + unlink(TMPFilename); +} +#endif + +#define BLANK(x) ((x) == ' ' || (x) == '\t' || (x) == '\n' \ + || (x) == '\0') + +/* --------------------------------------------------------------------------- + * Read in a netlist and store it in the netlist menu + */ + +int ReadNetlist(char *filename) +{ + char *command = NULL; + char inputline[MAX_NETLIST_LINE_LENGTH + 1]; + char temp[MAX_NETLIST_LINE_LENGTH + 1]; + FILE *fp; + LibraryMenuTypePtr menu = NULL; + LibraryEntryTypePtr entry; + int i, j, lines, kind; + bool continued; + int used_popen = 0; + + if (!filename) + return (1); /* nothing to do */ + + Message(_("Importing PCB netlist %s\n"), filename); + + if (EMPTY_STRING_P(conf_core.rc.rat_command)) { + fp = fopen(filename, "r"); + if (!fp) { + Message("Cannot open %s for reading", filename); + return 1; + } + } + else { + used_popen = 1; + command = EvaluateFilename(conf_core.rc.rat_command, conf_core.rc.rat_path, filename, NULL); + + /* open pipe to stdout of command */ + if (*command == '\0' || (fp = popen(command, "r")) == NULL) { + PopenErrorMessage(command); + free(command); + return (1); + } + free(command); + } + lines = 0; + /* kind = 0 is net name + * kind = 1 is route style name + * kind = 2 is connection + */ + kind = 0; + while (fgets(inputline, MAX_NETLIST_LINE_LENGTH, fp)) { + size_t len = strlen(inputline); + /* check for maximum length line */ + if (len) { + if (inputline[--len] != '\n') + Message(_("Line length (%i) exceeded in netlist file.\n" + "additional characters will be ignored.\n"), MAX_NETLIST_LINE_LENGTH); + else + inputline[len] = '\0'; + } + continued = (inputline[len - 1] == '\\') ? true : false; + if (continued) + inputline[len - 1] = '\0'; + lines++; + i = 0; + while (inputline[i] != '\0') { + j = 0; + /* skip leading blanks */ + while (inputline[i] != '\0' && BLANK(inputline[i])) + i++; + if (kind == 0) { + /* add two spaces for included/unincluded */ + temp[j++] = ' '; + temp[j++] = ' '; + } + while (!BLANK(inputline[i])) + temp[j++] = inputline[i++]; + temp[j] = '\0'; + while (inputline[i] != '\0' && BLANK(inputline[i])) + i++; + if (kind == 0) { + menu = GetLibraryMenuMemory(&PCB->NetlistLib[NETLIST_INPUT], NULL); + menu->Name = strdup(temp); + menu->flag = 1; + kind++; + } + else { + if (kind == 1 && strchr(temp, '-') == NULL) { + kind++; + menu->Style = strdup(temp); + } + else { + entry = GetLibraryEntryMemory(menu); + entry->ListEntry = strdup(temp); + entry->ListEntry_dontfree = 0; + } + } + } + if (!continued) + kind = 0; + } + if (!lines) { + Message(_("Empty netlist file!\n")); + pclose(fp); + return (1); + } + if (used_popen) + pclose(fp); + else + fclose(fp); + sort_netlist(); + rats_patch_make_edited(PCB); + return (0); +} + +int ImportNetlist(char *filename) +{ + FILE *fp; + char buf[16]; + int i; + char *p; + + + if (!filename) + return (1); /* nothing to do */ + fp = fopen(filename, "r"); + if (!fp) + return (1); /* bad filename */ + i = fread(buf, 1, sizeof(buf) - 1, fp); + fclose(fp); + buf[i] = '\0'; + p = buf; + while (*p) { + *p = tolower((int) *p); + p++; + } + p = strstr(buf, "edif"); + if (!p) + return ReadNetlist(filename); + else + return stub_ReadEdifNetlist(filename); +} Index: trunk/src_plugins/io_pcb/file.h =================================================================== --- trunk/src_plugins/io_pcb/file.h (nonexistent) +++ trunk/src_plugins/io_pcb/file.h (revision 1761) @@ -0,0 +1,81 @@ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Contact addresses for paper mail and Email: + * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany + * Thomas.Nau@rz.uni-ulm.de + * + */ + +/* prototypes for file routines + */ + +#ifndef PCB_FILE_H +#define PCB_FILE_H + +#include /* needed to define 'FILE *' */ +#include "global.h" + +FILE *CheckAndOpenFile(char *, bool, bool, bool *, bool *); +FILE *OpenConnectionDataFile(void); +int SavePCB(char *); +int LoadPCB(char *, bool, bool); +int RevertPCB(void); +void EnableAutosave(void); +void Backup(void); +void SaveInTMP(void); +void EmergencySave(void); +void DisableEmergencySave(void); +int ImportNetlist(char *); +int SaveBufferElements(char *); +void PreLoadElementPCB(void); +void PostLoadElementPCB(void); +void sort_netlist(void); + +/* + * Whenever the pcb file format is modified, this version number + * should be updated to the date when the new code is committed. + * It will be written out to the file and also used by pcb to give + * guidance to the user as to what the minimum version of pcb required + * is. + */ + +/* This is the version needed by the file we're saving. */ +int PCBFileVersionNeeded(void); + +/* This is the version we support. */ +#define PCB_FILE_VERSION 20110603 + + +#ifndef HAS_ATEXIT +#ifdef HAS_ON_EXIT +void GlueEmergencySave(int, caddr_t); +#else +void SaveTMPData(void); +void RemoveTMPData(void); +#endif +#endif + +void PrintQuotedString(FILE *, const char *); + +void file_uninit(); +void sort_library(LibraryTypePtr lib); + +#endif Index: trunk/src_plugins/io_pcb/parse_l.c =================================================================== --- trunk/src_plugins/io_pcb/parse_l.c (nonexistent) +++ trunk/src_plugins/io_pcb/parse_l.c (revision 1761) @@ -0,0 +1,2501 @@ + +#line 3 "lex.yy.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart(yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +extern int yyleng; + +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires + * access to the local variable yy_act. Since yyless() is a macro, it would break + * existing scanners that call yyless() from OUTSIDE yylex. + * One obvious solution it to make yy_act a global. I tried that, and saw + * a 5% performance hit in a non-yylineno scanner, because yy_act is + * normally declared as a register variable-- so it is not worth it. + */ + #define YY_LESS_LINENO(n) \ + do { \ + int yyl;\ + for ( yyl = n; yyl < yyleng; ++yyl )\ + if ( yytext[yyl] == '\n' )\ + --yylineno;\ + }while(0) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart (FILE *input_file ); +void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); +void yy_delete_buffer (YY_BUFFER_STATE b ); +void yy_flush_buffer (YY_BUFFER_STATE b ); +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state (void ); + +static void yyensure_buffer_stack (void ); +static void yy_load_buffer_state (void ); +static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); + +#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ); + +void *yyalloc (yy_size_t ); +void *yyrealloc (void *,yy_size_t ); +void yyfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +typedef unsigned char YY_CHAR; + +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; + +typedef int yy_state_type; + +extern int yylineno; + +int yylineno = 1; + +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +static void yy_fatal_error (yyconst char msg[] ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 55 +#define YY_END_OF_BUFFER 56 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[222] = + { 0, + 0, 0, 56, 54, 51, 52, 53, 54, 50, 54, + 54, 47, 47, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 39, 54, 54, 51, 0, 49, 0, + 50, 0, 47, 47, 46, 0, 47, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 44, 40, 0, 38, + 36, 37, 45, 46, 48, 27, 0, 0, 0, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, + + 2, 11, 10, 0, 14, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 0, 43, 0, 0, 0, 0, + 0, 0, 0, 3, 0, 26, 0, 13, 22, 0, + 0, 0, 0, 0, 16, 0, 0, 0, 42, 0, + 41, 0, 0, 0, 0, 0, 8, 0, 9, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 4, 0, 0, 23, 0, 0, 0, 0, 24, + 21, 0, 0, 0, 0, 0, 30, 19, 0, 28, + 0, 25, 0, 0, 5, 0, 0, 0, 0, 0, + 0, 0, 0, 6, 0, 0, 32, 0, 33, 35, + + 0, 0, 0, 0, 15, 0, 0, 18, 0, 0, + 0, 20, 0, 17, 1, 0, 0, 31, 0, 34, + 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 5, 6, 1, 1, 1, 7, 1, + 1, 1, 8, 1, 8, 9, 1, 10, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 1, 1, 1, + 1, 1, 1, 1, 12, 13, 14, 15, 16, 17, + 18, 19, 1, 1, 1, 20, 21, 22, 1, 23, + 1, 24, 25, 26, 1, 27, 1, 1, 1, 1, + 1, 28, 1, 1, 29, 1, 30, 31, 32, 33, + + 34, 35, 36, 37, 38, 1, 39, 40, 41, 42, + 43, 44, 1, 45, 46, 47, 48, 1, 1, 49, + 50, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[51] = + { 0, + 1, 1, 2, 3, 1, 1, 1, 1, 1, 4, + 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, + 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[226] = + { 0, + 0, 0, 256, 257, 253, 257, 257, 46, 0, 0, + 42, 45, 46, 13, 16, 230, 213, 23, 207, 208, + 32, 220, 215, 52, 35, 21, 38, 210, 214, 36, + 212, 203, 203, 38, 202, 201, 239, 73, 257, 236, + 0, 232, 229, 74, 70, 0, 77, 205, 189, 193, + 189, 219, 198, 191, 200, 53, 189, 178, 185, 181, + 178, 211, 190, 180, 181, 173, 187, 168, 176, 167, + 181, 184, 180, 182, 173, 170, 257, 257, 169, 257, + 257, 170, 257, 82, 0, 257, 162, 164, 159, 257, + 163, 169, 166, 168, 152, 165, 164, 163, 157, 175, + + 257, 257, 257, 144, 257, 146, 152, 160, 143, 144, + 257, 159, 145, 146, 156, 257, 144, 145, 148, 138, + 146, 152, 132, 257, 133, 257, 131, 257, 257, 137, + 77, 144, 139, 129, 257, 130, 138, 133, 257, 136, + 257, 136, 134, 120, 122, 129, 257, 116, 257, 115, + 115, 116, 116, 111, 116, 125, 111, 119, 109, 103, + 103, 257, 102, 103, 257, 100, 112, 103, 108, 257, + 123, 102, 99, 111, 97, 91, 257, 85, 91, 113, + 105, 257, 94, 95, 257, 90, 101, 88, 95, 83, + 89, 88, 93, 257, 85, 74, 257, 68, 257, 257, + + 80, 69, 67, 62, 257, 74, 60, 257, 72, 62, + 71, 257, 57, 257, 257, 63, 61, 257, 67, 257, + 257, 113, 117, 121, 63 + } ; + +static yyconst flex_int16_t yy_def[226] = + { 0, + 221, 1, 221, 221, 221, 221, 221, 222, 223, 224, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 222, 221, 222, + 223, 221, 221, 221, 221, 225, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 225, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 0, 221, 221, 221, 221 + } ; + +static yyconst flex_int16_t yy_nxt[308] = + { 0, + 4, 5, 6, 7, 8, 9, 10, 11, 4, 12, + 13, 14, 4, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 4, 4, 29, + 4, 30, 31, 4, 4, 4, 4, 32, 33, 4, + 34, 35, 4, 4, 4, 4, 4, 36, 4, 4, + 39, 43, 44, 45, 45, 47, 47, 48, 50, 49, + 54, 58, 55, 51, 66, 62, 85, 68, 67, 59, + 69, 70, 74, 40, 71, 79, 75, 39, 80, 84, + 84, 63, 45, 47, 47, 45, 47, 47, 151, 64, + 94, 84, 84, 46, 65, 95, 190, 220, 219, 218, + + 40, 217, 216, 215, 191, 214, 213, 212, 211, 210, + 209, 208, 152, 38, 207, 206, 38, 41, 205, 41, + 41, 42, 204, 42, 42, 203, 202, 201, 200, 199, + 198, 197, 196, 195, 194, 193, 192, 189, 188, 187, + 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, + 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, + 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, + 156, 155, 154, 153, 150, 149, 148, 147, 146, 145, + 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, + 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, + + 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, + 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, + 104, 103, 102, 101, 100, 99, 98, 97, 96, 93, + 92, 91, 90, 89, 88, 87, 86, 45, 83, 38, + 37, 82, 81, 78, 77, 76, 73, 72, 61, 60, + 57, 56, 53, 52, 37, 221, 3, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + + 221, 221, 221, 221, 221, 221, 221 + } ; + +static yyconst flex_int16_t yy_chk[308] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 8, 11, 11, 12, 13, 13, 13, 14, 15, 14, + 18, 21, 18, 15, 25, 24, 225, 26, 25, 21, + 26, 27, 30, 8, 27, 34, 30, 38, 34, 45, + 45, 24, 44, 44, 44, 47, 47, 47, 131, 24, + 56, 84, 84, 12, 24, 56, 178, 219, 217, 216, + + 38, 213, 211, 210, 178, 209, 207, 206, 204, 203, + 202, 201, 131, 222, 198, 196, 222, 223, 195, 223, + 223, 224, 193, 224, 224, 192, 191, 190, 189, 188, + 187, 186, 184, 183, 181, 180, 179, 176, 175, 174, + 173, 172, 171, 169, 168, 167, 166, 164, 163, 161, + 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, + 150, 148, 146, 145, 144, 143, 142, 140, 138, 137, + 136, 134, 133, 132, 130, 127, 125, 123, 122, 121, + 120, 119, 118, 117, 115, 114, 113, 112, 110, 109, + 108, 107, 106, 104, 100, 99, 98, 97, 96, 95, + + 94, 93, 92, 91, 89, 88, 87, 82, 79, 76, + 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, + 65, 64, 63, 62, 61, 60, 59, 58, 57, 55, + 54, 53, 52, 51, 50, 49, 48, 43, 42, 40, + 37, 36, 35, 33, 32, 31, 29, 28, 23, 22, + 20, 19, 17, 16, 5, 3, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, + + 221, 221, 221, 221, 221, 221, 221 + } ; + +/* Table of booleans, true if rule could match eol. */ +static yyconst flex_int32_t yy_rule_can_match_eol[56] = + { 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, }; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +extern int yy_flex_debug; +int yy_flex_debug = 0; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *yytext; +#line 1 "../../src_plugins/io_pcb/parse_l.l" +/* $Id$ */ +#line 4 "../../src_plugins/io_pcb/parse_l.l" +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 1994,1995,1996,2006 Thomas Nau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Contact addresses for paper mail and Email: + * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany + * Thomas.Nau@rz.uni-ulm.de + * + */ + +/* lexical definitions to parse ASCII input of PCB and Element description + */ + +#include "config.h" +#include "conf_core.h" + +#include +#include +#include +#include + +#if defined(_POSIX_SOURCE) || defined(_HPUX_SOURCE) +#include +#endif + +#include "global.h" + +#ifdef HAVE_LIBDMALLOC +# include /* see http://dmalloc.com */ +#endif + +RCSID("$Id$"); + + +#include "global.h" +#include "crosshair.h" +#include "data.h" +#include "error.h" +#include "file.h" +#include "mymem.h" +#include "misc.h" +#include "strflags.h" +#include "parse_l.h" +#include "parse_y.h" +#include "create.h" +#include "plug_footprint.h" + +#define YY_NO_INPUT + +/* --------------------------------------------------------------------------- + * some shared parser identifiers + */ +#ifdef FLEX_SCANNER + +#define yyunput ATTRIBUTE_UNUSED yyunput +#endif + +char *yyfilename; /* in this file */ +PCBTypePtr yyPCB; /* used by parser */ +DataTypePtr yyData; +ElementTypePtr yyElement; +FontTypePtr yyFont; + +static int parse_number (void); + +/* --------------------------------------------------------------------------- + * an external prototypes + */ +int yyparse(void); + +/* --------------------------------------------------------------------------- + * some local prototypes + */ +static int Parse(FILE *, char *, char *, char *, char *); + +#line 713 "lex.yy.c" + +#define INITIAL 0 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals (void ); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy (void ); + +int yyget_debug (void ); + +void yyset_debug (int debug_flag ); + +YY_EXTRA_TYPE yyget_extra (void ); + +void yyset_extra (YY_EXTRA_TYPE user_defined ); + +FILE *yyget_in (void ); + +void yyset_in (FILE * in_str ); + +FILE *yyget_out (void ); + +void yyset_out (FILE * out_str ); + +int yyget_leng (void ); + +char *yyget_text (void ); + +int yyget_lineno (void ); + +void yyset_lineno (int line_number ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap (void ); +#else +extern int yywrap (void ); +#endif +#endif + + static void yyunput (int c,char *buf_ptr ); + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (void ); +#else +static int input (void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex (void); + +#define YY_DECL int yylex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 104 "../../src_plugins/io_pcb/parse_l.l" + + +#line 903 "lex.yy.c" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer(yyin,YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 222 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 257 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) + { + int yyl; + for ( yyl = 0; yyl < yyleng; ++yyl ) + if ( yytext[yyl] == '\n' ) + + yylineno++; +; + } + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 106 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_FILEVERSION); } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 107 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_PCB); } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 108 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_GRID); } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 109 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_CURSOR); } + YY_BREAK +case 5: +YY_RULE_SETUP +#line 110 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_THERMAL); } + YY_BREAK +case 6: +YY_RULE_SETUP +#line 111 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_AREA); } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 112 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_DRC); } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 113 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_FLAGS); } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 114 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_LAYER); } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 115 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_PIN); } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 116 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_PAD); } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 117 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_VIA); } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 118 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_LINE); } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 119 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_RAT); } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 120 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_RECTANGLE); } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 121 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_TEXT); } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 122 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_ELEMENTLINE); } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 123 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_ELEMENTARC); } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 124 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_ELEMENT); } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 125 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_SYMBOLLINE); } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 126 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_SYMBOL); } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 127 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_MARK); } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 128 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_GROUPS); } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 129 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_STYLES); } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 130 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_POLYGON); } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 131 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_POLYGON_HOLE); } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 132 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_ARC); } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 133 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_NETLIST); } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 134 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_NET); } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 135 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_CONN); } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 136 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_NETLISTPATCH); } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 137 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_ADD_CONN); } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 138 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_DEL_CONN); } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 139 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_CHANGE_ATTRIB); } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 140 "../../src_plugins/io_pcb/parse_l.l" +{ return(T_ATTRIBUTE); } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 142 "../../src_plugins/io_pcb/parse_l.l" +{ return T_NM; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 143 "../../src_plugins/io_pcb/parse_l.l" +{ return T_UM; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 144 "../../src_plugins/io_pcb/parse_l.l" +{ return T_MM; } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 145 "../../src_plugins/io_pcb/parse_l.l" +{ return T_M; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 146 "../../src_plugins/io_pcb/parse_l.l" +{ return T_KM; } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 147 "../../src_plugins/io_pcb/parse_l.l" +{ return T_UMIL; } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 148 "../../src_plugins/io_pcb/parse_l.l" +{ return T_CMIL; } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 149 "../../src_plugins/io_pcb/parse_l.l" +{ return T_MIL; } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 150 "../../src_plugins/io_pcb/parse_l.l" +{ return T_IN; } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 152 "../../src_plugins/io_pcb/parse_l.l" +{ + yylval.integer = (unsigned) *(yytext+1); + return(CHAR_CONST); + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 156 "../../src_plugins/io_pcb/parse_l.l" +{ return parse_number(); } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 157 "../../src_plugins/io_pcb/parse_l.l" +{ yylval.integer = round (strtod (yytext, NULL)); return INTEGER; } + YY_BREAK +case 48: +YY_RULE_SETUP +#line 159 "../../src_plugins/io_pcb/parse_l.l" +{ unsigned n; + sscanf((char *) yytext, "%x", &n); + yylval.integer = n; + return INTEGER; + } + YY_BREAK +case 49: +YY_RULE_SETUP +#line 164 "../../src_plugins/io_pcb/parse_l.l" +{ + char *p1, *p2; + + /* return NULL on empty string */ + if (yyleng == 2) + { + yylval.string = NULL; + return(STRING); + } + + /* allocate memory and copy string; + * stringlength is counted and copied without + * leading and trailing '"' + */ + yyleng -= 2; + yylval.string = (char *)calloc (yyleng+1, sizeof (char)); + p1 = (char *) (yytext +1); + p2 = yylval.string; + while(yyleng--) + { + /* check for special character */ + if (*p1 == '\\') + { + yyleng--; + p1++; + + } + *p2++ = *p1++; + } + *p2 = '\0'; + return(STRING); + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 196 "../../src_plugins/io_pcb/parse_l.l" +{} + YY_BREAK +case 51: +YY_RULE_SETUP +#line 197 "../../src_plugins/io_pcb/parse_l.l" +{} + YY_BREAK +case 52: +/* rule 52 can match eol */ +YY_RULE_SETUP +#line 198 "../../src_plugins/io_pcb/parse_l.l" +{ +#ifndef FLEX_SCANNER + yylineno++; +#endif + } + YY_BREAK +case 53: +YY_RULE_SETUP +#line 203 "../../src_plugins/io_pcb/parse_l.l" +{} + YY_BREAK +case 54: +YY_RULE_SETUP +#line 204 "../../src_plugins/io_pcb/parse_l.l" +{ return(*yytext); } + YY_BREAK +case 55: +YY_RULE_SETUP +#line 206 "../../src_plugins/io_pcb/parse_l.l" +ECHO; + YY_BREAK +#line 1314 "lex.yy.c" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (void) +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), (size_t) num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart(yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 222 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 222 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 221); + + return yy_is_jam ? 0 : yy_current_state; +} + + static void yyunput (int c, register char * yy_bp ) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + if ( c == '\n' ){ + --yylineno; + } + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#endif + +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart(yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return EOF; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + if ( c == '\n' ) + + yylineno++; +; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer(yyin,YY_BUF_SIZE ); + } + + yy_init_buffer(YY_CURRENT_BUFFER,input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void yy_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer(b,file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yy_delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree((void *) b->yy_ch_buf ); + + yyfree((void *) b ); +} + +#ifndef __cplusplus +extern int isatty (int ); +#endif /* __cplusplus */ + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + yy_flush_buffer(b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yy_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (void) +{ + int num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer(b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) +{ + + return yy_scan_bytes(yystr,strlen(yystr) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) yyalloc(n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer(buf,n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg ) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int yyget_lineno (void) +{ + + return yylineno; +} + +/** Get the input stream. + * + */ +FILE *yyget_in (void) +{ + return yyin; +} + +/** Get the output stream. + * + */ +FILE *yyget_out (void) +{ + return yyout; +} + +/** Get the length of the current token. + * + */ +int yyget_leng (void) +{ + return yyleng; +} + +/** Get the current token. + * + */ + +char *yyget_text (void) +{ + return yytext; +} + +/** Set the current line number. + * @param line_number + * + */ +void yyset_lineno (int line_number ) +{ + + yylineno = line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * in_str ) +{ + yyin = in_str ; +} + +void yyset_out (FILE * out_str ) +{ + yyout = out_str ; +} + +int yyget_debug (void) +{ + return yy_flex_debug; +} + +void yyset_debug (int bdebug ) +{ + yy_flex_debug = bdebug ; +} + +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + /* We do not touch yylineno unless the option is enabled. */ + yylineno = 1; + + (yy_buffer_stack) = 0; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = (char *) 0; + (yy_init) = 0; + (yy_start) = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = (FILE *) 0; + yyout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(); + } + + /* Destroy the stack itself. */ + yyfree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *yyrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void yyfree (void * ptr ) +{ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 206 "../../src_plugins/io_pcb/parse_l.l" + + + +/* --------------------------------------------------------------------------- + * sets up the preprocessor command + */ +static int Parse(FILE *Pipe, char *Executable, char *Path, char *Filename, char *Parameter) +{ + static char *command = NULL; + int returncode; + int used_popen = 0; + char *tmps; + size_t l; +#ifdef FLEX_SCANNER + static bool firsttime = true; +#endif + + if (Pipe == NULL) { + if (EMPTY_STRING_P (Executable)) + { + l = 2; + if ( Path != NULL ) + l += strlen (Path); + + l += strlen (Filename); + + if ( (tmps = (char *) malloc ( l * sizeof (char))) == NULL) + { + fprintf (stderr, "Parse(): malloc failed\n"); + exit (1); + } + + if ( Path != NULL && *Path != '\0') + sprintf (tmps, "%s%s%s", Path, PCB_DIR_SEPARATOR_S, Filename); + else + sprintf (tmps, "%s", Filename); + + yyin = fopen (tmps, "r"); +printf("OPENING: %s -> %p\n", tmps, yyin); + if (!yyin) + { + /* Special case this one, we get it all the time... */ + if (strcmp (tmps, "./default_font")) + Message("Can't open %s for reading\n", tmps); + return(1); + } + free (tmps); + } + else + { + used_popen = 1; + + command = EvaluateFilename(Executable, Path, Filename, Parameter); + + /* open pipe to stdout of command */ + if (*command == '\0' || (yyin = popen(command, "r")) == NULL) + { + PopenErrorMessage(command); + free(command); + return(1); + } + free(command); + } + } + else { + yyin = Pipe; + } + +#ifdef FLEX_SCANNER + /* reset parser if not called the first time */ + if (!firsttime) + yyrestart(yyin); + firsttime = false; +#endif + + /* init linenumber and filename for yyerror() */ + yylineno = 1; + yyfilename = Filename; + + /* We need to save the data temporarily because lex-yacc are able + * to break the application if the input file has an illegal format. + * It's not necessary if the system supports the call of functions + * on termination. + */ + + CreateBeLenient (true); + +#if !defined(HAS_ATEXIT) && !defined(HAS_ON_EXIT) + if (PCB && PCB->Data) + SaveTMPData(); + returncode = yyparse(); + RemoveTMPData(); +#else + returncode = yyparse(); +#endif + /* clean up parse buffer */ + yy_delete_buffer(YY_CURRENT_BUFFER); + + CreateBeLenient (false); + + if (Pipe != NULL) + return returncode; + + if (used_popen) + return(pclose(yyin) ? 1 : returncode); + return(fclose(yyin) ? 1 : returncode); +} + +/* --------------------------------------------------------------------------- + * initializes LEX and calls parser for a single element file + */ +int ParseElement(DataTypePtr Ptr, const char *name) +{ + FILE *f; + int ret; + fp_fopen_ctx_t st; + + yyPCB = NULL; + yyData = Ptr; + yyFont = &PCB->Font; + yyElement = NULL; + + f = fp_fopen(conf_core.rc.library_search_paths, name, &st); + + if (f == NULL) + return -1; + + ret = Parse(f, NULL,NULL,NULL,NULL); + + fp_fclose(f, &st); + + return(ret); +} + +/* --------------------------------------------------------------------------- + * initializes LEX and calls parser for a complete board + */ +int ParsePCB(PCBTypePtr Ptr, char *Filename) +{ + int retval; + yyPCB = Ptr; + yyData = NULL; + yyFont = NULL; + yyElement = NULL; + setlocale(LC_ALL, "C"); /* make sure numerics are read predictably */ + retval = Parse(NULL, conf_core.rc.file_command, conf_core.rc.file_path, Filename, NULL); + setlocale(LC_ALL, ""); + return retval; +} + +/* --------------------------------------------------------------------------- + * initializes LEX and calls parser for a font + */ +int ParseFont(FontTypePtr Ptr, char *Filename) +{ + int r = 0; + char *path, *p; + yyPCB = NULL; + yyFont = Ptr; + yyElement = NULL; + + r = Parse(NULL, conf_core.rc.font_command, NULL, Filename, NULL); + if (r == 0) { +#ifdef DEBUG + Message ("Found %s in %s\n", Filename, p); +#endif + } + return r; +} + +static int +parse_number () +{ + yylval.number = strtod ((char *) yytext, NULL); + return FLOATING; +} + + Index: trunk/src_plugins/io_pcb/parse_l.h =================================================================== --- trunk/src_plugins/io_pcb/parse_l.h (nonexistent) +++ trunk/src_plugins/io_pcb/parse_l.h (revision 1761) @@ -0,0 +1,40 @@ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Contact addresses for paper mail and Email: + * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany + * Thomas.Nau@rz.uni-ulm.de + * + * RCS: $Id$ + */ + +/* just defines common parser identifiers + */ + +#ifndef PCB_LEX_H +#define PCB_LEX_H + +#include "global.h" + +int ParsePCB(PCBTypePtr, char *); +int ParseElement(DataTypePtr, const char *); +int ParseFont(FontTypePtr, char *); + +#endif Index: trunk/src_plugins/io_pcb/parse_l.l =================================================================== --- trunk/src_plugins/io_pcb/parse_l.l (nonexistent) +++ trunk/src_plugins/io_pcb/parse_l.l (revision 1761) @@ -0,0 +1,381 @@ +/* $Id$ */ + +%{ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 1994,1995,1996,2006 Thomas Nau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Contact addresses for paper mail and Email: + * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany + * Thomas.Nau@rz.uni-ulm.de + * + */ + +/* lexical definitions to parse ASCII input of PCB and Element description + */ + +#include "config.h" +#include "conf_core.h" + +#include +#include +#include +#include + +#if defined(_POSIX_SOURCE) || defined(_HPUX_SOURCE) +#include +#endif + +#include "global.h" + +#ifdef HAVE_LIBDMALLOC +# include /* see http://dmalloc.com */ +#endif + +RCSID("$Id$"); + + +#include "global.h" +#include "crosshair.h" +#include "data.h" +#include "error.h" +#include "file.h" +#include "mymem.h" +#include "misc.h" +#include "strflags.h" +#include "parse_l.h" +#include "parse_y.h" +#include "create.h" +#include "plug_footprint.h" + +#define YY_NO_INPUT + +/* --------------------------------------------------------------------------- + * some shared parser identifiers + */ +#ifdef FLEX_SCANNER + +#define yyunput ATTRIBUTE_UNUSED yyunput +#endif + +char *yyfilename; /* in this file */ +PCBTypePtr yyPCB; /* used by parser */ +DataTypePtr yyData; +ElementTypePtr yyElement; +FontTypePtr yyFont; + +static int parse_number (void); + +/* --------------------------------------------------------------------------- + * an external prototypes + */ +int yyparse(void); + +/* --------------------------------------------------------------------------- + * some local prototypes + */ +static int Parse(FILE *, char *, char *, char *, char *); + +%} + +HEX 0x[0-9a-fA-F]+ +INTEGER [+-]?([1-9][0-9]*|0) +FLOATING {INTEGER}"."[0-9]* +STRINGCHAR ([^"\n\r\\]|\\.) + +%option yylineno + +%% + +FileVersion { return(T_FILEVERSION); } +PCB { return(T_PCB); } +Grid { return(T_GRID); } +Cursor { return(T_CURSOR); } +Thermal { return(T_THERMAL); } +PolyArea { return(T_AREA); } +DRC { return(T_DRC); } +Flags { return(T_FLAGS); } +Layer { return(T_LAYER); } +Pin { return(T_PIN); } +Pad { return(T_PAD); } +Via { return(T_VIA); } +Line { return(T_LINE); } +Rat { return(T_RAT); } +Rectangle { return(T_RECTANGLE); } +Text { return(T_TEXT); } +ElementLine { return(T_ELEMENTLINE); } +ElementArc { return(T_ELEMENTARC); } +Element { return(T_ELEMENT); } +SymbolLine { return(T_SYMBOLLINE); } +Symbol { return(T_SYMBOL); } +Mark { return(T_MARK); } +Groups { return(T_GROUPS); } +Styles { return(T_STYLES); } +Polygon { return(T_POLYGON); } +Hole { return(T_POLYGON_HOLE); } +Arc { return(T_ARC); } +NetList { return(T_NETLIST); } +Net { return(T_NET); } +Connect { return(T_CONN); } +NetListPatch { return(T_NETLISTPATCH); } +add_conn { return(T_ADD_CONN); } +del_conn { return(T_DEL_CONN); } +change_attrib { return(T_CHANGE_ATTRIB); } +Attribute { return(T_ATTRIBUTE); } + +nm { return T_NM; } +um { return T_UM; } +mm { return T_MM; } +m { return T_M; } +km { return T_KM; } +umil { return T_UMIL; } +cmil { return T_CMIL; } +mil { return T_MIL; } +in { return T_IN; } + +\'.\' { + yylval.integer = (unsigned) *(yytext+1); + return(CHAR_CONST); + } +{FLOATING} { return parse_number(); } +{INTEGER} { yylval.integer = round (strtod (yytext, NULL)); return INTEGER; } + +{HEX} { unsigned n; + sscanf((char *) yytext, "%x", &n); + yylval.integer = n; + return INTEGER; + } +\"{STRINGCHAR}*\" { + char *p1, *p2; + + /* return NULL on empty string */ + if (yyleng == 2) + { + yylval.string = NULL; + return(STRING); + } + + /* allocate memory and copy string; + * stringlength is counted and copied without + * leading and trailing '"' + */ + yyleng -= 2; + yylval.string = (char *)calloc (yyleng+1, sizeof (char)); + p1 = (char *) (yytext +1); + p2 = yylval.string; + while(yyleng--) + { + /* check for special character */ + if (*p1 == '\\') + { + yyleng--; + p1++; + + } + *p2++ = *p1++; + } + *p2 = '\0'; + return(STRING); + } +#.* {} +[ \t]+ {} +[\n] { +#ifndef FLEX_SCANNER + yylineno++; +#endif + } +[\r] {} +. { return(*yytext); } + +%% + +/* --------------------------------------------------------------------------- + * sets up the preprocessor command + */ +static int Parse(FILE *Pipe, char *Executable, char *Path, char *Filename, char *Parameter) +{ + static char *command = NULL; + int returncode; + int used_popen = 0; + char *tmps; + size_t l; +#ifdef FLEX_SCANNER + static bool firsttime = true; +#endif + + if (Pipe == NULL) { + if (EMPTY_STRING_P (Executable)) + { + l = 2; + if ( Path != NULL ) + l += strlen (Path); + + l += strlen (Filename); + + if ( (tmps = (char *) malloc ( l * sizeof (char))) == NULL) + { + fprintf (stderr, "Parse(): malloc failed\n"); + exit (1); + } + + if ( Path != NULL && *Path != '\0') + sprintf (tmps, "%s%s%s", Path, PCB_DIR_SEPARATOR_S, Filename); + else + sprintf (tmps, "%s", Filename); + + yyin = fopen (tmps, "r"); +printf("OPENING: %s -> %p\n", tmps, yyin); + if (!yyin) + { + /* Special case this one, we get it all the time... */ + if (strcmp (tmps, "./default_font")) + Message("Can't open %s for reading\n", tmps); + return(1); + } + free (tmps); + } + else + { + used_popen = 1; + + command = EvaluateFilename(Executable, Path, Filename, Parameter); + + /* open pipe to stdout of command */ + if (*command == '\0' || (yyin = popen(command, "r")) == NULL) + { + PopenErrorMessage(command); + free(command); + return(1); + } + free(command); + } + } + else { + yyin = Pipe; + } + +#ifdef FLEX_SCANNER + /* reset parser if not called the first time */ + if (!firsttime) + yyrestart(yyin); + firsttime = false; +#endif + + /* init linenumber and filename for yyerror() */ + yylineno = 1; + yyfilename = Filename; + + /* We need to save the data temporarily because lex-yacc are able + * to break the application if the input file has an illegal format. + * It's not necessary if the system supports the call of functions + * on termination. + */ + + CreateBeLenient (true); + +#if !defined(HAS_ATEXIT) && !defined(HAS_ON_EXIT) + if (PCB && PCB->Data) + SaveTMPData(); + returncode = yyparse(); + RemoveTMPData(); +#else + returncode = yyparse(); +#endif + /* clean up parse buffer */ + yy_delete_buffer(YY_CURRENT_BUFFER); + + CreateBeLenient (false); + + if (Pipe != NULL) + return returncode; + + if (used_popen) + return(pclose(yyin) ? 1 : returncode); + return(fclose(yyin) ? 1 : returncode); +} + +/* --------------------------------------------------------------------------- + * initializes LEX and calls parser for a single element file + */ +int ParseElement(DataTypePtr Ptr, const char *name) +{ + FILE *f; + int ret; + fp_fopen_ctx_t st; + + yyPCB = NULL; + yyData = Ptr; + yyFont = &PCB->Font; + yyElement = NULL; + + f = fp_fopen(conf_core.rc.library_search_paths, name, &st); + + if (f == NULL) + return -1; + + ret = Parse(f, NULL,NULL,NULL,NULL); + + fp_fclose(f, &st); + + return(ret); +} + +/* --------------------------------------------------------------------------- + * initializes LEX and calls parser for a complete board + */ +int ParsePCB(PCBTypePtr Ptr, char *Filename) +{ + int retval; + yyPCB = Ptr; + yyData = NULL; + yyFont = NULL; + yyElement = NULL; + setlocale(LC_ALL, "C"); /* make sure numerics are read predictably */ + retval = Parse(NULL, conf_core.rc.file_command, conf_core.rc.file_path, Filename, NULL); + setlocale(LC_ALL, ""); + return retval; +} + +/* --------------------------------------------------------------------------- + * initializes LEX and calls parser for a font + */ +int ParseFont(FontTypePtr Ptr, char *Filename) +{ + int r = 0; + char *path, *p; + yyPCB = NULL; + yyFont = Ptr; + yyElement = NULL; + + r = Parse(NULL, conf_core.rc.font_command, NULL, Filename, NULL); + if (r == 0) { +#ifdef DEBUG + Message ("Found %s in %s\n", Filename, p); +#endif + } + return r; +} + +static int +parse_number () +{ + yylval.number = strtod ((char *) yytext, NULL); + return FLOATING; +} + Index: trunk/src_plugins/io_pcb/parse_y.c =================================================================== --- trunk/src_plugins/io_pcb/parse_y.c (nonexistent) +++ trunk/src_plugins/io_pcb/parse_y.c (revision 1761) @@ -0,0 +1,3241 @@ +/* A Bison parser, made by GNU Bison 3.0.2. */ + +/* Bison implementation for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "3.0.2" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + + + + +/* Copy the first part of user declarations. */ +#line 11 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:339 */ + +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Contact addresses for paper mail and Email: + * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany + * Thomas.Nau@rz.uni-ulm.de + * + */ + +/* grammar to parse ASCII input of PCB description + */ + +#include "config.h" +#include "conf_core.h" + +#include "global.h" +#include "create.h" +#include "data.h" +#include "error.h" +#include "file.h" +#include "mymem.h" +#include "misc.h" +#include "parse_l.h" +#include "polygon.h" +#include "remove.h" +#include "rtree.h" +#include "strflags.h" +#include "thermal.h" +#include "rats_patch.h" + +#ifdef HAVE_LIBDMALLOC +# include /* see http://dmalloc.com */ +#endif + +RCSID("$Id$"); + +static LayerTypePtr Layer; +static PolygonTypePtr Polygon; +static SymbolTypePtr Symbol; +static int pin_num; +static LibraryMenuTypePtr Menu; +static bool LayerFlag[MAX_LAYER + 2]; + +extern char *yytext; /* defined by LEX */ +extern PCBTypePtr yyPCB; +extern DataTypePtr yyData; +extern ElementTypePtr yyElement; +extern FontTypePtr yyFont; +extern int yylineno; /* linenumber */ +extern char *yyfilename; /* in this file */ + +static char *layer_group_string; + +static AttributeListTypePtr attr_list; + +int yyerror(const char *s); +int yylex(); +static int check_file_version (int); + +static void do_measure (PLMeasure *m, Coord i, double d, int u); +#define M(r,f,d) do_measure (&(r), f, d, 1) + +/* Macros for interpreting what "measure" means - integer value only, + old units (mil), or new units (cmil). */ +#define IV(m) integer_value (m) +#define OU(m) old_units (m) +#define NU(m) new_units (m) + +static int integer_value (PLMeasure m); +static Coord old_units (PLMeasure m); +static Coord new_units (PLMeasure m); + +#define YYDEBUG 1 +#define YYERROR_VERBOSE 1 + +#include "parse_y.h" + + +#line 163 "parse_y.tab.c" /* yacc.c:339 */ + +# ifndef YY_NULLPTR +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* In a future release of Bison, this section will be replaced + by #include "parse_y.tab.h". */ +#ifndef YY_YY_PARSE_Y_TAB_H_INCLUDED +# define YY_YY_PARSE_Y_TAB_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + FLOATING = 258, + INTEGER = 259, + CHAR_CONST = 260, + STRING = 261, + T_FILEVERSION = 262, + T_PCB = 263, + T_LAYER = 264, + T_VIA = 265, + T_RAT = 266, + T_LINE = 267, + T_ARC = 268, + T_RECTANGLE = 269, + T_TEXT = 270, + T_ELEMENTLINE = 271, + T_ELEMENT = 272, + T_PIN = 273, + T_PAD = 274, + T_GRID = 275, + T_FLAGS = 276, + T_SYMBOL = 277, + T_SYMBOLLINE = 278, + T_CURSOR = 279, + T_ELEMENTARC = 280, + T_MARK = 281, + T_GROUPS = 282, + T_STYLES = 283, + T_POLYGON = 284, + T_POLYGON_HOLE = 285, + T_NETLIST = 286, + T_NET = 287, + T_CONN = 288, + T_NETLISTPATCH = 289, + T_ADD_CONN = 290, + T_DEL_CONN = 291, + T_CHANGE_ATTRIB = 292, + T_AREA = 293, + T_THERMAL = 294, + T_DRC = 295, + T_ATTRIBUTE = 296, + T_UMIL = 297, + T_CMIL = 298, + T_MIL = 299, + T_IN = 300, + T_NM = 301, + T_UM = 302, + T_MM = 303, + T_M = 304, + T_KM = 305 + }; +#endif + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE YYSTYPE; +union YYSTYPE +{ +#line 111 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:355 */ + + int integer; + double number; + char *string; + FlagType flagtype; + PLMeasure measure; + +#line 262 "parse_y.tab.c" /* yacc.c:355 */ +}; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + +int yyparse (void); + +#endif /* !YY_YY_PARSE_Y_TAB_H_INCLUDED */ + +/* Copy the second part of user declarations. */ + +#line 277 "parse_y.tab.c" /* yacc.c:358 */ + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#else +typedef signed char yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) +# endif +# endif +# ifndef YY_ +# define YY_(Msgid) Msgid +# endif +#endif + +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(E) ((void) (E)) +#else +# define YYUSE(E) /* empty */ +#endif + +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +# define YY_INITIAL_VALUE(Value) Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS +# include /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's 'empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined EXIT_SUCCESS +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined EXIT_SUCCESS +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +# define YYCOPY_NEEDED 1 + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from SRC to DST. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ + while (0) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 10 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 608 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 55 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 112 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 214 +/* YYNSTATES -- Number of states. */ +#define YYNSTATES 643 + +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 305 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, without out-of-bounds checking. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 53, 54, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 51, 2, 52, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50 +}; + +#if YYDEBUG + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 138, 138, 139, 140, 141, 165, 165, 223, 223, + 234, 234, 253, 254, 259, 259, 299, 301, 331, 337, + 343, 372, 373, 374, 377, 385, 398, 430, 436, 442, + 458, 460, 485, 487, 518, 520, 521, 522, 526, 536, + 547, 574, 578, 583, 611, 615, 659, 668, 677, 681, + 682, 686, 687, 691, 692, 692, 693, 694, 696, 696, + 703, 707, 708, 709, 710, 711, 747, 757, 768, 778, + 788, 824, 829, 861, 860, 888, 889, 893, 894, 898, + 899, 900, 901, 902, 903, 905, 910, 911, 912, 913, + 913, 914, 944, 953, 962, 1010, 1019, 1028, 1065, 1075, + 1093, 1143, 1142, 1181, 1183, 1188, 1187, 1194, 1196, 1201, + 1205, 1265, 1266, 1267, 1268, 1269, 1277, 1276, 1295, 1294, + 1313, 1312, 1333, 1331, 1355, 1353, 1434, 1435, 1439, 1440, + 1441, 1442, 1443, 1445, 1450, 1455, 1460, 1465, 1470, 1475, + 1475, 1479, 1480, 1484, 1485, 1486, 1487, 1489, 1495, 1502, + 1507, 1512, 1512, 1553, 1565, 1577, 1588, 1604, 1658, 1672, + 1685, 1696, 1707, 1708, 1712, 1713, 1735, 1737, 1753, 1772, + 1773, 1776, 1778, 1779, 1800, 1807, 1823, 1824, 1828, 1833, + 1834, 1838, 1839, 1863, 1862, 1872, 1873, 1877, 1878, 1897, + 1914, 1915, 1919, 1924, 1925, 1929, 1930, 1945, 1946, 1947, + 1974, 1982, 1983, 1987, 1988, 1993, 1994, 1995, 1996, 1997, + 1998, 1999, 2000, 2001, 2002 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || 0 +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "FLOATING", "INTEGER", "CHAR_CONST", + "STRING", "T_FILEVERSION", "T_PCB", "T_LAYER", "T_VIA", "T_RAT", + "T_LINE", "T_ARC", "T_RECTANGLE", "T_TEXT", "T_ELEMENTLINE", "T_ELEMENT", + "T_PIN", "T_PAD", "T_GRID", "T_FLAGS", "T_SYMBOL", "T_SYMBOLLINE", + "T_CURSOR", "T_ELEMENTARC", "T_MARK", "T_GROUPS", "T_STYLES", + "T_POLYGON", "T_POLYGON_HOLE", "T_NETLIST", "T_NET", "T_CONN", + "T_NETLISTPATCH", "T_ADD_CONN", "T_DEL_CONN", "T_CHANGE_ATTRIB", + "T_AREA", "T_THERMAL", "T_DRC", "T_ATTRIBUTE", "T_UMIL", "T_CMIL", + "T_MIL", "T_IN", "T_NM", "T_UM", "T_MM", "T_M", "T_KM", "'['", "']'", + "'('", "')'", "$accept", "parse", "parsepcb", "$@1", "$@2", "parsedata", + "$@3", "pcbfont", "parsefont", "$@4", "pcbfileversion", "pcbname", + "pcbgrid", "pcbgridold", "pcbgridnew", "pcbhigrid", "pcbcursor", + "polyarea", "pcbthermal", "pcbdrc", "pcbdrc1", "pcbdrc2", "pcbdrc3", + "pcbflags", "pcbgroups", "pcbstyles", "pcbdata", "pcbdefinitions", + "pcbdefinition", "$@5", "$@6", "via", "via_hi_format", "via_2.0_format", + "via_1.7_format", "via_newformat", "via_oldformat", "rats", "layer", + "$@7", "layerdata", "layerdefinitions", "layerdefinition", "$@8", + "line_hi_format", "line_1.7_format", "line_oldformat", "arc_hi_format", + "arc_1.7_format", "arc_oldformat", "text_oldformat", "text_newformat", + "text_hi_format", "polygon_format", "$@9", "polygonholes", "polygonhole", + "$@10", "polygonpoints", "polygonpoint", "element", "element_oldformat", + "$@11", "element_1.3.4_format", "$@12", "element_newformat", "$@13", + "element_1.7_format", "$@14", "element_hi_format", "$@15", + "elementdefinitions", "elementdefinition", "$@16", "relementdefs", + "relementdef", "$@17", "pin_hi_format", "pin_1.7_format", + "pin_1.6.3_format", "pin_newformat", "pin_oldformat", "pad_hi_format", + "pad_1.7_format", "pad_newformat", "pad", "flags", "symbols", "symbol", + "symbolhead", "symbolid", "symboldata", "symboldefinition", + "hiressymbol", "pcbnetlist", "pcbnetdef", "nets", "netdefs", "net", + "$@18", "connections", "conndefs", "conn", "pcbnetlistpatch", + "pcbnetpatchdef", "netpatches", "netpatchdefs", "netpatch", "attribute", + "opt_string", "number", "measure", YY_NULLPTR +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[NUM] -- (External) token number corresponding to the + (internal) symbol number NUM (which must be that of a token). */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 91, 93, 40, 41 +}; +# endif + +#define YYPACT_NINF -449 + +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-449))) + +#define YYTABLE_NINF -90 + +#define yytable_value_is_error(Yytable_value) \ + 0 + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +static const yytype_int16 yypact[] = +{ + 151, -449, 39, -449, 4, 30, -449, 23, -449, 56, + -449, 32, 97, -31, -449, -449, -449, -449, -449, -449, + -449, 73, -5, 26, -449, 169, -449, 88, 30, -449, + -449, -449, -449, -449, -449, -449, -449, 48, 56, -449, + -449, 129, 55, 116, 49, 113, 140, 63, 63, 63, + 63, -449, 95, -449, -449, 84, 84, -449, -16, 105, + 143, 157, 92, 147, -449, -449, -449, -449, -449, 158, + 161, 168, 176, -449, -449, 305, 63, 63, 63, 63, + 187, -449, -449, 63, 63, 134, -449, -449, -449, -449, + 63, 6, 63, 63, 160, 156, 191, 192, 63, 210, + -449, -449, -449, -449, -449, -449, -449, -449, -449, 63, + 63, 224, 229, 233, 196, 197, 63, 63, 63, -449, + 63, 63, 63, 63, 63, 218, 257, 272, 185, 63, + -449, 236, 63, 221, 63, 63, 245, 255, 270, 63, + 63, 274, 287, 63, 63, 63, 63, 63, 283, 302, + 63, 63, 63, 353, 312, 63, 362, 239, 63, 63, + -449, -449, -449, 63, 63, -449, -449, 378, 0, 63, + 63, 334, 63, 341, 372, -449, -449, -449, 63, 63, + 63, 342, -449, 63, 343, 394, 251, 397, 398, 63, + 63, 351, 350, -449, 354, 355, -449, 356, 63, 357, + 380, 63, 63, 63, 358, 260, 399, -449, 359, 408, + 409, 49, 410, 63, 63, -449, -449, -449, -449, -449, + 63, 228, 363, 389, 63, 63, 414, -449, 205, 226, + 366, 253, 367, 368, 260, -449, 88, -449, -449, -449, + -449, -449, -449, -449, -449, -449, -449, 49, -449, 369, + 417, 373, 370, 376, 375, 63, 379, 381, 424, 256, + 412, 63, 90, 384, 33, 63, 63, 63, 63, 63, + 63, 63, 49, -449, -449, -449, 385, -449, 386, -449, + -449, -449, -449, 11, -449, -449, 387, 433, 436, 195, + -449, 63, 390, 63, 393, 276, 403, 404, 279, 280, + 102, -449, 88, -449, -449, -449, -449, -449, 63, 63, + 63, 63, 63, 63, 63, 405, -449, -449, -449, 13, + -449, 391, 406, 416, 49, 411, 454, -449, 63, 63, + 63, 63, 63, 63, 63, 63, -449, -449, -449, 63, + 63, 63, 63, 63, 63, 63, 415, -449, 63, -449, + -449, 418, 427, -449, 413, -449, 419, 33, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 264, -449, 420, 421, 423, -449, -449, 425, + 33, 426, 121, 63, 63, 63, 63, 63, 63, 422, + 437, 63, 63, 63, 63, 458, 457, 465, 464, 320, + -449, 428, 438, -449, 183, -449, -449, 63, 63, 299, + 63, 63, 63, -449, -449, 63, 63, 63, 63, 439, + 49, 440, 473, 63, 63, -449, 320, 448, 442, 165, + -449, 165, 63, 63, 486, 490, 63, 63, 63, 49, + 2, 63, 63, -449, 445, -449, 444, 63, 63, -17, + -449, 446, 447, 448, -449, -10, 321, 326, 327, 330, + 222, -449, 88, -449, -449, -449, -449, 234, 450, 449, + 459, 352, 494, 63, 63, 460, 461, -449, 63, 110, + -449, -449, 462, 463, 466, -449, -449, 510, -449, -449, + 467, 468, 469, 478, -10, -449, 63, 63, 63, 63, + 63, 63, 63, 63, -449, -449, -449, -449, -449, -449, + -449, 479, 514, 383, 63, 63, -449, -449, 49, 480, + 519, -449, -449, -449, 529, 530, 531, 538, -449, -449, + 63, 63, 63, 63, 63, 63, 63, 63, -449, 493, + 495, 544, 502, 503, 506, -449, 505, 320, 507, 554, + 556, 557, 63, 63, 63, 63, 63, 63, 63, 63, + -449, -449, 515, -449, -449, -449, -449, 516, 518, 520, + 521, 562, 63, 63, 63, 63, 63, 63, 63, 63, + -449, -449, -449, -449, -449, 522, 63, 63, 63, 63, + 63, 63, 63, 63, 539, -449, 525, 524, 63, 63, + 63, 63, 63, 63, 526, 527, 539, -449, -449, -449, + 567, 574, 63, 63, 63, 63, 576, -449, -449, 577, + 578, 579, 580, 535, 534, 536, 49, 585, 586, 587, + -449, -449, -449, 542, 537, 49, 591, -449, -449, 545, + 546, -449, -449 +}; + + /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 5, 0, 2, 16, 0, 3, 0, 4, 0, + 1, 0, 0, 0, 9, 111, 112, 113, 114, 115, + 60, 0, 0, 0, 11, 0, 51, 0, 0, 53, + 61, 62, 63, 64, 65, 56, 57, 0, 15, 164, + 171, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 52, 0, 55, 59, 0, 0, 165, 0, 0, + 0, 0, 0, 29, 21, 22, 23, 162, 163, 0, + 0, 0, 0, 203, 204, 205, 0, 0, 0, 0, + 0, 169, 170, 0, 0, 0, 166, 172, 173, 17, + 0, 0, 0, 0, 0, 30, 0, 0, 0, 202, + 206, 207, 208, 209, 210, 211, 212, 213, 214, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, + 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, + 201, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 34, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 200, 167, 168, 0, 0, 20, 19, 0, 0, 0, + 0, 0, 0, 0, 43, 35, 36, 37, 0, 0, + 0, 0, 73, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 24, 0, 0, 31, 0, 0, 0, + 45, 0, 0, 0, 0, 76, 0, 70, 0, 0, + 0, 0, 0, 0, 0, 26, 25, 28, 27, 33, + 0, 0, 0, 48, 0, 0, 0, 116, 0, 0, + 0, 0, 0, 0, 75, 77, 0, 79, 80, 81, + 82, 83, 84, 88, 87, 86, 91, 0, 69, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 13, 0, 0, 0, 139, 0, 0, 0, 0, 0, + 0, 0, 0, 74, 78, 90, 0, 68, 0, 71, + 72, 175, 174, 0, 41, 42, 0, 0, 0, 0, + 12, 0, 204, 0, 0, 0, 0, 0, 0, 0, + 139, 126, 0, 128, 129, 130, 131, 132, 0, 0, + 0, 0, 0, 0, 0, 0, 66, 67, 38, 0, + 44, 0, 0, 177, 0, 0, 0, 118, 0, 0, + 0, 0, 0, 0, 0, 0, 117, 127, 140, 0, + 0, 0, 0, 0, 0, 0, 0, 39, 0, 47, + 46, 0, 191, 176, 0, 120, 0, 139, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 101, 0, 0, 0, 7, 190, 0, + 139, 0, 139, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 107, + 40, 0, 0, 124, 139, 122, 119, 0, 0, 0, + 0, 0, 0, 137, 138, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 103, 107, 180, 0, 151, + 121, 151, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 85, 0, 98, 0, 0, 0, 0, + 108, 0, 0, 179, 181, 194, 0, 0, 0, 0, + 151, 141, 0, 144, 143, 146, 145, 151, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 94, 0, 0, + 100, 99, 0, 0, 0, 102, 104, 0, 178, 182, + 0, 0, 0, 0, 193, 195, 0, 0, 0, 0, + 0, 0, 0, 0, 125, 142, 152, 123, 133, 134, + 157, 0, 0, 0, 0, 0, 92, 93, 0, 204, + 0, 110, 109, 105, 0, 0, 0, 0, 192, 196, + 0, 0, 0, 0, 0, 0, 0, 0, 156, 0, + 0, 0, 0, 0, 0, 97, 0, 107, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 155, 161, 0, 135, 136, 95, 96, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 160, 106, 183, 197, 198, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 186, 199, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 185, 187, 147, 148, + 0, 0, 0, 0, 0, 0, 0, 184, 188, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 149, 150, 189, 0, 0, 0, 0, 153, 154, 0, + 0, 158, 159 +}; + + /* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -449, -449, -449, -449, -449, -449, -449, -449, 336, -449, + -449, -449, -449, -449, -449, -449, -449, -449, -449, -449, + -449, -449, -449, -449, -449, -449, 309, -449, 581, -449, + -449, -449, -449, -449, -449, -449, -449, -449, -449, -449, + -449, -449, 365, -449, -449, -449, -449, -449, -449, -449, + -449, -449, -449, -449, -449, -449, -449, -449, -423, -449, + 573, -449, -449, -449, -449, -449, -449, -449, -449, -449, + -449, -339, -292, -449, 171, -448, -449, -449, -449, -449, + -449, -449, -449, -449, -449, -449, -190, -449, 565, -449, + 548, -449, -449, -449, -449, -449, -449, -449, 152, -449, + -449, -449, 1, -449, -449, -449, -449, 114, -231, -449, + -47, -48 +}; + + /* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 2, 3, 4, 5, 6, 7, 289, 8, 9, + 12, 43, 63, 64, 65, 66, 95, 126, 149, 174, + 175, 176, 177, 200, 223, 260, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 205, + 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, + 243, 244, 245, 246, 399, 449, 486, 547, 425, 426, + 14, 15, 264, 16, 357, 17, 380, 18, 431, 19, + 429, 300, 301, 302, 460, 461, 462, 463, 464, 303, + 304, 305, 465, 466, 306, 307, 69, 38, 39, 40, + 83, 58, 87, 88, 352, 353, 452, 453, 454, 594, + 605, 606, 607, 377, 378, 493, 494, 495, 53, 131, + 75, 76 +}; + + /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ +static const yytype_int16 yytable[] = +{ + 77, 78, 79, 450, 192, 275, 476, 85, 337, 73, + 74, 11, 505, 484, 73, 74, 73, 74, 382, 505, + 44, 251, 45, -50, 20, 490, 491, 492, 109, 110, + 111, 112, 21, 22, 23, 114, 115, 485, 86, 10, + -58, 404, 118, 120, 121, 122, 47, 13, 48, 295, + 129, 296, 297, 67, 193, 68, 477, 276, 298, 299, + 119, 132, 133, 318, -54, 347, 73, 74, 139, 140, + 141, 338, 142, 143, 144, 145, 146, 49, 37, 50, + 152, 153, 315, 41, 155, 157, 158, 159, 81, 82, + 337, 163, 164, 73, 292, 167, 168, 169, 170, 55, + 171, 56, 178, 179, 180, 42, 60, 183, 61, 186, + 187, 188, 337, 73, 519, 189, 190, 70, 295, 71, + 296, 297, 194, 195, 567, 197, 46, 298, 299, 52, + 201, 202, 203, 59, 354, 206, 62, 295, 210, 296, + 297, 213, 214, 92, 72, 93, 298, 299, 80, 90, + 220, -10, 1, 224, 225, 226, 336, 89, -6, -6, + -10, -10, -10, 91, 96, 253, 254, 97, -8, -49, + 20, 94, 255, -14, 98, 406, 261, 262, 21, 22, + 23, 456, 99, 457, 458, 116, -58, 117, 73, 74, + 459, 151, -10, 113, 125, -50, 20, 127, 128, 295, + -49, 296, 297, -49, 21, 22, 23, 283, 298, 299, + -54, 123, -58, 124, 291, 293, 130, 308, 309, 310, + 311, 312, 313, 314, 73, 74, -50, 156, 134, -50, + 444, 506, 256, 135, 257, 319, -54, 430, 456, 136, + 457, 458, 73, 74, 324, 185, 326, 459, 137, 475, + 456, 138, 457, 458, 73, 74, 265, 209, 266, 459, + 339, 340, 341, 342, 343, 344, 345, 73, 74, 147, + 397, 348, 228, 229, 230, 231, 504, 267, 150, 268, + 358, 359, 360, 361, 362, 363, 364, 365, 507, 232, + 154, 366, 367, 368, 369, 370, 148, 371, 372, 160, + 374, -89, 73, 74, 270, 434, 271, 287, 161, 288, + 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, + 393, 394, 395, 162, 396, 398, 165, 328, 544, 329, + 332, 334, 333, 335, 172, 407, 408, 409, 410, 411, + 412, 166, 173, 415, 416, 417, 418, 100, 101, 102, + 103, 104, 105, 106, 107, 108, 511, 181, 512, 432, + 433, 435, 436, 437, 438, 182, 184, 439, 440, 441, + 442, 423, 496, 424, 497, 447, 448, 498, 500, 499, + 501, 502, 191, 503, 468, 469, 196, 540, 472, 541, + 473, 474, 198, 199, 478, 479, 204, 207, 208, 482, + 483, 211, 212, 215, 216, 247, 217, 222, 219, 218, + 221, 227, 249, 248, 252, 250, 258, 259, 263, 269, + 272, 278, 273, 277, 280, 279, 514, 515, 281, 282, + 286, 518, 520, 284, -14, 285, 633, 316, 294, 321, + 317, 320, 322, 349, 325, 639, 327, 351, 530, 531, + 532, 533, 534, 535, 536, 537, 330, 331, 356, 346, + 350, 376, 419, 420, 355, 379, 542, 543, 373, 421, + 422, 375, 400, 381, 413, 401, 402, 446, 403, 405, + 451, 427, 552, 553, 554, 555, 556, 557, 558, 559, + 470, 414, 428, 443, 445, 455, 471, 480, 481, 487, + 513, 488, 508, 509, 572, 573, 574, 575, 576, 577, + 578, 579, 516, 510, 521, 517, 524, 522, 539, 523, + 525, 526, 527, 546, 586, 587, 588, 589, 590, 591, + 592, 593, 528, 538, 545, 548, 549, 550, 596, 597, + 598, 599, 600, 601, 551, 602, 603, 560, 562, 561, + 610, 611, 612, 613, 563, 614, 615, 564, 565, 566, + 569, 568, 570, 571, 621, 622, 623, 624, 585, 580, + 581, 582, 604, 619, 583, 584, 595, 608, 609, 616, + 620, 617, 625, 626, 627, 628, 629, 630, 631, 634, + 632, 638, 635, 636, 637, 640, 290, 641, 323, 274, + 642, 54, 467, 57, 84, 489, 51, 618, 529 +}; + +static const yytype_uint16 yycheck[] = +{ + 48, 49, 50, 426, 4, 236, 4, 23, 300, 3, + 4, 7, 460, 30, 3, 4, 3, 4, 357, 467, + 51, 211, 53, 0, 1, 35, 36, 37, 76, 77, + 78, 79, 9, 10, 11, 83, 84, 54, 54, 0, + 17, 380, 90, 91, 92, 93, 51, 17, 53, 16, + 98, 18, 19, 4, 54, 6, 54, 247, 25, 26, + 54, 109, 110, 52, 41, 52, 3, 4, 116, 117, + 118, 302, 120, 121, 122, 123, 124, 51, 22, 53, + 128, 129, 272, 51, 132, 133, 134, 135, 4, 5, + 382, 139, 140, 3, 4, 143, 144, 145, 146, 51, + 147, 53, 150, 151, 152, 8, 51, 155, 53, 157, + 158, 159, 404, 3, 4, 163, 164, 4, 16, 6, + 18, 19, 169, 170, 547, 172, 53, 25, 26, 41, + 178, 179, 180, 4, 324, 183, 20, 16, 186, 18, + 19, 189, 190, 51, 4, 53, 25, 26, 53, 6, + 198, 0, 1, 201, 202, 203, 54, 52, 7, 8, + 9, 10, 11, 6, 6, 213, 214, 6, 17, 0, + 1, 24, 220, 22, 6, 54, 224, 225, 9, 10, + 11, 16, 6, 18, 19, 51, 17, 53, 3, 4, + 25, 6, 41, 6, 38, 0, 1, 6, 6, 16, + 31, 18, 19, 34, 9, 10, 11, 255, 25, 26, + 41, 51, 17, 53, 261, 262, 6, 265, 266, 267, + 268, 269, 270, 271, 3, 4, 31, 6, 4, 34, + 420, 462, 4, 4, 6, 283, 41, 54, 16, 6, + 18, 19, 3, 4, 291, 6, 293, 25, 52, 439, + 16, 54, 18, 19, 3, 4, 51, 6, 53, 25, + 308, 309, 310, 311, 312, 313, 314, 3, 4, 51, + 6, 319, 12, 13, 14, 15, 54, 51, 6, 53, + 328, 329, 330, 331, 332, 333, 334, 335, 54, 29, + 54, 339, 340, 341, 342, 343, 39, 344, 345, 54, + 348, 41, 3, 4, 51, 6, 53, 51, 53, 53, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 53, 371, 372, 52, 51, 518, 53, + 51, 51, 53, 53, 51, 383, 384, 385, 386, 387, + 388, 54, 40, 391, 392, 393, 394, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 4, 4, 6, 407, + 408, 409, 410, 411, 412, 53, 4, 415, 416, 417, + 418, 51, 51, 53, 53, 423, 424, 51, 51, 53, + 53, 51, 4, 53, 432, 433, 52, 4, 436, 6, + 437, 438, 51, 21, 441, 442, 54, 54, 4, 447, + 448, 4, 4, 52, 54, 6, 52, 27, 52, 54, + 53, 53, 4, 54, 4, 6, 53, 28, 4, 53, + 53, 4, 54, 54, 54, 52, 473, 474, 52, 54, + 6, 478, 479, 54, 22, 54, 626, 52, 54, 6, + 54, 54, 6, 52, 54, 635, 53, 31, 496, 497, + 498, 499, 500, 501, 502, 503, 53, 53, 4, 54, + 54, 34, 4, 6, 53, 52, 514, 515, 53, 4, + 6, 53, 52, 54, 52, 54, 53, 4, 53, 53, + 32, 53, 530, 531, 532, 533, 534, 535, 536, 537, + 4, 54, 54, 54, 54, 53, 6, 52, 54, 53, + 6, 54, 52, 54, 552, 553, 554, 555, 556, 557, + 558, 559, 52, 54, 52, 54, 6, 54, 4, 53, + 53, 53, 53, 4, 572, 573, 574, 575, 576, 577, + 578, 579, 54, 54, 54, 6, 6, 6, 586, 587, + 588, 589, 590, 591, 6, 592, 593, 54, 4, 54, + 598, 599, 600, 601, 52, 602, 603, 54, 52, 54, + 6, 54, 6, 6, 612, 613, 614, 615, 6, 54, + 54, 53, 33, 6, 54, 54, 54, 52, 54, 53, + 6, 54, 6, 6, 6, 6, 6, 52, 54, 4, + 54, 54, 6, 6, 52, 4, 260, 52, 289, 234, + 54, 28, 431, 38, 56, 453, 25, 606, 494 +}; + + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 1, 56, 57, 58, 59, 60, 61, 63, 64, + 0, 7, 65, 17, 115, 116, 118, 120, 122, 124, + 1, 9, 10, 11, 81, 82, 83, 84, 85, 86, + 87, 88, 89, 90, 91, 92, 93, 22, 142, 143, + 144, 51, 8, 66, 51, 53, 53, 51, 53, 51, + 53, 83, 41, 163, 115, 51, 53, 143, 146, 4, + 51, 53, 20, 67, 68, 69, 70, 4, 6, 141, + 4, 6, 4, 3, 4, 165, 166, 166, 166, 166, + 53, 4, 5, 145, 145, 23, 54, 147, 148, 52, + 6, 6, 51, 53, 24, 71, 6, 6, 6, 6, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 166, + 166, 166, 166, 6, 166, 166, 51, 53, 166, 54, + 166, 166, 166, 51, 53, 38, 72, 6, 6, 166, + 6, 164, 166, 166, 4, 4, 6, 52, 54, 166, + 166, 166, 166, 166, 166, 166, 166, 51, 39, 73, + 6, 6, 166, 166, 54, 166, 6, 166, 166, 166, + 54, 53, 53, 166, 166, 52, 54, 166, 166, 166, + 166, 165, 51, 40, 74, 75, 76, 77, 166, 166, + 166, 4, 53, 166, 4, 6, 166, 166, 166, 166, + 166, 4, 4, 54, 165, 165, 52, 165, 51, 21, + 78, 166, 166, 166, 54, 94, 166, 54, 4, 6, + 166, 4, 4, 166, 166, 52, 54, 52, 54, 52, + 166, 53, 27, 79, 166, 166, 166, 53, 12, 13, + 14, 15, 29, 95, 96, 97, 98, 99, 100, 101, + 102, 103, 104, 105, 106, 107, 108, 6, 54, 4, + 6, 141, 4, 166, 166, 166, 4, 6, 53, 28, + 80, 166, 166, 4, 117, 51, 53, 51, 53, 53, + 51, 53, 53, 54, 97, 163, 141, 54, 4, 52, + 54, 52, 54, 166, 54, 54, 6, 51, 53, 62, + 63, 165, 4, 165, 54, 16, 18, 19, 25, 26, + 126, 127, 128, 134, 135, 136, 139, 140, 166, 166, + 166, 166, 166, 166, 166, 141, 52, 54, 52, 166, + 54, 6, 6, 81, 165, 54, 165, 53, 51, 53, + 53, 53, 51, 53, 51, 53, 54, 127, 163, 166, + 166, 166, 166, 166, 166, 166, 54, 52, 166, 52, + 54, 31, 149, 150, 141, 53, 4, 119, 166, 166, + 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, + 166, 165, 165, 53, 166, 53, 34, 158, 159, 52, + 121, 54, 126, 166, 166, 166, 166, 166, 166, 166, + 166, 166, 166, 166, 166, 166, 165, 6, 165, 109, + 52, 54, 53, 53, 126, 53, 54, 166, 166, 166, + 166, 166, 166, 52, 54, 166, 166, 166, 166, 4, + 6, 4, 6, 51, 53, 113, 114, 53, 54, 125, + 54, 123, 166, 166, 6, 166, 166, 166, 166, 166, + 166, 166, 166, 54, 141, 54, 4, 166, 166, 110, + 113, 32, 151, 152, 153, 53, 16, 18, 19, 25, + 129, 130, 131, 132, 133, 137, 138, 129, 166, 166, + 4, 6, 166, 165, 165, 141, 4, 54, 165, 165, + 52, 54, 166, 166, 30, 54, 111, 53, 54, 153, + 35, 36, 37, 160, 161, 162, 51, 53, 51, 53, + 51, 53, 51, 53, 54, 130, 163, 54, 52, 54, + 54, 4, 6, 6, 165, 165, 52, 54, 165, 4, + 165, 52, 54, 53, 6, 53, 53, 53, 54, 162, + 166, 166, 166, 166, 166, 166, 166, 166, 54, 4, + 4, 6, 166, 166, 141, 54, 4, 112, 6, 6, + 6, 6, 166, 166, 166, 166, 166, 166, 166, 166, + 54, 54, 4, 52, 54, 52, 54, 113, 54, 6, + 6, 6, 166, 166, 166, 166, 166, 166, 166, 166, + 54, 54, 53, 54, 54, 6, 166, 166, 166, 166, + 166, 166, 166, 166, 154, 54, 166, 166, 166, 166, + 166, 166, 165, 165, 33, 155, 156, 157, 52, 54, + 166, 166, 166, 166, 165, 165, 53, 54, 157, 6, + 6, 166, 166, 166, 166, 6, 6, 6, 6, 6, + 52, 54, 54, 141, 4, 6, 6, 52, 54, 141, + 4, 52, 54 +}; + + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 55, 56, 56, 56, 56, 58, 57, 59, 57, + 61, 60, 62, 62, 64, 63, 65, 65, 66, 66, + 66, 67, 67, 67, 68, 69, 70, 71, 71, 71, + 72, 72, 73, 73, 74, 74, 74, 74, 75, 76, + 77, 78, 78, 78, 79, 79, 80, 80, 80, 81, + 81, 82, 82, 83, 84, 83, 83, 83, 85, 83, + 83, 86, 86, 86, 86, 86, 87, 88, 89, 90, + 91, 92, 92, 94, 93, 95, 95, 96, 96, 97, + 97, 97, 97, 97, 97, 97, 97, 97, 97, 98, + 97, 97, 99, 100, 101, 102, 103, 104, 105, 106, + 107, 109, 108, 110, 110, 112, 111, 113, 113, 114, + 114, 115, 115, 115, 115, 115, 117, 116, 119, 118, + 121, 120, 123, 122, 125, 124, 126, 126, 127, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, + 127, 129, 129, 130, 130, 130, 130, 130, 130, 130, + 130, 131, 130, 132, 133, 134, 135, 136, 137, 138, + 139, 140, 141, 141, 142, 142, 143, 144, 144, 145, + 145, 146, 146, 146, 147, 148, 149, 149, 150, 151, + 151, 152, 152, 154, 153, 155, 155, 156, 156, 157, + 158, 158, 159, 160, 160, 161, 161, 162, 162, 162, + 163, 164, 164, 165, 165, 166, 166, 166, 166, 166, + 166, 166, 166, 166, 166 +}; + + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 1, 1, 1, 0, 15, 0, 2, + 0, 2, 1, 0, 0, 2, 0, 4, 4, 6, + 6, 1, 1, 1, 6, 7, 7, 6, 6, 0, + 0, 4, 0, 4, 0, 1, 1, 1, 6, 7, + 9, 4, 4, 0, 4, 0, 4, 4, 0, 1, + 0, 1, 2, 1, 0, 2, 1, 1, 0, 2, + 1, 1, 1, 1, 1, 1, 11, 11, 10, 9, + 8, 10, 10, 0, 10, 1, 0, 1, 2, 1, + 1, 1, 1, 1, 1, 8, 1, 1, 1, 0, + 2, 1, 10, 10, 9, 12, 12, 11, 8, 9, + 9, 0, 9, 0, 2, 0, 5, 0, 2, 4, + 4, 1, 1, 1, 1, 1, 0, 12, 0, 15, + 0, 16, 0, 18, 0, 18, 1, 2, 1, 1, + 1, 1, 1, 8, 8, 10, 10, 5, 5, 0, + 2, 1, 2, 1, 1, 1, 1, 8, 8, 10, + 10, 0, 2, 12, 12, 10, 9, 8, 13, 13, + 11, 10, 1, 1, 1, 2, 3, 6, 6, 1, + 1, 0, 2, 2, 8, 8, 1, 0, 6, 1, + 0, 1, 2, 0, 9, 1, 0, 1, 2, 4, + 1, 0, 6, 1, 0, 1, 2, 5, 5, 6, + 5, 1, 0, 1, 1, 1, 2, 2, 2, 2, + 2, 2, 2, 2, 2 +}; + + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (0) + +/* Error token number */ +#define YYTERROR 1 +#define YYERRCODE 256 + + + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif + + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + + +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ + +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + FILE *yyo = yyoutput; + YYUSE (yyo); + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + YYUSE (yytype); +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + YYFPRINTF (yyoutput, "%s %s (", + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +static void +yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +{ + unsigned long int yylno = yyrline[yyrule]; + int yynrhs = yyr2[yyrule]; + int yyi; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, + yystos[yyssp[yyi + 1 - yynrhs]], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyssp, yyvsp, Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +yystrlen (const char *yystr) +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +yystpcpy (char *yydest, const char *yysrc) +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. + + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) +{ + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = YY_NULLPTR; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; + + /* There are many possibilities here to consider: + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) + { + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } + } + } + + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ + } + + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; + } + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; +} +#endif /* YYERROR_VERBOSE */ + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +{ + YYUSE (yyvaluep); + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_END +} + + + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; +/* Number of syntax errors so far. */ +int yynerrs; + + +/*----------. +| yyparse. | +`----------*/ + +int +yyparse (void) +{ + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + 'yyss': related to states. + 'yyvs': related to semantic values. + + Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yypact_value_is_default (yyn)) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = yylex (); + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yytable_value_is_error (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + '$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 5: +#line 141 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { YYABORT; } +#line 1779 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 6: +#line 165 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + /* reset flags for 'used layers'; + * init font and data pointers + */ + int i; + + if (!yyPCB) + { + Message("illegal fileformat\n"); + YYABORT; + } + for (i = 0; i < MAX_LAYER + 2; i++) + LayerFlag[i] = false; + yyFont = &yyPCB->Font; + yyData = yyPCB->Data; + yyData->pcb = yyPCB; + yyData->LayerN = 0; + yyPCB->NetlistPatches = yyPCB->NetlistPatchLast = NULL; + layer_group_string = NULL; + } +#line 1804 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 7: +#line 199 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + PCBTypePtr pcb_save = PCB; + + if (layer_group_string == NULL) + layer_group_string = strdup(conf_core.design.groups); + CreateNewPCBPost (yyPCB, 0); + if (ParseGroupString(layer_group_string, &yyPCB->LayerGroups, yyData->LayerN)) + { + Message("illegal layer-group string\n"); + YYABORT; + } + /* initialize the polygon clipping now since + * we didn't know the layer grouping before. + */ + free(layer_group_string); + PCB = yyPCB; + ALLPOLYGON_LOOP (yyData); + { + InitClip (yyData, layer, polygon); + } + ENDALL_LOOP; + PCB = pcb_save; + } +#line 1832 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 8: +#line 223 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { PreLoadElementPCB (); + layer_group_string = NULL; } +#line 1839 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 9: +#line 226 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { LayerFlag[0] = true; + LayerFlag[1] = true; + yyData->LayerN = 2; + PostLoadElementPCB (); + } +#line 1849 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 10: +#line 234 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + /* reset flags for 'used layers'; + * init font and data pointers + */ + int i; + + if (!yyData || !yyFont) + { + Message("illegal fileformat\n"); + YYABORT; + } + for (i = 0; i < MAX_LAYER + 2; i++) + LayerFlag[i] = false; + yyData->LayerN = 0; + } +#line 1869 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 14: +#line 259 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + /* mark all symbols invalid */ + int i; + + if (!yyFont) + { + Message("illegal fileformat\n"); + YYABORT; + } + yyFont->Valid = false; + for (i = 0; i <= MAX_FONTPOSITION; i++) + free (yyFont->Symbol[i].Line); + bzero(yyFont->Symbol, sizeof(yyFont->Symbol)); + } +#line 1888 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 15: +#line 274 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyFont->Valid = true; + SetFontInfo(yyFont); + } +#line 1897 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 17: +#line 302 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + if (check_file_version ((yyvsp[-1].integer)) != 0) + { + YYABORT; + } +} +#line 1908 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 18: +#line 332 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyPCB->Name = (yyvsp[-1].string); + yyPCB->MaxWidth = MAX_COORD; + yyPCB->MaxHeight = MAX_COORD; + } +#line 1918 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 19: +#line 338 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyPCB->Name = (yyvsp[-3].string); + yyPCB->MaxWidth = OU ((yyvsp[-2].measure)); + yyPCB->MaxHeight = OU ((yyvsp[-1].measure)); + } +#line 1928 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 20: +#line 344 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyPCB->Name = (yyvsp[-3].string); + yyPCB->MaxWidth = NU ((yyvsp[-2].measure)); + yyPCB->MaxHeight = NU ((yyvsp[-1].measure)); + } +#line 1938 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 24: +#line 378 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyPCB->Grid = OU ((yyvsp[-3].measure)); + yyPCB->GridOffsetX = OU ((yyvsp[-2].measure)); + yyPCB->GridOffsetY = OU ((yyvsp[-1].measure)); + } +#line 1948 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 25: +#line 386 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyPCB->Grid = OU ((yyvsp[-4].measure)); + yyPCB->GridOffsetX = OU ((yyvsp[-3].measure)); + yyPCB->GridOffsetY = OU ((yyvsp[-2].measure)); + if ((yyvsp[-1].integer)) + conf_core.editor.draw_grid = true; + else + conf_core.editor.draw_grid = false; + } +#line 1962 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 26: +#line 399 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyPCB->Grid = NU ((yyvsp[-4].measure)); + yyPCB->GridOffsetX = NU ((yyvsp[-3].measure)); + yyPCB->GridOffsetY = NU ((yyvsp[-2].measure)); + if ((yyvsp[-1].integer)) + conf_core.editor.draw_grid = true; + else + conf_core.editor.draw_grid = false; + } +#line 1976 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 27: +#line 431 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyPCB->CursorX = OU ((yyvsp[-3].measure)); + yyPCB->CursorY = OU ((yyvsp[-2].measure)); + yyPCB->Zoom = (yyvsp[-1].number)*2; + } +#line 1986 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 28: +#line 437 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyPCB->CursorX = NU ((yyvsp[-3].measure)); + yyPCB->CursorY = NU ((yyvsp[-2].measure)); + yyPCB->Zoom = (yyvsp[-1].number); + } +#line 1996 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 31: +#line 461 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + /* Read in cmil^2 for now; in future this should be a noop. */ + yyPCB->IsleArea = MIL_TO_COORD (MIL_TO_COORD ((yyvsp[-1].number)) / 100.0) / 100.0; + } +#line 2005 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 33: +#line 488 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyPCB->ThermScale = (yyvsp[-1].number); + } +#line 2013 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 38: +#line 527 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyPCB->Bloat = NU ((yyvsp[-3].measure)); + yyPCB->Shrink = NU ((yyvsp[-2].measure)); + yyPCB->minWid = NU ((yyvsp[-1].measure)); + yyPCB->minRing = NU ((yyvsp[-1].measure)); + } +#line 2024 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 39: +#line 537 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyPCB->Bloat = NU ((yyvsp[-4].measure)); + yyPCB->Shrink = NU ((yyvsp[-3].measure)); + yyPCB->minWid = NU ((yyvsp[-2].measure)); + yyPCB->minSlk = NU ((yyvsp[-1].measure)); + yyPCB->minRing = NU ((yyvsp[-2].measure)); + } +#line 2036 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 40: +#line 548 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyPCB->Bloat = NU ((yyvsp[-6].measure)); + yyPCB->Shrink = NU ((yyvsp[-5].measure)); + yyPCB->minWid = NU ((yyvsp[-4].measure)); + yyPCB->minSlk = NU ((yyvsp[-3].measure)); + yyPCB->minDrill = NU ((yyvsp[-2].measure)); + yyPCB->minRing = NU ((yyvsp[-1].measure)); + } +#line 2049 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 41: +#line 575 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyPCB->Flags = MakeFlags ((yyvsp[-1].integer) & PCB_FLAGS); + } +#line 2057 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 42: +#line 579 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyPCB->Flags = string_to_pcbflags ((yyvsp[-1].string), yyerror); + free((yyvsp[-1].string)); + } +#line 2066 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 44: +#line 612 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + layer_group_string = (yyvsp[-1].string); + } +#line 2074 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 46: +#line 660 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + if (ParseRouteString((yyvsp[-1].string), &yyPCB->RouteStyle[0], "mil")) + { + Message("illegal route-style string\n"); + YYABORT; + } + free((yyvsp[-1].string)); + } +#line 2087 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 47: +#line 669 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + if (ParseRouteString((yyvsp[-1].string), &yyPCB->RouteStyle[0], "cmil")) + { + Message("illegal route-style string\n"); + YYABORT; + } + free((yyvsp[-1].string)); + } +#line 2100 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 54: +#line 692 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { attr_list = & yyPCB->Attributes; } +#line 2106 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 58: +#line 696 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + /* clear pointer to force memory allocation by + * the appropriate subroutine + */ + yyElement = NULL; + } +#line 2117 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 60: +#line 703 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { YYABORT; } +#line 2123 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 66: +#line 748 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewVia(yyData, NU ((yyvsp[-8].measure)), NU ((yyvsp[-7].measure)), NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), + NU ((yyvsp[-3].measure)), (yyvsp[-2].string), (yyvsp[-1].flagtype)); + free ((yyvsp[-2].string)); + } +#line 2133 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 67: +#line 758 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewVia(yyData, OU ((yyvsp[-8].measure)), OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), (yyvsp[-2].string), + OldFlags((yyvsp[-1].integer))); + free ((yyvsp[-2].string)); + } +#line 2143 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 68: +#line 769 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewVia(yyData, OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), + OU ((yyvsp[-5].measure)) + OU((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), (yyvsp[-2].string), OldFlags((yyvsp[-1].integer))); + free ((yyvsp[-2].string)); + } +#line 2153 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 69: +#line 779 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewVia(yyData, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), 2*GROUNDPLANEFRAME, + OU((yyvsp[-4].measure)) + 2*MASKFRAME, OU ((yyvsp[-3].measure)), (yyvsp[-2].string), OldFlags((yyvsp[-1].integer))); + free ((yyvsp[-2].string)); + } +#line 2163 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 70: +#line 789 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + Coord hole = (OU((yyvsp[-3].measure)) * DEFAULT_DRILLINGHOLE); + + /* make sure that there's enough copper left */ + if (OU((yyvsp[-3].measure)) - hole < MIN_PINORVIACOPPER && + OU((yyvsp[-3].measure)) > MIN_PINORVIACOPPER) + hole = OU((yyvsp[-3].measure)) - MIN_PINORVIACOPPER; + + CreateNewVia(yyData, OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), 2*GROUNDPLANEFRAME, + OU((yyvsp[-3].measure)) + 2*MASKFRAME, hole, (yyvsp[-2].string), OldFlags((yyvsp[-1].integer))); + free ((yyvsp[-2].string)); + } +#line 2180 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 71: +#line 825 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewRat(yyData, NU ((yyvsp[-7].measure)), NU ((yyvsp[-6].measure)), NU ((yyvsp[-4].measure)), NU ((yyvsp[-3].measure)), (yyvsp[-5].integer), (yyvsp[-2].integer), + conf_core.appearance.rat_thickness, (yyvsp[-1].flagtype)); + } +#line 2189 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 72: +#line 830 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewRat(yyData, OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), (yyvsp[-5].integer), (yyvsp[-2].integer), + conf_core.appearance.rat_thickness, OldFlags((yyvsp[-1].integer))); + } +#line 2198 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 73: +#line 861 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + if ((yyvsp[-4].integer) <= 0 || (yyvsp[-4].integer) > MAX_LAYER + 2) + { + yyerror("Layernumber out of range"); + YYABORT; + } + if (LayerFlag[(yyvsp[-4].integer)-1]) + { + yyerror("Layernumber used twice"); + YYABORT; + } + Layer = &yyData->Layer[(yyvsp[-4].integer)-1]; + + /* memory for name is already allocated */ + if (Layer->Name != NULL) + free(Layer->Name); + Layer->Name = (yyvsp[-3].string); + LayerFlag[(yyvsp[-4].integer)-1] = true; + if (yyData->LayerN + 2 < (yyvsp[-4].integer)) + yyData->LayerN = (yyvsp[-4].integer) - 2; + if ((yyvsp[-2].string) != NULL) + free((yyvsp[-2].string)); + } +#line 2226 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 85: +#line 906 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewPolygonFromRectangle(Layer, + OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-5].measure)) + OU ((yyvsp[-3].measure)), OU ((yyvsp[-4].measure)) + OU ((yyvsp[-2].measure)), OldFlags((yyvsp[-1].integer))); + } +#line 2235 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 89: +#line 913 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { attr_list = & Layer->Attributes; } +#line 2241 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 92: +#line 945 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewLineOnLayer(Layer, NU ((yyvsp[-7].measure)), NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), + NU ((yyvsp[-3].measure)), NU ((yyvsp[-2].measure)), (yyvsp[-1].flagtype)); + } +#line 2250 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 93: +#line 954 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewLineOnLayer(Layer, OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), + OU ((yyvsp[-3].measure)), OU ((yyvsp[-2].measure)), OldFlags((yyvsp[-1].integer))); + } +#line 2259 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 94: +#line 963 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + /* eliminate old-style rat-lines */ + if ((IV ((yyvsp[-1].measure)) & RATFLAG) == 0) + CreateNewLineOnLayer(Layer, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), OU ((yyvsp[-2].measure)), + 200*GROUNDPLANEFRAME, OldFlags(IV ((yyvsp[-1].measure)))); + } +#line 2270 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 95: +#line 1011 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewArcOnLayer(Layer, NU ((yyvsp[-9].measure)), NU ((yyvsp[-8].measure)), NU ((yyvsp[-7].measure)), NU ((yyvsp[-6].measure)), (yyvsp[-3].number), (yyvsp[-2].number), + NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), (yyvsp[-1].flagtype)); + } +#line 2279 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 96: +#line 1020 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewArcOnLayer(Layer, OU ((yyvsp[-9].measure)), OU ((yyvsp[-8].measure)), OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), (yyvsp[-3].number), (yyvsp[-2].number), + OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OldFlags((yyvsp[-1].integer))); + } +#line 2288 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 97: +#line 1029 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewArcOnLayer(Layer, OU ((yyvsp[-8].measure)), OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-6].measure)), IV ((yyvsp[-3].measure)), (yyvsp[-2].number), + OU ((yyvsp[-4].measure)), 200*GROUNDPLANEFRAME, OldFlags((yyvsp[-1].integer))); + } +#line 2297 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 98: +#line 1066 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + /* use a default scale of 100% */ + CreateNewText(Layer,yyFont,OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), (yyvsp[-3].number), 100, (yyvsp[-2].string), OldFlags((yyvsp[-1].integer))); + free ((yyvsp[-2].string)); + } +#line 2307 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 99: +#line 1076 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + if ((yyvsp[-1].integer) & ONSILKFLAG) + { + LayerTypePtr lay = &yyData->Layer[yyData->LayerN + + (((yyvsp[-1].integer) & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)]; + + CreateNewText(lay ,yyFont, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), (yyvsp[-4].number), (yyvsp[-3].number), (yyvsp[-2].string), + OldFlags((yyvsp[-1].integer))); + } + else + CreateNewText(Layer, yyFont, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), (yyvsp[-4].number), (yyvsp[-3].number), (yyvsp[-2].string), + OldFlags((yyvsp[-1].integer))); + free ((yyvsp[-2].string)); + } +#line 2326 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 100: +#line 1094 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + /* FIXME: shouldn't know about .f */ + /* I don't think this matters because anything with hi_format + * will have the silk on its own layer in the file rather + * than using the ONSILKFLAG and having it in a copper layer. + * Thus there is no need for anything besides the 'else' + * part of this code. + */ + if ((yyvsp[-1].flagtype).f & ONSILKFLAG) + { + LayerTypePtr lay = &yyData->Layer[yyData->LayerN + + (((yyvsp[-1].flagtype).f & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)]; + + CreateNewText(lay, yyFont, NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), (yyvsp[-4].number), (yyvsp[-3].number), (yyvsp[-2].string), (yyvsp[-1].flagtype)); + } + else + CreateNewText(Layer, yyFont, NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), (yyvsp[-4].number), (yyvsp[-3].number), (yyvsp[-2].string), (yyvsp[-1].flagtype)); + free ((yyvsp[-2].string)); + } +#line 2350 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 101: +#line 1143 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + Polygon = CreateNewPolygon(Layer, (yyvsp[-2].flagtype)); + } +#line 2358 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 102: +#line 1148 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + Cardinal contour, contour_start, contour_end; + bool bad_contour_found = false; + /* ignore junk */ + for (contour = 0; contour <= Polygon->HoleIndexN; contour++) + { + contour_start = (contour == 0) ? + 0 : Polygon->HoleIndex[contour - 1]; + contour_end = (contour == Polygon->HoleIndexN) ? + Polygon->PointN : + Polygon->HoleIndex[contour]; + if (contour_end - contour_start < 3) + bad_contour_found = true; + } + + if (bad_contour_found) + { + Message("WARNING parsing file '%s'\n" + " line: %i\n" + " description: 'ignored polygon (< 3 points in a contour)'\n", + yyfilename, yylineno); + DestroyObject(yyData, POLYGON_TYPE, Layer, Polygon, Polygon); + } + else + { + SetPolygonBoundingBox (Polygon); + if (!Layer->polygon_tree) + Layer->polygon_tree = r_create_tree (NULL, 0, 0); + r_insert_entry (Layer->polygon_tree, (BoxType *) Polygon, 0); + } + } +#line 2394 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 105: +#line 1188 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewHoleInPolygon (Polygon); + } +#line 2402 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 109: +#line 1202 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewPointInPolygon(Polygon, OU ((yyvsp[-2].measure)), OU ((yyvsp[-1].measure))); + } +#line 2410 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 110: +#line 1206 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewPointInPolygon(Polygon, NU ((yyvsp[-2].measure)), NU ((yyvsp[-1].measure))); + } +#line 2418 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 116: +#line 1277 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyElement = CreateNewElement(yyData, yyElement, yyFont, NoFlags(), + (yyvsp[-6].string), (yyvsp[-5].string), NULL, OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), (yyvsp[-2].integer), 100, NoFlags(), false); + free ((yyvsp[-6].string)); + free ((yyvsp[-5].string)); + pin_num = 1; + } +#line 2430 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 117: +#line 1285 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + SetElementBoundingBox(yyData, yyElement, yyFont); + } +#line 2438 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 118: +#line 1295 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags((yyvsp[-9].integer)), + (yyvsp[-8].string), (yyvsp[-7].string), NULL, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), IV ((yyvsp[-4].measure)), IV ((yyvsp[-3].measure)), OldFlags((yyvsp[-2].integer)), false); + free ((yyvsp[-8].string)); + free ((yyvsp[-7].string)); + pin_num = 1; + } +#line 2450 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 119: +#line 1303 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + SetElementBoundingBox(yyData, yyElement, yyFont); + } +#line 2458 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 120: +#line 1313 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags((yyvsp[-10].integer)), + (yyvsp[-9].string), (yyvsp[-8].string), (yyvsp[-7].string), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), IV ((yyvsp[-4].measure)), IV ((yyvsp[-3].measure)), OldFlags((yyvsp[-2].integer)), false); + free ((yyvsp[-9].string)); + free ((yyvsp[-8].string)); + free ((yyvsp[-7].string)); + pin_num = 1; + } +#line 2471 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 121: +#line 1322 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + SetElementBoundingBox(yyData, yyElement, yyFont); + } +#line 2479 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 122: +#line 1333 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags((yyvsp[-12].integer)), + (yyvsp[-11].string), (yyvsp[-10].string), (yyvsp[-9].string), OU ((yyvsp[-8].measure)) + OU ((yyvsp[-6].measure)), OU ((yyvsp[-7].measure)) + OU ((yyvsp[-5].measure)), + (yyvsp[-4].number), (yyvsp[-3].number), OldFlags((yyvsp[-2].integer)), false); + yyElement->MarkX = OU ((yyvsp[-8].measure)); + yyElement->MarkY = OU ((yyvsp[-7].measure)); + free ((yyvsp[-11].string)); + free ((yyvsp[-10].string)); + free ((yyvsp[-9].string)); + } +#line 2494 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 123: +#line 1344 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + SetElementBoundingBox(yyData, yyElement, yyFont); + } +#line 2502 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 124: +#line 1355 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyElement = CreateNewElement(yyData, yyElement, yyFont, (yyvsp[-12].flagtype), + (yyvsp[-11].string), (yyvsp[-10].string), (yyvsp[-9].string), NU ((yyvsp[-8].measure)) + NU ((yyvsp[-6].measure)), NU ((yyvsp[-7].measure)) + NU ((yyvsp[-5].measure)), + (yyvsp[-4].number), (yyvsp[-3].number), (yyvsp[-2].flagtype), false); + yyElement->MarkX = NU ((yyvsp[-8].measure)); + yyElement->MarkY = NU ((yyvsp[-7].measure)); + free ((yyvsp[-11].string)); + free ((yyvsp[-10].string)); + free ((yyvsp[-9].string)); + } +#line 2517 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 125: +#line 1366 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + SetElementBoundingBox(yyData, yyElement, yyFont); + } +#line 2525 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 133: +#line 1446 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewLineInElement(yyElement, NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), NU ((yyvsp[-3].measure)), NU ((yyvsp[-2].measure)), NU ((yyvsp[-1].measure))); + } +#line 2533 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 134: +#line 1451 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewLineInElement(yyElement, OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), OU ((yyvsp[-2].measure)), OU ((yyvsp[-1].measure))); + } +#line 2541 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 135: +#line 1456 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewArcInElement(yyElement, NU ((yyvsp[-7].measure)), NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), (yyvsp[-3].number), (yyvsp[-2].number), NU ((yyvsp[-1].measure))); + } +#line 2549 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 136: +#line 1461 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewArcInElement(yyElement, OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), (yyvsp[-3].number), (yyvsp[-2].number), OU ((yyvsp[-1].measure))); + } +#line 2557 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 137: +#line 1466 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyElement->MarkX = NU ((yyvsp[-2].measure)); + yyElement->MarkY = NU ((yyvsp[-1].measure)); + } +#line 2566 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 138: +#line 1471 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + yyElement->MarkX = OU ((yyvsp[-2].measure)); + yyElement->MarkY = OU ((yyvsp[-1].measure)); + } +#line 2575 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 139: +#line 1475 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { attr_list = & yyElement->Attributes; } +#line 2581 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 147: +#line 1490 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewLineInElement(yyElement, NU ((yyvsp[-5].measure)) + yyElement->MarkX, + NU ((yyvsp[-4].measure)) + yyElement->MarkY, NU ((yyvsp[-3].measure)) + yyElement->MarkX, + NU ((yyvsp[-2].measure)) + yyElement->MarkY, NU ((yyvsp[-1].measure))); + } +#line 2591 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 148: +#line 1496 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewLineInElement(yyElement, OU ((yyvsp[-5].measure)) + yyElement->MarkX, + OU ((yyvsp[-4].measure)) + yyElement->MarkY, OU ((yyvsp[-3].measure)) + yyElement->MarkX, + OU ((yyvsp[-2].measure)) + yyElement->MarkY, OU ((yyvsp[-1].measure))); + } +#line 2601 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 149: +#line 1503 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewArcInElement(yyElement, NU ((yyvsp[-7].measure)) + yyElement->MarkX, + NU ((yyvsp[-6].measure)) + yyElement->MarkY, NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), (yyvsp[-3].number), (yyvsp[-2].number), NU ((yyvsp[-1].measure))); + } +#line 2610 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 150: +#line 1508 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewArcInElement(yyElement, OU ((yyvsp[-7].measure)) + yyElement->MarkX, + OU ((yyvsp[-6].measure)) + yyElement->MarkY, OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), (yyvsp[-3].number), (yyvsp[-2].number), OU ((yyvsp[-1].measure))); + } +#line 2619 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 151: +#line 1512 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { attr_list = & yyElement->Attributes; } +#line 2625 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 153: +#line 1554 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewPin(yyElement, NU ((yyvsp[-9].measure)) + yyElement->MarkX, + NU ((yyvsp[-8].measure)) + yyElement->MarkY, NU ((yyvsp[-7].measure)), NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), (yyvsp[-3].string), + (yyvsp[-2].string), (yyvsp[-1].flagtype)); + free ((yyvsp[-3].string)); + free ((yyvsp[-2].string)); + } +#line 2637 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 154: +#line 1566 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewPin(yyElement, OU ((yyvsp[-9].measure)) + yyElement->MarkX, + OU ((yyvsp[-8].measure)) + yyElement->MarkY, OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), (yyvsp[-3].string), + (yyvsp[-2].string), OldFlags((yyvsp[-1].integer))); + free ((yyvsp[-3].string)); + free ((yyvsp[-2].string)); + } +#line 2649 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 155: +#line 1578 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewPin(yyElement, OU ((yyvsp[-7].measure)), OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), 2*GROUNDPLANEFRAME, + OU ((yyvsp[-5].measure)) + 2*MASKFRAME, OU ((yyvsp[-4].measure)), (yyvsp[-3].string), (yyvsp[-2].string), OldFlags((yyvsp[-1].integer))); + free ((yyvsp[-3].string)); + free ((yyvsp[-2].string)); + } +#line 2660 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 156: +#line 1589 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + char p_number[8]; + + sprintf(p_number, "%d", pin_num++); + CreateNewPin(yyElement, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), 2*GROUNDPLANEFRAME, + OU ((yyvsp[-4].measure)) + 2*MASKFRAME, OU ((yyvsp[-3].measure)), (yyvsp[-2].string), p_number, OldFlags((yyvsp[-1].integer))); + + free ((yyvsp[-2].string)); + } +#line 2674 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 157: +#line 1605 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + Coord hole = OU ((yyvsp[-3].measure)) * DEFAULT_DRILLINGHOLE; + char p_number[8]; + + /* make sure that there's enough copper left */ + if (OU ((yyvsp[-3].measure)) - hole < MIN_PINORVIACOPPER && + OU ((yyvsp[-3].measure)) > MIN_PINORVIACOPPER) + hole = OU ((yyvsp[-3].measure)) - MIN_PINORVIACOPPER; + + sprintf(p_number, "%d", pin_num++); + CreateNewPin(yyElement, OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), 2*GROUNDPLANEFRAME, + OU ((yyvsp[-3].measure)) + 2*MASKFRAME, hole, (yyvsp[-2].string), p_number, OldFlags((yyvsp[-1].integer))); + free ((yyvsp[-2].string)); + } +#line 2693 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 158: +#line 1659 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewPad(yyElement, NU ((yyvsp[-10].measure)) + yyElement->MarkX, + NU ((yyvsp[-9].measure)) + yyElement->MarkY, + NU ((yyvsp[-8].measure)) + yyElement->MarkX, + NU ((yyvsp[-7].measure)) + yyElement->MarkY, NU ((yyvsp[-6].measure)), NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), + (yyvsp[-3].string), (yyvsp[-2].string), (yyvsp[-1].flagtype)); + free ((yyvsp[-3].string)); + free ((yyvsp[-2].string)); + } +#line 2707 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 159: +#line 1673 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewPad(yyElement,OU ((yyvsp[-10].measure)) + yyElement->MarkX, + OU ((yyvsp[-9].measure)) + yyElement->MarkY, OU ((yyvsp[-8].measure)) + yyElement->MarkX, + OU ((yyvsp[-7].measure)) + yyElement->MarkY, OU ((yyvsp[-6].measure)), OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), + (yyvsp[-3].string), (yyvsp[-2].string), OldFlags((yyvsp[-1].integer))); + free ((yyvsp[-3].string)); + free ((yyvsp[-2].string)); + } +#line 2720 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 160: +#line 1686 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewPad(yyElement,OU ((yyvsp[-8].measure)),OU ((yyvsp[-7].measure)),OU ((yyvsp[-6].measure)),OU ((yyvsp[-5].measure)),OU ((yyvsp[-4].measure)), 2*GROUNDPLANEFRAME, + OU ((yyvsp[-4].measure)) + 2*MASKFRAME, (yyvsp[-3].string), (yyvsp[-2].string), OldFlags((yyvsp[-1].integer))); + free ((yyvsp[-3].string)); + free ((yyvsp[-2].string)); + } +#line 2731 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 161: +#line 1697 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + char p_number[8]; + + sprintf(p_number, "%d", pin_num++); + CreateNewPad(yyElement,OU ((yyvsp[-7].measure)),OU ((yyvsp[-6].measure)),OU ((yyvsp[-5].measure)),OU ((yyvsp[-4].measure)),OU ((yyvsp[-3].measure)), 2*GROUNDPLANEFRAME, + OU ((yyvsp[-3].measure)) + 2*MASKFRAME, (yyvsp[-2].string),p_number, OldFlags((yyvsp[-1].integer))); + free ((yyvsp[-2].string)); + } +#line 2744 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 162: +#line 1707 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { (yyval.flagtype) = OldFlags((yyvsp[0].integer)); } +#line 2750 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 163: +#line 1708 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { (yyval.flagtype) = string_to_flags ((yyvsp[0].string), yyerror); free((yyvsp[0].string)); } +#line 2756 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 167: +#line 1738 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + if ((yyvsp[-3].integer) <= 0 || (yyvsp[-3].integer) > MAX_FONTPOSITION) + { + yyerror("fontposition out of range"); + YYABORT; + } + Symbol = &yyFont->Symbol[(yyvsp[-3].integer)]; + if (Symbol->Valid) + { + yyerror("symbol ID used twice"); + YYABORT; + } + Symbol->Valid = true; + Symbol->Delta = NU ((yyvsp[-2].measure)); + } +#line 2776 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 168: +#line 1754 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + if ((yyvsp[-3].integer) <= 0 || (yyvsp[-3].integer) > MAX_FONTPOSITION) + { + yyerror("fontposition out of range"); + YYABORT; + } + Symbol = &yyFont->Symbol[(yyvsp[-3].integer)]; + if (Symbol->Valid) + { + yyerror("symbol ID used twice"); + YYABORT; + } + Symbol->Valid = true; + Symbol->Delta = OU ((yyvsp[-2].measure)); + } +#line 2796 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 174: +#line 1801 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewLineInSymbol(Symbol, OU ((yyvsp[-5].measure)), OU ((yyvsp[-4].measure)), OU ((yyvsp[-3].measure)), OU ((yyvsp[-2].measure)), OU ((yyvsp[-1].measure))); + } +#line 2804 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 175: +#line 1808 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewLineInSymbol(Symbol, NU ((yyvsp[-5].measure)), NU ((yyvsp[-4].measure)), NU ((yyvsp[-3].measure)), NU ((yyvsp[-2].measure)), NU ((yyvsp[-1].measure))); + } +#line 2812 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 183: +#line 1863 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + Menu = CreateNewNet((LibraryTypePtr)&yyPCB->NetlistLib, (yyvsp[-3].string), (yyvsp[-2].string)); + free ((yyvsp[-3].string)); + free ((yyvsp[-2].string)); + } +#line 2822 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 189: +#line 1898 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewConnection(Menu, (yyvsp[-1].string)); + free ((yyvsp[-1].string)); + } +#line 2831 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 197: +#line 1945 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { rats_patch_append(yyPCB, RATP_ADD_CONN, (yyvsp[-2].string), (yyvsp[-1].string), NULL); free((yyvsp[-2].string)); free((yyvsp[-1].string)); } +#line 2837 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 198: +#line 1946 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { rats_patch_append(yyPCB, RATP_DEL_CONN, (yyvsp[-2].string), (yyvsp[-1].string), NULL); free((yyvsp[-2].string)); free((yyvsp[-1].string)); } +#line 2843 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 199: +#line 1947 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { rats_patch_append(yyPCB, RATP_CHANGE_ATTRIB, (yyvsp[-3].string), (yyvsp[-2].string), (yyvsp[-1].string)); free((yyvsp[-3].string)); free((yyvsp[-2].string)); free((yyvsp[-1].string)); } +#line 2849 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 200: +#line 1975 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { + CreateNewAttribute (attr_list, (yyvsp[-2].string), (yyvsp[-1].string) ? (yyvsp[-1].string) : (char *)""); + free ((yyvsp[-2].string)); + free ((yyvsp[-1].string)); + } +#line 2859 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 201: +#line 1982 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { (yyval.string) = (yyvsp[0].string); } +#line 2865 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 202: +#line 1983 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { (yyval.string) = 0; } +#line 2871 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 203: +#line 1987 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { (yyval.number) = (yyvsp[0].number); } +#line 2877 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 204: +#line 1988 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { (yyval.number) = (yyvsp[0].integer); } +#line 2883 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 205: +#line 1993 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { do_measure(&(yyval.measure), (yyvsp[0].number), MIL_TO_COORD ((yyvsp[0].number)) / 100.0, 0); } +#line 2889 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 206: +#line 1994 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { M ((yyval.measure), (yyvsp[-1].number), MIL_TO_COORD ((yyvsp[-1].number)) / 100000.0); } +#line 2895 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 207: +#line 1995 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { M ((yyval.measure), (yyvsp[-1].number), MIL_TO_COORD ((yyvsp[-1].number)) / 100.0); } +#line 2901 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 208: +#line 1996 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { M ((yyval.measure), (yyvsp[-1].number), MIL_TO_COORD ((yyvsp[-1].number))); } +#line 2907 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 209: +#line 1997 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { M ((yyval.measure), (yyvsp[-1].number), INCH_TO_COORD ((yyvsp[-1].number))); } +#line 2913 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 210: +#line 1998 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { M ((yyval.measure), (yyvsp[-1].number), MM_TO_COORD ((yyvsp[-1].number)) / 1000000.0); } +#line 2919 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 211: +#line 1999 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { M ((yyval.measure), (yyvsp[-1].number), MM_TO_COORD ((yyvsp[-1].number)) / 1000.0); } +#line 2925 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 212: +#line 2000 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { M ((yyval.measure), (yyvsp[-1].number), MM_TO_COORD ((yyvsp[-1].number))); } +#line 2931 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 213: +#line 2001 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { M ((yyval.measure), (yyvsp[-1].number), MM_TO_COORD ((yyvsp[-1].number)) * 1000.0); } +#line 2937 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + case 214: +#line 2002 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1646 */ + { M ((yyval.measure), (yyvsp[-1].number), MM_TO_COORD ((yyvsp[-1].number)) * 1000000.0); } +#line 2943 "parse_y.tab.c" /* yacc.c:1646 */ + break; + + +#line 2947 "parse_y.tab.c" /* yacc.c:1646 */ + default: break; + } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + /* Now 'shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*--------------------------------------. +| yyerrlab -- here on detecting error. | +`--------------------------------------*/ +yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) + { + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; + } +# undef YYSYNTAX_ERROR +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule whose action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (!yypact_value_is_default (yyn)) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined yyoverflow || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } + /* Do not reclaim the symbols of the rule whose action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + return yyresult; +} +#line 2005 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1906 */ + + +/* --------------------------------------------------------------------------- + * error routine called by parser library + */ +int yyerror(const char * s) +{ + Message("ERROR parsing file '%s'\n" + " line: %i\n" + " description: '%s'\n", + yyfilename, yylineno, s); + return(0); +} + +int yywrap() +{ + return 1; +} + +static int +check_file_version (int ver) +{ + if ( ver > PCB_FILE_VERSION ) { + Message ("ERROR: The file you are attempting to load is in a format\n" + "which is too new for this version of pcb. To load this file\n" + "you need a version of pcb which is >= %d. If you are\n" + "using a version built from git source, the source date\n" + "must be >= %d. This copy of pcb can only read files\n" + "up to file version %d.\n", ver, ver, PCB_FILE_VERSION); + return 1; + } + + return 0; +} + +static void +do_measure (PLMeasure *m, Coord i, double d, int u) +{ + m->ival = i; + m->bval = round (d); + m->dval = d; + m->has_units = u; +} + +static int +integer_value (PLMeasure m) +{ + if (m.has_units) + yyerror("units ignored here"); + return m.ival; +} + +static Coord +old_units (PLMeasure m) +{ + if (m.has_units) + return m.bval; + return round (MIL_TO_COORD (m.ival)); +} + +static Coord +new_units (PLMeasure m) +{ + if (m.has_units) + return m.bval; + return round (MIL_TO_COORD (m.ival) / 100.0); +} Index: trunk/src_plugins/io_pcb/parse_y.h =================================================================== --- trunk/src_plugins/io_pcb/parse_y.h (nonexistent) +++ trunk/src_plugins/io_pcb/parse_y.h (revision 1761) @@ -0,0 +1,123 @@ +/* A Bison parser, made by GNU Bison 3.0.2. */ + +/* Bison interface for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +#ifndef YY_YY_PARSE_Y_TAB_H_INCLUDED +# define YY_YY_PARSE_Y_TAB_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + FLOATING = 258, + INTEGER = 259, + CHAR_CONST = 260, + STRING = 261, + T_FILEVERSION = 262, + T_PCB = 263, + T_LAYER = 264, + T_VIA = 265, + T_RAT = 266, + T_LINE = 267, + T_ARC = 268, + T_RECTANGLE = 269, + T_TEXT = 270, + T_ELEMENTLINE = 271, + T_ELEMENT = 272, + T_PIN = 273, + T_PAD = 274, + T_GRID = 275, + T_FLAGS = 276, + T_SYMBOL = 277, + T_SYMBOLLINE = 278, + T_CURSOR = 279, + T_ELEMENTARC = 280, + T_MARK = 281, + T_GROUPS = 282, + T_STYLES = 283, + T_POLYGON = 284, + T_POLYGON_HOLE = 285, + T_NETLIST = 286, + T_NET = 287, + T_CONN = 288, + T_NETLISTPATCH = 289, + T_ADD_CONN = 290, + T_DEL_CONN = 291, + T_CHANGE_ATTRIB = 292, + T_AREA = 293, + T_THERMAL = 294, + T_DRC = 295, + T_ATTRIBUTE = 296, + T_UMIL = 297, + T_CMIL = 298, + T_MIL = 299, + T_IN = 300, + T_NM = 301, + T_UM = 302, + T_MM = 303, + T_M = 304, + T_KM = 305 + }; +#endif + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE YYSTYPE; +union YYSTYPE +{ +#line 111 "../../src_plugins/io_pcb/parse_y.y" /* yacc.c:1909 */ + + int integer; + double number; + char *string; + FlagType flagtype; + PLMeasure measure; + +#line 113 "parse_y.tab.h" /* yacc.c:1909 */ +}; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + +int yyparse (void); + +#endif /* !YY_YY_PARSE_Y_TAB_H_INCLUDED */ Index: trunk/src_plugins/io_pcb/parse_y.y =================================================================== --- trunk/src_plugins/io_pcb/parse_y.y (nonexistent) +++ trunk/src_plugins/io_pcb/parse_y.y (revision 1761) @@ -0,0 +1,2071 @@ +/* $Id$ */ +/* + * ************************** README ******************* + * + * If the file format is modified in any way, update + * PCB_FILE_VERSION in file.h + * + * ************************** README ******************* + */ + +%{ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Contact addresses for paper mail and Email: + * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany + * Thomas.Nau@rz.uni-ulm.de + * + */ + +/* grammar to parse ASCII input of PCB description + */ + +#include "config.h" +#include "conf_core.h" + +#include "global.h" +#include "create.h" +#include "data.h" +#include "error.h" +#include "file.h" +#include "mymem.h" +#include "misc.h" +#include "parse_l.h" +#include "polygon.h" +#include "remove.h" +#include "rtree.h" +#include "strflags.h" +#include "thermal.h" +#include "rats_patch.h" + +#ifdef HAVE_LIBDMALLOC +# include /* see http://dmalloc.com */ +#endif + +RCSID("$Id$"); + +static LayerTypePtr Layer; +static PolygonTypePtr Polygon; +static SymbolTypePtr Symbol; +static int pin_num; +static LibraryMenuTypePtr Menu; +static bool LayerFlag[MAX_LAYER + 2]; + +extern char *yytext; /* defined by LEX */ +extern PCBTypePtr yyPCB; +extern DataTypePtr yyData; +extern ElementTypePtr yyElement; +extern FontTypePtr yyFont; +extern int yylineno; /* linenumber */ +extern char *yyfilename; /* in this file */ + +static char *layer_group_string; + +static AttributeListTypePtr attr_list; + +int yyerror(const char *s); +int yylex(); +static int check_file_version (int); + +static void do_measure (PLMeasure *m, Coord i, double d, int u); +#define M(r,f,d) do_measure (&(r), f, d, 1) + +/* Macros for interpreting what "measure" means - integer value only, + old units (mil), or new units (cmil). */ +#define IV(m) integer_value (m) +#define OU(m) old_units (m) +#define NU(m) new_units (m) + +static int integer_value (PLMeasure m); +static Coord old_units (PLMeasure m); +static Coord new_units (PLMeasure m); + +#define YYDEBUG 1 +#define YYERROR_VERBOSE 1 + +#include "parse_y.h" + +%} + +%verbose + +%union /* define YYSTACK type */ +{ + int integer; + double number; + char *string; + FlagType flagtype; + PLMeasure measure; +} + +%token FLOATING /* line thickness, coordinates ... */ +%token INTEGER CHAR_CONST /* flags ... */ +%token STRING /* element names ... */ + +%token T_FILEVERSION T_PCB T_LAYER T_VIA T_RAT T_LINE T_ARC T_RECTANGLE T_TEXT T_ELEMENTLINE +%token T_ELEMENT T_PIN T_PAD T_GRID T_FLAGS T_SYMBOL T_SYMBOLLINE T_CURSOR +%token T_ELEMENTARC T_MARK T_GROUPS T_STYLES T_POLYGON T_POLYGON_HOLE T_NETLIST T_NET T_CONN +%token T_NETLISTPATCH T_ADD_CONN T_DEL_CONN T_CHANGE_ATTRIB +%token T_AREA T_THERMAL T_DRC T_ATTRIBUTE +%token T_UMIL T_CMIL T_MIL T_IN T_NM T_UM T_MM T_M T_KM +%type symbolid +%type opt_string +%type flags +%type number +%type measure + +%% + +parse + : parsepcb + | parsedata + | parsefont + | error { YYABORT; } + ; + +/* %start-doc pcbfile 00pcb +@nodetype subsection +@nodename %s syntax + +A special note about units: Older versions of @code{pcb} used mils +(1/1000 inch) as the base unit; a value of 500 in the file meant +half an inch. Newer versions uses a "high resolution" syntax, +where the base unit is 1/100 of a mil (0.000010 inch); a value of 500 in +the file means 5 mils. As a general rule, the variants of each entry +listed below which use square brackets are the high resolution formats +and use the 1/100 mil units, and the ones with parentheses are the older +variants and use 1 mil units. Note that when multiple variants +are listed, the most recent (and most preferred) format is the first +listed. + +Symbolic and numeric flags (SFlags and NFlags) are described in +@ref{Object Flags}. + +%end-doc */ + +parsepcb + : { + /* reset flags for 'used layers'; + * init font and data pointers + */ + int i; + + if (!yyPCB) + { + Message("illegal fileformat\n"); + YYABORT; + } + for (i = 0; i < MAX_LAYER + 2; i++) + LayerFlag[i] = false; + yyFont = &yyPCB->Font; + yyData = yyPCB->Data; + yyData->pcb = yyPCB; + yyData->LayerN = 0; + yyPCB->NetlistPatches = yyPCB->NetlistPatchLast = NULL; + layer_group_string = NULL; + } + pcbfileversion + pcbname + pcbgrid + pcbcursor + polyarea + pcbthermal + pcbdrc + pcbflags + pcbgroups + pcbstyles + pcbfont + pcbdata + pcbnetlist + pcbnetlistpatch + { + PCBTypePtr pcb_save = PCB; + + if (layer_group_string == NULL) + layer_group_string = strdup(conf_core.design.groups); + CreateNewPCBPost (yyPCB, 0); + if (ParseGroupString(layer_group_string, &yyPCB->LayerGroups, yyData->LayerN)) + { + Message("illegal layer-group string\n"); + YYABORT; + } + /* initialize the polygon clipping now since + * we didn't know the layer grouping before. + */ + free(layer_group_string); + PCB = yyPCB; + ALLPOLYGON_LOOP (yyData); + { + InitClip (yyData, layer, polygon); + } + ENDALL_LOOP; + PCB = pcb_save; + } + + | { PreLoadElementPCB (); + layer_group_string = NULL; } + element + { LayerFlag[0] = true; + LayerFlag[1] = true; + yyData->LayerN = 2; + PostLoadElementPCB (); + } + ; + +parsedata + : { + /* reset flags for 'used layers'; + * init font and data pointers + */ + int i; + + if (!yyData || !yyFont) + { + Message("illegal fileformat\n"); + YYABORT; + } + for (i = 0; i < MAX_LAYER + 2; i++) + LayerFlag[i] = false; + yyData->LayerN = 0; + } + pcbdata + ; + +pcbfont + : parsefont + | + ; + +parsefont + : + { + /* mark all symbols invalid */ + int i; + + if (!yyFont) + { + Message("illegal fileformat\n"); + YYABORT; + } + yyFont->Valid = false; + for (i = 0; i <= MAX_FONTPOSITION; i++) + free (yyFont->Symbol[i].Line); + bzero(yyFont->Symbol, sizeof(yyFont->Symbol)); + } + symbols + { + yyFont->Valid = true; + SetFontInfo(yyFont); + } + ; + +/* %start-doc pcbfile FileVersion + +@syntax +FileVersion[Version] +@end syntax + +@table @var +@item Version +File format version. This version number represents the date when the pcb file +format was last changed. +@end table + +Any version of pcb build from sources equal to or newer +than this number should be able to read the file. If this line is not present +in the input file then file format compatibility is not checked. + + +%end-doc */ + +pcbfileversion +: | +T_FILEVERSION '[' INTEGER ']' +{ + if (check_file_version ($3) != 0) + { + YYABORT; + } +} +; + +/* %start-doc pcbfile PCB + +@syntax +PCB ["Name" Width Height] +PCB ("Name" Width Height] +PCB ("Name") +@end syntax + +@table @var +@item Name +Name of the PCB project +@item Width Height +Size of the board +@end table + +If you don't specify the size of the board, a very large default is +chosen. + +%end-doc */ + +pcbname + : T_PCB '(' STRING ')' + { + yyPCB->Name = $3; + yyPCB->MaxWidth = MAX_COORD; + yyPCB->MaxHeight = MAX_COORD; + } + | T_PCB '(' STRING measure measure ')' + { + yyPCB->Name = $3; + yyPCB->MaxWidth = OU ($4); + yyPCB->MaxHeight = OU ($5); + } + | T_PCB '[' STRING measure measure ']' + { + yyPCB->Name = $3; + yyPCB->MaxWidth = NU ($4); + yyPCB->MaxHeight = NU ($5); + } + ; + +/* %start-doc pcbfile Grid + +@syntax +Grid [Step OffsetX OffsetY Visible] +Grid (Step OffsetX OffsetY Visible) +Grid (Step OffsetX OffsetY) +@end syntax + +@table @var +@item Step +Distance from one grid point to adjacent points. This value may be a +floating point number for the first two variants. +@item OffsetX OffsetY +The "origin" of the grid. Normally zero. +@item Visible +If non-zero, the grid will be visible on the screen. +@end table + +%end-doc */ + +pcbgrid + : pcbgridold + | pcbgridnew + | pcbhigrid + ; +pcbgridold + : T_GRID '(' measure measure measure ')' + { + yyPCB->Grid = OU ($3); + yyPCB->GridOffsetX = OU ($4); + yyPCB->GridOffsetY = OU ($5); + } + ; +pcbgridnew + : T_GRID '(' measure measure measure INTEGER ')' + { + yyPCB->Grid = OU ($3); + yyPCB->GridOffsetX = OU ($4); + yyPCB->GridOffsetY = OU ($5); + if ($6) + conf_core.editor.draw_grid = true; + else + conf_core.editor.draw_grid = false; + } + ; + +pcbhigrid + : T_GRID '[' measure measure measure INTEGER ']' + { + yyPCB->Grid = NU ($3); + yyPCB->GridOffsetX = NU ($4); + yyPCB->GridOffsetY = NU ($5); + if ($6) + conf_core.editor.draw_grid = true; + else + conf_core.editor.draw_grid = false; + } + ; + +/* %start-doc pcbfile Cursor + +@syntax +Cursor [X Y Zoom] +Cursor (X Y Zoom) +@end syntax + +@table @var +@item X Y +Location of the cursor when the board was saved. +@item Zoom +The current zoom factor. Note that a zoom factor of "0" means 1 mil +per screen pixel, N means @math{2^N} mils per screen pixel, etc. The +first variant accepts floating point numbers. The special value +"1000" means "zoom to fit" +@end table + +%end-doc */ + +pcbcursor + : T_CURSOR '(' measure measure number ')' + { + yyPCB->CursorX = OU ($3); + yyPCB->CursorY = OU ($4); + yyPCB->Zoom = $5*2; + } + | T_CURSOR '[' measure measure number ']' + { + yyPCB->CursorX = NU ($3); + yyPCB->CursorY = NU ($4); + yyPCB->Zoom = $5; + } + | + ; + +/* %start-doc pcbfile PolyArea + +@syntax +PolyArea [Area] +@end syntax + +@table @var +@item Area +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. +@end table + +%end-doc */ + +polyarea + : + | T_AREA '[' number ']' + { + /* Read in cmil^2 for now; in future this should be a noop. */ + yyPCB->IsleArea = MIL_TO_COORD (MIL_TO_COORD ($3) / 100.0) / 100.0; + } + ; + + +/* %start-doc pcbfile Thermal + +@syntax +Thermal [Scale] +@end syntax + +@table @var +@item Scale +Relative size of thermal fingers. A value of 1.0 makes the finger +width twice the clearance gap width (measured across the gap, not +diameter). The normal value is 0.5, which results in a finger width +the same as the clearance gap width. +@end table + +%end-doc */ + + +pcbthermal + : + | T_THERMAL '[' number ']' + { + yyPCB->ThermScale = $3; + } + ; + +/* %start-doc pcbfile DRC + +@syntax +DRC [Bloat Shrink Line Silk Drill Ring] +DRC [Bloat Shrink Line Silk] +DRC [Bloat Shrink Line] +@end syntax + +@table @var +@item Bloat +Minimum spacing between copper. +@item Shrink +Minimum copper overlap to guarantee connectivity. +@item Line +Minimum line thickness. +@item Silk +Minimum silk thickness. +@item Drill +Minimum drill size. +@item Ring +Minimum width of the annular ring around pins and vias. +@end table + +%end-doc */ + +pcbdrc + : + | pcbdrc1 + | pcbdrc2 + | pcbdrc3 + ; + +pcbdrc1 + : T_DRC '[' measure measure measure ']' + { + yyPCB->Bloat = NU ($3); + yyPCB->Shrink = NU ($4); + yyPCB->minWid = NU ($5); + yyPCB->minRing = NU ($5); + } + ; + +pcbdrc2 + : T_DRC '[' measure measure measure measure ']' + { + yyPCB->Bloat = NU ($3); + yyPCB->Shrink = NU ($4); + yyPCB->minWid = NU ($5); + yyPCB->minSlk = NU ($6); + yyPCB->minRing = NU ($5); + } + ; + +pcbdrc3 + : T_DRC '[' measure measure measure measure measure measure ']' + { + yyPCB->Bloat = NU ($3); + yyPCB->Shrink = NU ($4); + yyPCB->minWid = NU ($5); + yyPCB->minSlk = NU ($6); + yyPCB->minDrill = NU ($7); + yyPCB->minRing = NU ($8); + } + ; + +/* %start-doc pcbfile Flags + +@syntax +Flags(Number) +@end syntax + +@table @var +@item Number +A number, whose value is normally given in hex, individual bits of which +represent pcb-wide flags as defined in @ref{PCBFlags}. + +@end table + +%end-doc */ + +pcbflags + : T_FLAGS '(' INTEGER ')' + { + yyPCB->Flags = MakeFlags ($3 & PCB_FLAGS); + } + | T_FLAGS '(' STRING ')' + { + yyPCB->Flags = string_to_pcbflags ($3, yyerror); + free($3); + } + | + ; + +/* %start-doc pcbfile Groups + +@syntax +Groups("String") +@end syntax + +@table @var +@item String + +Encodes the layer grouping information. Each group is separated by a +colon, each member of each group is separated by a comma. Group +members are either numbers from @code{1}..@var{N} for each layer, and +the letters @code{c} or @code{s} representing the component side and +solder side of the board. Including @code{c} or @code{s} marks that +group as being the top or bottom side of the board. + +@example +Groups("1,2,c:3:4:5,6,s:7,8") +@end example + +@end table + +%end-doc */ + +pcbgroups + : T_GROUPS '(' STRING ')' + { + layer_group_string = $3; + } + | + ; + +/* %start-doc pcbfile Styles + +@syntax +Styles("String") +@end syntax + +@table @var +@item String + +Encodes the four routing styles @code{pcb} knows about. The four styles +are separated by colons. Each style consists of five parameters as follows: + +@table @var +@item Name +The name of the style. +@item Thickness +Width of lines and arcs. +@item Diameter +Copper diameter of pins and vias. +@item Drill +Drill diameter of pins and vias. +@item Keepaway +Minimum spacing to other nets. If omitted, 10 mils is the default. + +@end table + +@end table + +@example +Styles("Signal,10,40,20:Power,25,60,35:Fat,40,60,35:Skinny,8,36,20") +Styles["Logic,1000,3600,2000,1000:Power,2500,6000,3500,1000: +@ @ @ Line,4000,6000,3500,1000:Breakout,600,2402,1181,600"] +@end example + +@noindent +Note that strings in actual files cannot span lines; the above example +is split across lines only to make it readable. + +%end-doc */ + +pcbstyles + : T_STYLES '(' STRING ')' + { + if (ParseRouteString($3, &yyPCB->RouteStyle[0], "mil")) + { + Message("illegal route-style string\n"); + YYABORT; + } + free($3); + } + | T_STYLES '[' STRING ']' + { + if (ParseRouteString($3, &yyPCB->RouteStyle[0], "cmil")) + { + Message("illegal route-style string\n"); + YYABORT; + } + free($3); + } + | + ; + +pcbdata + : pcbdefinitions + | + ; + +pcbdefinitions + : pcbdefinition + | pcbdefinitions pcbdefinition + ; + +pcbdefinition + : via + | { attr_list = & yyPCB->Attributes; } attribute + | rats + | layer + | + { + /* clear pointer to force memory allocation by + * the appropriate subroutine + */ + yyElement = NULL; + } + element + | error { YYABORT; } + ; + +via + : via_hi_format + | via_2.0_format + | via_1.7_format + | via_newformat + | via_oldformat + ; + +/* %start-doc pcbfile Via + +@syntax +Via [X Y Thickness Clearance Mask Drill "Name" SFlags] +Via (X Y Thickness Clearance Mask Drill "Name" NFlags) +Via (X Y Thickness Clearance Drill "Name" NFlags) +Via (X Y Thickness Drill "Name" NFlags) +Via (X Y Thickness "Name" NFlags) +@end syntax + +@table @var +@item X Y +coordinates of center +@item Thickness +outer diameter of copper annulus +@item Clearance +add to thickness to get clearance diameter +@item Mask +diameter of solder mask opening +@item Drill +diameter of drill +@item Name +string, name of via (vias have names?) +@item SFlags +symbolic or numerical flags +@item NFlags +numerical flags only +@end table + +%end-doc */ + +via_hi_format + /* x, y, thickness, clearance, mask, drilling-hole, name, flags */ + : T_VIA '[' measure measure measure measure measure measure STRING flags ']' + { + CreateNewVia(yyData, NU ($3), NU ($4), NU ($5), NU ($6), NU ($7), + NU ($8), $9, $10); + free ($9); + } + ; + +via_2.0_format + /* x, y, thickness, clearance, mask, drilling-hole, name, flags */ + : T_VIA '(' measure measure measure measure measure measure STRING INTEGER ')' + { + CreateNewVia(yyData, OU ($3), OU ($4), OU ($5), OU ($6), OU ($7), OU ($8), $9, + OldFlags($10)); + free ($9); + } + ; + + +via_1.7_format + /* x, y, thickness, clearance, drilling-hole, name, flags */ + : T_VIA '(' measure measure measure measure measure STRING INTEGER ')' + { + CreateNewVia(yyData, OU ($3), OU ($4), OU ($5), OU ($6), + OU ($5) + OU($6), OU ($7), $8, OldFlags($9)); + free ($8); + } + ; + +via_newformat + /* x, y, thickness, drilling-hole, name, flags */ + : T_VIA '(' measure measure measure measure STRING INTEGER ')' + { + CreateNewVia(yyData, OU ($3), OU ($4), OU ($5), 2*GROUNDPLANEFRAME, + OU($5) + 2*MASKFRAME, OU ($6), $7, OldFlags($8)); + free ($7); + } + ; + +via_oldformat + /* old format: x, y, thickness, name, flags */ + : T_VIA '(' measure measure measure STRING INTEGER ')' + { + Coord hole = (OU($5) * DEFAULT_DRILLINGHOLE); + + /* make sure that there's enough copper left */ + if (OU($5) - hole < MIN_PINORVIACOPPER && + OU($5) > MIN_PINORVIACOPPER) + hole = OU($5) - MIN_PINORVIACOPPER; + + CreateNewVia(yyData, OU ($3), OU ($4), OU ($5), 2*GROUNDPLANEFRAME, + OU($5) + 2*MASKFRAME, hole, $6, OldFlags($7)); + free ($6); + } + ; + +/* %start-doc pcbfile Rat + +@syntax +Rat [X1 Y1 Group1 X2 Y2 Group2 SFlags] +Rat (X1 Y1 Group1 X2 Y2 Group2 NFlags) +@end syntax + +@table @var +@item X1 Y1 X2 Y2 +The endpoints of the rat line. +@item Group1 Group2 +The layer group each end is connected on. +@item SFlags +Symbolic or numeric flags. +@item NFlags +Numeric flags. +@end table + +%end-doc */ + +rats + : T_RAT '[' measure measure INTEGER measure measure INTEGER flags ']' + { + CreateNewRat(yyData, NU ($3), NU ($4), NU ($6), NU ($7), $5, $8, + conf_core.appearance.rat_thickness, $9); + } + | T_RAT '(' measure measure INTEGER measure measure INTEGER INTEGER ')' + { + CreateNewRat(yyData, OU ($3), OU ($4), OU ($6), OU ($7), $5, $8, + conf_core.appearance.rat_thickness, OldFlags($9)); + } + ; + +/* %start-doc pcbfile Layer + +@syntax +Layer (LayerNum "Name") ( +@ @ @ @dots{} contents @dots{} +) +@end syntax + +@table @var +@item LayerNum +The layer number. Layers are numbered sequentially, starting with 1. +The last two layers (9 and 10 by default) are solder-side silk and +component-side silk, in that order. +@item Name +The layer name. +@item contents +The contents of the layer, which may include attributes, lines, arcs, rectangles, +text, and polygons. +@end table + +%end-doc */ + +layer + /* name */ + : T_LAYER '(' INTEGER STRING opt_string ')' '(' + { + if ($3 <= 0 || $3 > MAX_LAYER + 2) + { + yyerror("Layernumber out of range"); + YYABORT; + } + if (LayerFlag[$3-1]) + { + yyerror("Layernumber used twice"); + YYABORT; + } + Layer = &yyData->Layer[$3-1]; + + /* memory for name is already allocated */ + if (Layer->Name != NULL) + free(Layer->Name); + Layer->Name = $4; + LayerFlag[$3-1] = true; + if (yyData->LayerN + 2 < $3) + yyData->LayerN = $3 - 2; + if ($5 != NULL) + free($5); + } + layerdata ')' + ; + +layerdata + : layerdefinitions + | + ; + +layerdefinitions + : layerdefinition + | layerdefinitions layerdefinition + ; + +layerdefinition + : line_hi_format + | line_1.7_format + | line_oldformat + | arc_hi_format + | arc_1.7_format + | arc_oldformat + /* x1, y1, x2, y2, flags */ + | T_RECTANGLE '(' measure measure measure measure INTEGER ')' + { + CreateNewPolygonFromRectangle(Layer, + OU ($3), OU ($4), OU ($3) + OU ($5), OU ($4) + OU ($6), OldFlags($7)); + } + | text_hi_format + | text_newformat + | text_oldformat + | { attr_list = & Layer->Attributes; } attribute + | polygon_format + +/* %start-doc pcbfile Line + +@syntax +Line [X1 Y1 X2 Y2 Thickness Clearance SFlags] +Line (X1 Y1 X2 Y2 Thickness Clearance NFlags) +Line (X1 Y1 X2 Y2 Thickness NFlags) +@end syntax + +@table @var +@item X1 Y1 X2 Y2 +The end points of the line +@item Thickness +The width of the line +@item Clearance +The amount of space cleared around the line when the line passes +through a polygon. The clearance is added to the thickness to get the +thickness of the clear; thus the space between the line and the +polygon is @math{Clearance/2} wide. +@item SFlags +Symbolic or numeric flags +@item NFlags +Numeric flags. +@end table + +%end-doc */ + +line_hi_format + /* x1, y1, x2, y2, thickness, clearance, flags */ + : T_LINE '[' measure measure measure measure measure measure flags ']' + { + CreateNewLineOnLayer(Layer, NU ($3), NU ($4), NU ($5), NU ($6), + NU ($7), NU ($8), $9); + } + ; + +line_1.7_format + /* x1, y1, x2, y2, thickness, clearance, flags */ + : T_LINE '(' measure measure measure measure measure measure INTEGER ')' + { + CreateNewLineOnLayer(Layer, OU ($3), OU ($4), OU ($5), OU ($6), + OU ($7), OU ($8), OldFlags($9)); + } + ; + +line_oldformat + /* x1, y1, x2, y2, thickness, flags */ + : T_LINE '(' measure measure measure measure measure measure ')' + { + /* eliminate old-style rat-lines */ + if ((IV ($8) & RATFLAG) == 0) + CreateNewLineOnLayer(Layer, OU ($3), OU ($4), OU ($5), OU ($6), OU ($7), + 200*GROUNDPLANEFRAME, OldFlags(IV ($8))); + } + ; + +/* %start-doc pcbfile Arc + +@syntax +Arc [X Y Width Height Thickness Clearance StartAngle DeltaAngle SFlags] +Arc (X Y Width Height Thickness Clearance StartAngle DeltaAngle NFlags) +Arc (X Y Width Height Thickness StartAngle DeltaAngle NFlags) +@end syntax + +@table @var +@item X Y +Coordinates of the center of the arc. +@item Width Height +The width and height, from the center to the edge. The bounds of the +circle of which this arc is a segment, is thus @math{2*Width} by +@math{2*Height}. +@item Thickness +The width of the copper trace which forms the arc. +@item Clearance +The amount of space cleared around the arc when the line passes +through a polygon. The clearance is added to the thickness to get the +thickness of the clear; thus the space between the arc and the polygon +is @math{Clearance/2} wide. +@item StartAngle +The angle of one end of the arc, in degrees. In PCB, an angle of zero +points left (negative X direction), and 90 degrees points down +(positive Y direction). +@item DeltaAngle +The sweep of the arc. This may be negative. Positive angles sweep +counterclockwise. +@item SFlags +Symbolic or numeric flags. +@item NFlags +Numeric flags. +@end table + +%end-doc */ + +arc_hi_format + /* x, y, width, height, thickness, clearance, startangle, delta, flags */ + : T_ARC '[' measure measure measure measure measure measure number number flags ']' + { + CreateNewArcOnLayer(Layer, NU ($3), NU ($4), NU ($5), NU ($6), $9, $10, + NU ($7), NU ($8), $11); + } + ; + +arc_1.7_format + /* x, y, width, height, thickness, clearance, startangle, delta, flags */ + : T_ARC '(' measure measure measure measure measure measure number number INTEGER ')' + { + CreateNewArcOnLayer(Layer, OU ($3), OU ($4), OU ($5), OU ($6), $9, $10, + OU ($7), OU ($8), OldFlags($11)); + } + ; + +arc_oldformat + /* x, y, width, height, thickness, startangle, delta, flags */ + : T_ARC '(' measure measure measure measure measure measure number INTEGER ')' + { + CreateNewArcOnLayer(Layer, OU ($3), OU ($4), OU ($5), OU ($5), IV ($8), $9, + OU ($7), 200*GROUNDPLANEFRAME, OldFlags($10)); + } + ; + +/* %start-doc pcbfile Text + +@syntax +Text [X Y Direction Scale "String" SFlags] +Text (X Y Direction Scale "String" NFlags) +Text (X Y Direction "String" NFlags) +@end syntax + +@table @var +@item X Y +The location of the upper left corner of the text. +@item Direction +0 means text is drawn left to right, 1 means up, 2 means right to left +(i.e. upside down), and 3 means down. +@item Scale +Size of the text, as a percentage of the ``default'' size of of the +font (the default font is about 40 mils high). Default is 100 (40 +mils). +@item String +The string to draw. +@item SFlags +Symbolic or numeric flags. +@item NFlags +Numeric flags. +@end table + +%end-doc */ + +text_oldformat + /* x, y, direction, text, flags */ + : T_TEXT '(' measure measure number STRING INTEGER ')' + { + /* use a default scale of 100% */ + CreateNewText(Layer,yyFont,OU ($3), OU ($4), $5, 100, $6, OldFlags($7)); + free ($6); + } + ; + +text_newformat + /* x, y, direction, scale, text, flags */ + : T_TEXT '(' measure measure number number STRING INTEGER ')' + { + if ($8 & ONSILKFLAG) + { + LayerTypePtr lay = &yyData->Layer[yyData->LayerN + + (($8 & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)]; + + CreateNewText(lay ,yyFont, OU ($3), OU ($4), $5, $6, $7, + OldFlags($8)); + } + else + CreateNewText(Layer, yyFont, OU ($3), OU ($4), $5, $6, $7, + OldFlags($8)); + free ($7); + } + ; +text_hi_format + /* x, y, direction, scale, text, flags */ + : T_TEXT '[' measure measure number number STRING flags ']' + { + /* FIXME: shouldn't know about .f */ + /* I don't think this matters because anything with hi_format + * will have the silk on its own layer in the file rather + * than using the ONSILKFLAG and having it in a copper layer. + * Thus there is no need for anything besides the 'else' + * part of this code. + */ + if ($8.f & ONSILKFLAG) + { + LayerTypePtr lay = &yyData->Layer[yyData->LayerN + + (($8.f & ONSOLDERFLAG) ? SOLDER_LAYER : COMPONENT_LAYER)]; + + CreateNewText(lay, yyFont, NU ($3), NU ($4), $5, $6, $7, $8); + } + else + CreateNewText(Layer, yyFont, NU ($3), NU ($4), $5, $6, $7, $8); + free ($7); + } + ; + +/* %start-doc pcbfile Polygon + +@syntax +Polygon (SFlags) ( +@ @ @ @dots{} (X Y) @dots{} +@ @ @ @dots{} [X Y] @dots{} +@ @ @ Hole ( +@ @ @ @ @ @ @dots{} (X Y) @dots{} +@ @ @ @ @ @ @dots{} [X Y] @dots{} +@ @ @ ) +@ @ @ @dots{} +) +@end syntax + +@table @var +@item SFlags +Symbolic or numeric flags. +@item X Y +Coordinates of each vertex. You must list at least three coordinates. +@item Hole (...) +Defines a hole within the polygon's outer contour. There may be zero or more such sections. +@end table + +%end-doc */ + +polygon_format + : /* flags are passed in */ + T_POLYGON '(' flags ')' '(' + { + Polygon = CreateNewPolygon(Layer, $3); + } + polygonpoints + polygonholes ')' + { + Cardinal contour, contour_start, contour_end; + bool bad_contour_found = false; + /* ignore junk */ + for (contour = 0; contour <= Polygon->HoleIndexN; contour++) + { + contour_start = (contour == 0) ? + 0 : Polygon->HoleIndex[contour - 1]; + contour_end = (contour == Polygon->HoleIndexN) ? + Polygon->PointN : + Polygon->HoleIndex[contour]; + if (contour_end - contour_start < 3) + bad_contour_found = true; + } + + if (bad_contour_found) + { + Message("WARNING parsing file '%s'\n" + " line: %i\n" + " description: 'ignored polygon (< 3 points in a contour)'\n", + yyfilename, yylineno); + DestroyObject(yyData, POLYGON_TYPE, Layer, Polygon, Polygon); + } + else + { + SetPolygonBoundingBox (Polygon); + if (!Layer->polygon_tree) + Layer->polygon_tree = r_create_tree (NULL, 0, 0); + r_insert_entry (Layer->polygon_tree, (BoxType *) Polygon, 0); + } + } + ; + +polygonholes + : /* empty */ + | polygonholes polygonhole + ; + +polygonhole + : T_POLYGON_HOLE '(' + { + CreateNewHoleInPolygon (Polygon); + } + polygonpoints ')' + ; + +polygonpoints + : /* empty */ + | polygonpoint polygonpoints + ; + +polygonpoint + /* xcoord ycoord */ + : '(' measure measure ')' + { + CreateNewPointInPolygon(Polygon, OU ($2), OU ($3)); + } + | '[' measure measure ']' + { + CreateNewPointInPolygon(Polygon, NU ($2), NU ($3)); + } + ; + +/* %start-doc pcbfile Element + +@syntax +Element [SFlags "Desc" "Name" "Value" MX MY TX TY TDir TScale TSFlags] ( +Element (NFlags "Desc" "Name" "Value" MX MY TX TY TDir TScale TNFlags) ( +Element (NFlags "Desc" "Name" "Value" TX TY TDir TScale TNFlags) ( +Element (NFlags "Desc" "Name" TX TY TDir TScale TNFlags) ( +Element ("Desc" "Name" TX TY TDir TScale TNFlags) ( +@ @ @ @dots{} contents @dots{} +) +@end syntax + +@table @var +@item SFlags +Symbolic or numeric flags, for the element as a whole. +@item NFlags +Numeric flags, for the element as a whole. +@item Desc +The description of the element. This is one of the three strings +which can be displayed on the screen. +@item Name +The name of the element, usually the reference designator. +@item Value +The value of the element. +@item MX MY +The location of the element's mark. This is the reference point +for placing the element and its pins and pads. +@item TX TY +The upper left corner of the text (one of the three strings). +@item TDir +The relative direction of the text. 0 means left to right for +an unrotated element, 1 means up, 2 left, 3 down. +@item TScale +Size of the text, as a percentage of the ``default'' size of of the +font (the default font is about 40 mils high). Default is 100 (40 +mils). +@item TSFlags +Symbolic or numeric flags, for the text. +@item TNFlags +Numeric flags, for the text. +@end table + +Elements may contain pins, pads, element lines, element arcs, +attributes, and (for older elements) an optional mark. Note that +element definitions that have the mark coordinates in the element +line, only support pins and pads which use relative coordinates. The +pin and pad coordinates are relative to the mark. Element definitions +which do not include the mark coordinates in the element line, may +have a Mark definition in their contents, and only use pin and pad +definitions which use absolute coordinates. + +%end-doc */ + +element + : element_oldformat + | element_1.3.4_format + | element_newformat + | element_1.7_format + | element_hi_format + ; + +element_oldformat + /* element_flags, description, pcb-name, + * text_x, text_y, text_direction, text_scale, text_flags + */ + : T_ELEMENT '(' STRING STRING measure measure INTEGER ')' '(' + { + yyElement = CreateNewElement(yyData, yyElement, yyFont, NoFlags(), + $3, $4, NULL, OU ($5), OU ($6), $7, 100, NoFlags(), false); + free ($3); + free ($4); + pin_num = 1; + } + elementdefinitions ')' + { + SetElementBoundingBox(yyData, yyElement, yyFont); + } + ; + +element_1.3.4_format + /* element_flags, description, pcb-name, + * text_x, text_y, text_direction, text_scale, text_flags + */ + : T_ELEMENT '(' INTEGER STRING STRING measure measure measure measure INTEGER ')' '(' + { + yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3), + $4, $5, NULL, OU ($6), OU ($7), IV ($8), IV ($9), OldFlags($10), false); + free ($4); + free ($5); + pin_num = 1; + } + elementdefinitions ')' + { + SetElementBoundingBox(yyData, yyElement, yyFont); + } + ; + +element_newformat + /* element_flags, description, pcb-name, value, + * text_x, text_y, text_direction, text_scale, text_flags + */ + : T_ELEMENT '(' INTEGER STRING STRING STRING measure measure measure measure INTEGER ')' '(' + { + yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3), + $4, $5, $6, OU ($7), OU ($8), IV ($9), IV ($10), OldFlags($11), false); + free ($4); + free ($5); + free ($6); + pin_num = 1; + } + elementdefinitions ')' + { + SetElementBoundingBox(yyData, yyElement, yyFont); + } + ; + +element_1.7_format + /* element_flags, description, pcb-name, value, mark_x, mark_y, + * text_x, text_y, text_direction, text_scale, text_flags + */ + : T_ELEMENT '(' INTEGER STRING STRING STRING measure measure + measure measure number number INTEGER ')' '(' + { + yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3), + $4, $5, $6, OU ($7) + OU ($9), OU ($8) + OU ($10), + $11, $12, OldFlags($13), false); + yyElement->MarkX = OU ($7); + yyElement->MarkY = OU ($8); + free ($4); + free ($5); + free ($6); + } + relementdefs ')' + { + SetElementBoundingBox(yyData, yyElement, yyFont); + } + ; + +element_hi_format + /* element_flags, description, pcb-name, value, mark_x, mark_y, + * text_x, text_y, text_direction, text_scale, text_flags + */ + : T_ELEMENT '[' flags STRING STRING STRING measure measure + measure measure number number flags ']' '(' + { + yyElement = CreateNewElement(yyData, yyElement, yyFont, $3, + $4, $5, $6, NU ($7) + NU ($9), NU ($8) + NU ($10), + $11, $12, $13, false); + yyElement->MarkX = NU ($7); + yyElement->MarkY = NU ($8); + free ($4); + free ($5); + free ($6); + } + relementdefs ')' + { + SetElementBoundingBox(yyData, yyElement, yyFont); + } + ; + +/* %start-doc pcbfile ElementLine + +@syntax +ElementLine [X1 Y1 X2 Y2 Thickness] +ElementLine (X1 Y1 X2 Y2 Thickness) +@end syntax + +@table @var +@item X1 Y1 X2 Y2 +Coordinates of the endpoints of the line. These are relative to the +Element's mark point for new element formats, or absolute for older +formats. +@item Thickness +The width of the silk for this line. +@end table + +%end-doc */ + +/* %start-doc pcbfile ElementArc + +@syntax +ElementArc [X Y Width Height StartAngle DeltaAngle Thickness] +ElementArc (X Y Width Height StartAngle DeltaAngle Thickness) +@end syntax + +@table @var +@item X Y +Coordinates of the center of the arc. These are relative to the +Element's mark point for new element formats, or absolute for older +formats. +@item Width Height +The width and height, from the center to the edge. The bounds of the +circle of which this arc is a segment, is thus @math{2*Width} by +@math{2*Height}. +@item StartAngle +The angle of one end of the arc, in degrees. In PCB, an angle of zero +points left (negative X direction), and 90 degrees points down +(positive Y direction). +@item DeltaAngle +The sweep of the arc. This may be negative. Positive angles sweep +counterclockwise. +@item Thickness +The width of the silk line which forms the arc. +@end table + +%end-doc */ + +/* %start-doc pcbfile Mark + +@syntax +Mark [X Y] +Mark (X Y) +@end syntax + +@table @var +@item X Y +Coordinates of the Mark, for older element formats that don't have +the mark as part of the Element line. +@end table + +%end-doc */ + +elementdefinitions + : elementdefinition + | elementdefinitions elementdefinition + ; + +elementdefinition + : pin_1.6.3_format + | pin_newformat + | pin_oldformat + | pad_newformat + | pad + /* x1, y1, x2, y2, thickness */ + | T_ELEMENTLINE '[' measure measure measure measure measure ']' + { + CreateNewLineInElement(yyElement, NU ($3), NU ($4), NU ($5), NU ($6), NU ($7)); + } + /* x1, y1, x2, y2, thickness */ + | T_ELEMENTLINE '(' measure measure measure measure measure ')' + { + CreateNewLineInElement(yyElement, OU ($3), OU ($4), OU ($5), OU ($6), OU ($7)); + } + /* x, y, width, height, startangle, anglediff, thickness */ + | T_ELEMENTARC '[' measure measure measure measure number number measure ']' + { + CreateNewArcInElement(yyElement, NU ($3), NU ($4), NU ($5), NU ($6), $7, $8, NU ($9)); + } + /* x, y, width, height, startangle, anglediff, thickness */ + | T_ELEMENTARC '(' measure measure measure measure number number measure ')' + { + CreateNewArcInElement(yyElement, OU ($3), OU ($4), OU ($5), OU ($6), $7, $8, OU ($9)); + } + /* x, y position */ + | T_MARK '[' measure measure ']' + { + yyElement->MarkX = NU ($3); + yyElement->MarkY = NU ($4); + } + | T_MARK '(' measure measure ')' + { + yyElement->MarkX = OU ($3); + yyElement->MarkY = OU ($4); + } + | { attr_list = & yyElement->Attributes; } attribute + ; + +relementdefs + : relementdef + | relementdefs relementdef + ; + +relementdef + : pin_1.7_format + | pin_hi_format + | pad_1.7_format + | pad_hi_format + /* x1, y1, x2, y2, thickness */ + | T_ELEMENTLINE '[' measure measure measure measure measure ']' + { + CreateNewLineInElement(yyElement, NU ($3) + yyElement->MarkX, + NU ($4) + yyElement->MarkY, NU ($5) + yyElement->MarkX, + NU ($6) + yyElement->MarkY, NU ($7)); + } + | T_ELEMENTLINE '(' measure measure measure measure measure ')' + { + CreateNewLineInElement(yyElement, OU ($3) + yyElement->MarkX, + OU ($4) + yyElement->MarkY, OU ($5) + yyElement->MarkX, + OU ($6) + yyElement->MarkY, OU ($7)); + } + /* x, y, width, height, startangle, anglediff, thickness */ + | T_ELEMENTARC '[' measure measure measure measure number number measure ']' + { + CreateNewArcInElement(yyElement, NU ($3) + yyElement->MarkX, + NU ($4) + yyElement->MarkY, NU ($5), NU ($6), $7, $8, NU ($9)); + } + | T_ELEMENTARC '(' measure measure measure measure number number measure ')' + { + CreateNewArcInElement(yyElement, OU ($3) + yyElement->MarkX, + OU ($4) + yyElement->MarkY, OU ($5), OU ($6), $7, $8, OU ($9)); + } + | { attr_list = & yyElement->Attributes; } attribute + ; + +/* %start-doc pcbfile Pin + +@syntax +Pin [rX rY Thickness Clearance Mask Drill "Name" "Number" SFlags] +Pin (rX rY Thickness Clearance Mask Drill "Name" "Number" NFlags) +Pin (aX aY Thickness Drill "Name" "Number" NFlags) +Pin (aX aY Thickness Drill "Name" NFlags) +Pin (aX aY Thickness "Name" NFlags) +@end syntax + +@table @var +@item rX rY +coordinates of center, relative to the element's mark +@item aX aY +absolute coordinates of center. +@item Thickness +outer diameter of copper annulus +@item Clearance +add to thickness to get clearance diameter +@item Mask +diameter of solder mask opening +@item Drill +diameter of drill +@item Name +name of pin +@item Number +number of pin +@item SFlags +symbolic or numerical flags +@item NFlags +numerical flags only +@end table + +%end-doc */ + +pin_hi_format + /* x, y, thickness, clearance, mask, drilling hole, name, + number, flags */ + : T_PIN '[' measure measure measure measure measure measure STRING STRING flags ']' + { + CreateNewPin(yyElement, NU ($3) + yyElement->MarkX, + NU ($4) + yyElement->MarkY, NU ($5), NU ($6), NU ($7), NU ($8), $9, + $10, $11); + free ($9); + free ($10); + } + ; +pin_1.7_format + /* x, y, thickness, clearance, mask, drilling hole, name, + number, flags */ + : T_PIN '(' measure measure measure measure measure measure STRING STRING INTEGER ')' + { + CreateNewPin(yyElement, OU ($3) + yyElement->MarkX, + OU ($4) + yyElement->MarkY, OU ($5), OU ($6), OU ($7), OU ($8), $9, + $10, OldFlags($11)); + free ($9); + free ($10); + } + ; + +pin_1.6.3_format + /* x, y, thickness, drilling hole, name, number, flags */ + : T_PIN '(' measure measure measure measure STRING STRING INTEGER ')' + { + CreateNewPin(yyElement, OU ($3), OU ($4), OU ($5), 2*GROUNDPLANEFRAME, + OU ($5) + 2*MASKFRAME, OU ($6), $7, $8, OldFlags($9)); + free ($7); + free ($8); + } + ; + +pin_newformat + /* x, y, thickness, drilling hole, name, flags */ + : T_PIN '(' measure measure measure measure STRING INTEGER ')' + { + char p_number[8]; + + sprintf(p_number, "%d", pin_num++); + CreateNewPin(yyElement, OU ($3), OU ($4), OU ($5), 2*GROUNDPLANEFRAME, + OU ($5) + 2*MASKFRAME, OU ($6), $7, p_number, OldFlags($8)); + + free ($7); + } + ; + +pin_oldformat + /* old format: x, y, thickness, name, flags + * drilling hole is 40% of the diameter + */ + : T_PIN '(' measure measure measure STRING INTEGER ')' + { + Coord hole = OU ($5) * DEFAULT_DRILLINGHOLE; + char p_number[8]; + + /* make sure that there's enough copper left */ + if (OU ($5) - hole < MIN_PINORVIACOPPER && + OU ($5) > MIN_PINORVIACOPPER) + hole = OU ($5) - MIN_PINORVIACOPPER; + + sprintf(p_number, "%d", pin_num++); + CreateNewPin(yyElement, OU ($3), OU ($4), OU ($5), 2*GROUNDPLANEFRAME, + OU ($5) + 2*MASKFRAME, hole, $6, p_number, OldFlags($7)); + free ($6); + } + ; + +/* %start-doc pcbfile Pad + +@syntax +Pad [rX1 rY1 rX2 rY2 Thickness Clearance Mask "Name" "Number" SFlags] +Pad (rX1 rY1 rX2 rY2 Thickness Clearance Mask "Name" "Number" NFlags) +Pad (aX1 aY1 aX2 aY2 Thickness "Name" "Number" NFlags) +Pad (aX1 aY1 aX2 aY2 Thickness "Name" NFlags) +@end syntax + +@table @var +@item rX1 rY1 rX2 rY2 +Coordinates of the endpoints of the pad, relative to the element's +mark. Note that the copper extends beyond these coordinates by half +the thickness. To make a square or round pad, specify the same +coordinate twice. +@item aX1 aY1 aX2 aY2 +Same, but absolute coordinates of the endpoints of the pad. +@item Thickness +width of the pad. +@item Clearance +add to thickness to get clearance width. +@item Mask +width of solder mask opening. +@item Name +name of pin +@item Number +number of pin +@item SFlags +symbolic or numerical flags +@item NFlags +numerical flags only +@end table + +%end-doc */ + +pad_hi_format + /* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */ + : T_PAD '[' measure measure measure measure measure measure measure STRING STRING flags ']' + { + CreateNewPad(yyElement, NU ($3) + yyElement->MarkX, + NU ($4) + yyElement->MarkY, + NU ($5) + yyElement->MarkX, + NU ($6) + yyElement->MarkY, NU ($7), NU ($8), NU ($9), + $10, $11, $12); + free ($10); + free ($11); + } + ; + +pad_1.7_format + /* x1, y1, x2, y2, thickness, clearance, mask, name , pad number, flags */ + : T_PAD '(' measure measure measure measure measure measure measure STRING STRING INTEGER ')' + { + CreateNewPad(yyElement,OU ($3) + yyElement->MarkX, + OU ($4) + yyElement->MarkY, OU ($5) + yyElement->MarkX, + OU ($6) + yyElement->MarkY, OU ($7), OU ($8), OU ($9), + $10, $11, OldFlags($12)); + free ($10); + free ($11); + } + ; + +pad_newformat + /* x1, y1, x2, y2, thickness, name , pad number, flags */ + : T_PAD '(' measure measure measure measure measure STRING STRING INTEGER ')' + { + CreateNewPad(yyElement,OU ($3),OU ($4),OU ($5),OU ($6),OU ($7), 2*GROUNDPLANEFRAME, + OU ($7) + 2*MASKFRAME, $8, $9, OldFlags($10)); + free ($8); + free ($9); + } + ; + +pad + /* x1, y1, x2, y2, thickness, name and flags */ + : T_PAD '(' measure measure measure measure measure STRING INTEGER ')' + { + char p_number[8]; + + sprintf(p_number, "%d", pin_num++); + CreateNewPad(yyElement,OU ($3),OU ($4),OU ($5),OU ($6),OU ($7), 2*GROUNDPLANEFRAME, + OU ($7) + 2*MASKFRAME, $8,p_number, OldFlags($9)); + free ($8); + } + ; + +flags : INTEGER { $$ = OldFlags($1); } + | STRING { $$ = string_to_flags ($1, yyerror); free($1); } + ; + +symbols + : symbol + | symbols symbol + ; + +/* %start-doc pcbfile Symbol + +@syntax +Symbol [Char Delta] ( +Symbol (Char Delta) ( +@ @ @ @dots{} symbol lines @dots{} +) +@end syntax + +@table @var +@item Char +The character or numerical character value this symbol represents. +Characters must be in single quotes. +@item Delta +Additional space to allow after this character. +@end table + +%end-doc */ + +symbol : symbolhead symboldata ')' + +symbolhead : T_SYMBOL '[' symbolid measure ']' '(' + { + if ($3 <= 0 || $3 > MAX_FONTPOSITION) + { + yyerror("fontposition out of range"); + YYABORT; + } + Symbol = &yyFont->Symbol[$3]; + if (Symbol->Valid) + { + yyerror("symbol ID used twice"); + YYABORT; + } + Symbol->Valid = true; + Symbol->Delta = NU ($4); + } + | T_SYMBOL '(' symbolid measure ')' '(' + { + if ($3 <= 0 || $3 > MAX_FONTPOSITION) + { + yyerror("fontposition out of range"); + YYABORT; + } + Symbol = &yyFont->Symbol[$3]; + if (Symbol->Valid) + { + yyerror("symbol ID used twice"); + YYABORT; + } + Symbol->Valid = true; + Symbol->Delta = OU ($4); + } + ; + +symbolid + : INTEGER + | CHAR_CONST + ; + +symboldata + : /* empty */ + | symboldata symboldefinition + | symboldata hiressymbol + ; + +/* %start-doc pcbfile SymbolLine + +@syntax +SymbolLine [X1 Y1 X2 Y1 Thickness] +SymbolLine (X1 Y1 X2 Y1 Thickness) +@end syntax + +@table @var +@item X1 Y1 X2 Y2 +The endpoints of this line. +@item Thickness +The width of this line. +@end table + +%end-doc */ + +symboldefinition + /* x1, y1, x2, y2, thickness */ + : T_SYMBOLLINE '(' measure measure measure measure measure ')' + { + CreateNewLineInSymbol(Symbol, OU ($3), OU ($4), OU ($5), OU ($6), OU ($7)); + } + ; +hiressymbol + /* x1, y1, x2, y2, thickness */ + : T_SYMBOLLINE '[' measure measure measure measure measure ']' + { + CreateNewLineInSymbol(Symbol, NU ($3), NU ($4), NU ($5), NU ($6), NU ($7)); + } + ; + +/* %start-doc pcbfile Netlist + +@syntax +Netlist ( ) ( +@ @ @ @dots{} nets @dots{} +) +@end syntax + +%end-doc */ + +pcbnetlist : pcbnetdef + | + ; +pcbnetdef + /* net(...) net(...) ... */ + : T_NETLIST '(' ')' '(' + nets ')' + ; + +nets + : netdefs + | + ; + +netdefs + : net + | netdefs net + ; + + +/* %start-doc pcbfile Net + +@syntax +Net ("Name" "Style") ( +@ @ @ @dots{} connects @dots{} +) +@end syntax + +@table @var +@item Name +The name of this net. +@item Style +The routing style that should be used when autorouting this net. +@end table + +%end-doc */ + +net + /* name style pin pin ... */ + : T_NET '(' STRING STRING ')' '(' + { + Menu = CreateNewNet((LibraryTypePtr)&yyPCB->NetlistLib, $3, $4); + free ($3); + free ($4); + } + connections ')' + ; + +connections + : conndefs + | + ; + +conndefs + : conn + | conndefs conn + ; + +/* %start-doc pcbfile Connect + +@syntax +Connect ("PinPad") +@end syntax + +@table @var +@item PinPad +The name of a pin or pad which is included in this net. Pin and Pad +names are named by the refdes and pin name, like @code{"U14-7"} for +pin 7 of U14, or @code{"T4-E"} for pin E of T4. +@end table + +%end-doc */ + +conn + : T_CONN '(' STRING ')' + { + CreateNewConnection(Menu, $3); + free ($3); + } + ; + +/* %start-doc pcbfile Netlistpatch + +@syntax +NetListPatch ( ) ( +@ @ @ @dots{} netpatch @dots{} +) +@end syntax + +%end-doc */ + +pcbnetlistpatch : pcbnetpatchdef + | + ; +pcbnetpatchdef + /* net(...) net(...) ... */ + : T_NETLISTPATCH '(' ')' '(' + netpatches ')' + ; + +netpatches + : netpatchdefs + | + ; + +netpatchdefs + : netpatch + | netpatchdefs netpatch + ; + +/* %start-doc pcbfile NetPatch + +@syntax +op (arg1 arg2 ...) ( +@ @ @ @dots{} netlist patch directive @dots{} +) +@end syntax + +%end-doc */ + +netpatch + /* name style pin pin ... */ + : T_ADD_CONN '(' STRING STRING ')' { rats_patch_append(yyPCB, RATP_ADD_CONN, $3, $4, NULL); free($3); free($4); } + | T_DEL_CONN '(' STRING STRING ')' { rats_patch_append(yyPCB, RATP_DEL_CONN, $3, $4, NULL); free($3); free($4); } + | T_CHANGE_ATTRIB '(' STRING STRING STRING ')' { rats_patch_append(yyPCB, RATP_CHANGE_ATTRIB, $3, $4, $5); free($3); free($4); free($5); } + ; + + +/* %start-doc pcbfile Attribute + +@syntax +Attribute ("Name" "Value") +@end syntax + +Attributes allow boards and elements to have arbitrary data attached +to them, which is not directly used by PCB itself but may be of use by +other programs or users. + +@table @var +@item Name +The name of the attribute + +@item Value +The value of the attribute. Values are always stored as strings, even +if the value is interpreted as, for example, a number. + +@end table + +%end-doc */ + +attribute + : T_ATTRIBUTE '(' STRING STRING ')' + { + CreateNewAttribute (attr_list, $3, $4 ? $4 : (char *)""); + free ($3); + free ($4); + } + ; + +opt_string : STRING { $$ = $1; } + | /* empty */ { $$ = 0; } + ; + +number + : FLOATING { $$ = $1; } + | INTEGER { $$ = $1; } + ; + +measure + /* Default unit (no suffix) is cmil */ + : number { do_measure(&$$, $1, MIL_TO_COORD ($1) / 100.0, 0); } + | number T_UMIL { M ($$, $1, MIL_TO_COORD ($1) / 100000.0); } + | number T_CMIL { M ($$, $1, MIL_TO_COORD ($1) / 100.0); } + | number T_MIL { M ($$, $1, MIL_TO_COORD ($1)); } + | number T_IN { M ($$, $1, INCH_TO_COORD ($1)); } + | number T_NM { M ($$, $1, MM_TO_COORD ($1) / 1000000.0); } + | number T_UM { M ($$, $1, MM_TO_COORD ($1) / 1000.0); } + | number T_MM { M ($$, $1, MM_TO_COORD ($1)); } + | number T_M { M ($$, $1, MM_TO_COORD ($1) * 1000.0); } + | number T_KM { M ($$, $1, MM_TO_COORD ($1) * 1000000.0); } + ; + +%% + +/* --------------------------------------------------------------------------- + * error routine called by parser library + */ +int yyerror(const char * s) +{ + Message("ERROR parsing file '%s'\n" + " line: %i\n" + " description: '%s'\n", + yyfilename, yylineno, s); + return(0); +} + +int yywrap() +{ + return 1; +} + +static int +check_file_version (int ver) +{ + if ( ver > PCB_FILE_VERSION ) { + Message ("ERROR: The file you are attempting to load is in a format\n" + "which is too new for this version of pcb. To load this file\n" + "you need a version of pcb which is >= %d. If you are\n" + "using a version built from git source, the source date\n" + "must be >= %d. This copy of pcb can only read files\n" + "up to file version %d.\n", ver, ver, PCB_FILE_VERSION); + return 1; + } + + return 0; +} + +static void +do_measure (PLMeasure *m, Coord i, double d, int u) +{ + m->ival = i; + m->bval = round (d); + m->dval = d; + m->has_units = u; +} + +static int +integer_value (PLMeasure m) +{ + if (m.has_units) + yyerror("units ignored here"); + return m.ival; +} + +static Coord +old_units (PLMeasure m) +{ + if (m.has_units) + return m.bval; + return round (MIL_TO_COORD (m.ival)); +} + +static Coord +new_units (PLMeasure m) +{ + if (m.has_units) + return m.bval; + return round (MIL_TO_COORD (m.ival) / 100.0); +} Index: trunk/src_plugins/io_pcb/strflags.c =================================================================== --- trunk/src_plugins/io_pcb/strflags.c (nonexistent) +++ trunk/src_plugins/io_pcb/strflags.c (revision 1761) @@ -0,0 +1,603 @@ +/* $Id$ */ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 2005 DJ Delorie + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Contact addresses for paper mail and Email: + * DJ Delorie, 334 North Road, Deerfield NH 03037-1110, USA + * dj@delorie.com + * + */ + +#include "config.h" + +#include +#include +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif + +#include "globalconst.h" +#include "global.h" +#include "compat_misc.h" +#include "const.h" +#include "strflags.h" + + +RCSID("$Id$"); + +/* Because all the macros expect it, that's why. */ +typedef struct { + FlagType Flags; +} FlagHolder; + +/* Be careful to list more specific flags first, followed by general + * flags, when two flags use the same bit. For example, "onsolder" is + * for elements only, while "auto" is for everything else. They use + * the same bit, but onsolder is listed first so that elements will + * use it and not auto. + * + * Thermals are handled separately, as they're layer-selective. + */ + +typedef struct { + + /* This is the bit that we're setting. */ + int mask; + + /* The name used in the output file. */ + char *name; + int nlen; +#define N(x) x, sizeof(x)-1 + + /* If set, this entry won't be output unless the object type is one + of these. */ + int object_types; + +} FlagBitsType; + +static FlagBitsType object_flagbits[] = { + {PINFLAG, N("pin"), ALL_TYPES}, + {VIAFLAG, N("via"), ALL_TYPES}, + {FOUNDFLAG, N("found"), ALL_TYPES}, + {HOLEFLAG, N("hole"), PIN_TYPES}, + {RATFLAG, N("rat"), RATLINE_TYPE}, + {PININPOLYFLAG, N("pininpoly"), PIN_TYPES | PAD_TYPE}, + {CLEARPOLYFLAG, N("clearpoly"), POLYGON_TYPE}, + {HIDENAMEFLAG, N("hidename"), ELEMENT_TYPE}, + {SNAPOFFGRIDLINEFLAG, N("snapoffgridline"), ALL_TYPES}, + {HIGHLIGHTONPOINTFLAG, N("highlightonpoint"), ALL_TYPES}, + {DISPLAYNAMEFLAG, N("showname"), ELEMENT_TYPE}, + {CLEARLINEFLAG, N("clearline"), LINE_TYPE | ARC_TYPE | TEXT_TYPE}, + {SELECTEDFLAG, N("selected"), ALL_TYPES}, + {ONSOLDERFLAG, N("onsolder"), ELEMENT_TYPE | PAD_TYPE | TEXT_TYPE}, + {AUTOFLAG, N("auto"), ALL_TYPES}, + {SQUAREFLAG, N("square"), PIN_TYPES | PAD_TYPE}, + {RUBBERENDFLAG, N("rubberend"), LINE_TYPE | ARC_TYPE}, + {WARNFLAG, N("warn"), PIN_TYPES | PAD_TYPE}, + {USETHERMALFLAG, N("usetherm"), PIN_TYPES | LINE_TYPE | ARC_TYPE}, + {OCTAGONFLAG, N("octagon"), PIN_TYPES | PAD_TYPE}, + {DRCFLAG, N("drc"), ALL_TYPES}, + {LOCKFLAG, N("lock"), ALL_TYPES}, + {EDGE2FLAG, N("edge2"), ALL_TYPES}, + {FULLPOLYFLAG, N("fullpoly"), POLYGON_TYPE}, + {NOPASTEFLAG, N("nopaste"), PAD_TYPE}, + {NONETLISTFLAG, N("nonetlist"), ALL_TYPES} +}; + +static FlagBitsType pcb_flagbits[] = { + {SHOWNUMBERFLAG, N("shownumber"), 1}, + {LOCALREFFLAG, N("localref"), 1}, + {CHECKPLANESFLAG, N("checkplanes"), 1}, + {SHOWDRCFLAG, N("showdrc"), 1}, + {RUBBERBANDFLAG, N("rubberband"), 1}, + {DESCRIPTIONFLAG, N("description"), 1}, + {NAMEONPCBFLAG, N("nameonpcb"), 1}, + {AUTODRCFLAG, N("autodrc"), 1}, + {ALLDIRECTIONFLAG, N("alldirection"), 1}, + {SWAPSTARTDIRFLAG, N("swapstartdir"), 1}, + {UNIQUENAMEFLAG, N("uniquename"), 1}, + {CLEARNEWFLAG, N("clearnew"), 1}, + {NEWFULLPOLYFLAG, N("newfullpoly"), 1}, + {SNAPPINFLAG, N("snappin"), 1}, + {SHOWMASKFLAG, N("showmask"), 1}, + {THINDRAWFLAG, N("thindraw"), 1}, + {ORTHOMOVEFLAG, N("orthomove"), 1}, + {LIVEROUTEFLAG, N("liveroute"), 1}, + {THINDRAWPOLYFLAG, N("thindrawpoly"), 1}, + {LOCKNAMESFLAG, N("locknames"), 1}, + {ONLYNAMESFLAG, N("onlynames"), 1}, + {HIDENAMESFLAG, N("hidenames"), 1}, + {ENABLEMINCUTFLAG, N("enablemincut"), 1}, + {ENABLESTROKEFLAG, N("enablestroke"), 1} +}; + +#undef N + +/* + * This helper function maintains a small list of buffers which are + * used by flags_to_string(). Each buffer is allocated from the heap, + * but the caller must not free them (they get realloced when they're + * reused, but never completely freed). + */ + +static struct { + char *ptr; + int len; +} buffers[10]; +static int bufptr = 0; +static char *alloc_buf(int len) +{ +#define B buffers[bufptr] + len++; + bufptr = (bufptr + 1) % 10; + if (B.len < len) { + if (B.ptr) + B.ptr = (char *) realloc(B.ptr, len); + else + B.ptr = (char *) malloc(len); + B.len = len; + } + return B.ptr; +#undef B +} + +void uninit_strflags_buf(void) +{ + int n; + for(n = 0; n < 10; n++) { + if (buffers[n].ptr != NULL) { + free(buffers[n].ptr); + buffers[n].ptr = NULL; + } + } +} + +/* + * This set of routines manages a list of layer-specific flags. + * Callers should call grow_layer_list(0) to reset the list, and + * set_layer_list(layer,1) to set bits in the layer list. The results + * are stored in layers[], which has num_layers valid entries. + */ + +static char *layers = 0; +static int max_layers = 0, num_layers = 0; + +static void grow_layer_list(int num) +{ + if (layers == 0) { + layers = (char *) calloc(num > 0 ? num : 1, 1); + max_layers = num; + } + else if (num > max_layers) { + max_layers = num; + layers = (char *) realloc(layers, max_layers); + } + if (num > num_layers) + memset(layers + num_layers, 0, num - num_layers - 1); + num_layers = num; + return; +} + +void uninit_strflags_layerlist(void) +{ + if (layers != NULL) { + free(layers); + layers = NULL; + num_layers = max_layers = 0; + } +} + +static inline void set_layer_list(int layer, int v) +{ + if (layer >= num_layers) + grow_layer_list(layer + 1); + layers[layer] = v; +} + +/* + * These next two convert between layer lists and strings. + * parse_layer_list() is passed a pointer to a string, and parses a + * list of integer which reflect layers to be flagged. It returns a + * pointer to the first character following the list. The syntax of + * the list is a paren-surrounded, comma-separated list of integers + * and/or pairs of integers separated by a dash (like "(1,2,3-7)"). + * Spaces and other punctuation are not allowed. The results are + * stored in layers[] defined above. + * + * print_layer_list() does the opposite - it uses the flags set in + * layers[] to build a string that represents them, using the syntax + * above. + * + */ + +/* Returns a pointer to the first character past the list. */ +static const char *parse_layer_list(const char *bp, int (*error) (const char *)) +{ + const char *orig_bp = bp; + int l = 0, range = -1; + int value = 1; + + grow_layer_list(0); + while (*bp) { + if (*bp == '+') + value = 2; + else if (*bp == 'S') + value = 3; + else if (*bp == 'X') + value = 4; + else if (*bp == 't') + value = 5; + else if (*bp == ')' || *bp == ',' || *bp == '-') { + if (range == -1) + range = l; + while (range <= l) + set_layer_list(range++, value); + if (*bp == '-') + range = l; + else + range = -1; + value = 1; + l = 0; + } + + else if (isdigit((int) *bp)) + l = l * 10 + (*bp - '0'); + + else if (error) { + char *fmt = "Syntax error parsing layer list \"%.*s\" at %c"; + char *msg = alloc_buf(strlen(fmt) + strlen(orig_bp)); + sprintf(msg, fmt, bp - orig_bp + 5, orig_bp, *bp); + error(msg); + error = NULL; + } + + if (*bp == ')') + return bp + 1; + + bp++; + } + return bp; +} + +/* Number of character the value "i" requires when printed. */ +static int printed_int_length(int i, int j) +{ + int rv; + + if (i < 10) + return 1 + (j ? 1 : 0); + if (i < 100) + return 2 + (j ? 1 : 0); + + for (rv = 1; i >= 10; rv++) + i /= 10; + return rv + (j ? 1 : 0); +} + +/* Returns a pointer to an internal buffer which is overwritten with + each new call. */ +static char *print_layer_list() +{ + static char *buf = 0; + static int buflen = 0; + int len, i, j; + char *bp; + + len = 2; + for (i = 0; i < num_layers; i++) + if (layers[i]) + len += 1 + printed_int_length(i, layers[i]); + if (buflen < len) { + if (buf) + buf = (char *) realloc(buf, len); + else + buf = (char *) malloc(len); + buflen = len; + } + + bp = buf; + *bp++ = '('; + + for (i = 0; i < num_layers; i++) + if (layers[i]) { + /* 0 0 1 1 1 0 0 */ + /* i j */ + for (j = i + 1; j < num_layers && layers[j] == 1; j++); + if (j > i + 2) { + sprintf(bp, "%d-%d,", i, j - 1); + i = j - 1; + } + else + switch (layers[i]) { + case 1: + sprintf(bp, "%d,", i); + break; + case 2: + sprintf(bp, "%d+,", i); + break; + case 3: + sprintf(bp, "%dS,", i); + break; + case 4: + sprintf(bp, "%dX,", i); + break; + case 5: + default: + sprintf(bp, "%dt,", i); + break; + } + bp += strlen(bp); + } + bp[-1] = ')'; + *bp = 0; + return buf; +} + +/* + * Ok, now the two entry points to this file. The first, string_to_flags, + * is passed a string (usually from parse_y.y) and returns a "set of flags". + * In theory, this can be anything, but for now it's just an integer. Later + * it might be a structure, for example. + * + * Currently, there is no error handling :-P + */ + +static int error_ignore(const char *msg) +{ /* do nothing */ + return 0; +} + +static FlagType empty_flags; + +static FlagType +common_string_to_flags(const char *flagstring, int (*error) (const char *msg), FlagBitsType * flagbits, int n_flagbits) +{ + const char *fp, *ep; + int flen; + FlagHolder rv; + int i; + + rv.Flags = empty_flags; + + if (error == 0) + error = error_ignore; + + if (flagstring == NULL) + return empty_flags; + + fp = ep = flagstring; + + if (*fp == '"') + ep = ++fp; + + while (*ep && *ep != '"') { + int found = 0; + + for (ep = fp; *ep && *ep != ',' && *ep != '"' && *ep != '('; ep++); + flen = ep - fp; + if (*ep == '(') + ep = parse_layer_list(ep + 1, error); + + if (flen == 7 && memcmp(fp, "thermal", 7) == 0) { + for (i = 0; i < MAX_LAYER && i < num_layers; i++) + if (layers[i]) + ASSIGN_THERM(i, layers[i], &rv); + } + else if (flen == 5 && memcmp(fp, "shape", 5) == 0) { + rv.Flags.q = atoi(fp + 6); + } + else if (flen == 7 && memcmp(fp, "intconn", 7) == 0) { + rv.Flags.int_conn_grp = atoi(fp + 8); + } + else { + for (i = 0; i < n_flagbits; i++) + if (flagbits[i].nlen == flen && memcmp(flagbits[i].name, fp, flen) == 0) { + found = 1; + SET_FLAG(flagbits[i].mask, &rv); + break; + } + if (!found) { + const char *fmt = "Unknown flag: \"%.*s\" ignored"; + unknown_flag_t *u; + char *msg; + const char *s; + + /* include () */ + s = fp + flen; + if (*s == '(') { + while (*s != ')') { + flen++; + s++; + } + } + if (*s == ')') + flen++; + + msg = alloc_buf(strlen(fmt) + flen); + sprintf(msg, fmt, flen, fp); + error(msg); + + u = malloc(sizeof(unknown_flag_t)); + u->str = strndup(fp, flen); + u->next = NULL; + /* need to append, to keep order of flags */ + if (rv.Flags.unknowns != NULL) { + unknown_flag_t *n; + for (n = rv.Flags.unknowns; n->next != NULL; n = n->next); + n->next = u; + } + else + rv.Flags.unknowns = u; + } + } + fp = ep + 1; + } + return rv.Flags; +} + +FlagType string_to_flags(const char *flagstring, int (*error) (const char *msg)) +{ + return common_string_to_flags(flagstring, error, object_flagbits, ENTRIES(object_flagbits)); +} + +FlagType string_to_pcbflags(const char *flagstring, int (*error) (const char *msg)) +{ + return common_string_to_flags(flagstring, error, pcb_flagbits, ENTRIES(pcb_flagbits)); +} + + +/* + * Given a set of flags for a given type of object, return a string + * which reflects those flags. The only requirement is that this + * string be parseable by string_to_flags. + * + * Note that this function knows a little about what kinds of flags + * will be automatically set by parsing, so it won't (for example) + * include the "via" flag for VIA_TYPEs because it knows those get + * forcibly set when vias are parsed. + */ + +static char *common_flags_to_string(FlagType flags, int object_type, FlagBitsType * flagbits, int n_flagbits) +{ + int len; + int i; + FlagHolder fh, savef; + char *buf, *bp; + unknown_flag_t *u; + + fh.Flags = flags; + +#ifndef FLAG_TEST + switch (object_type) { + case VIA_TYPE: + CLEAR_FLAG(VIAFLAG, &fh); + break; + case RATLINE_TYPE: + CLEAR_FLAG(RATFLAG, &fh); + break; + case PIN_TYPE: + CLEAR_FLAG(PINFLAG, &fh); + break; + } +#endif + + savef = fh; + + len = 3; /* for "()\0" */ + + for (i = 0; i < n_flagbits; i++) + + if ((flagbits[i].object_types & object_type) + && (TEST_FLAG(flagbits[i].mask, &fh))) { + + len += flagbits[i].nlen + 1; + CLEAR_FLAG(flagbits[i].mask, &fh); + } + + if (TEST_ANY_THERMS(&fh)) { + len += sizeof("thermal()"); + for (i = 0; i < MAX_LAYER; i++) + if (TEST_THERM(i, &fh)) + len += printed_int_length(i, GET_THERM(i, &fh)) + 1; + } + + if (flags.q > 0) { + len += sizeof("shape(.)"); + if (flags.q > 9) + len += 2; + } + + if (flags.int_conn_grp > 0) { + len += sizeof("intconn(.)"); + if (flags.q > 9) + len++; + if (flags.q > 99) + len++; + } + + for (u = flags.unknowns; u != NULL; u = u->next) + len += strlen(u->str) + 1; + + bp = buf = alloc_buf(len + 2); + + *bp++ = '"'; + + fh = savef; + for (i = 0; i < n_flagbits; i++) + if (flagbits[i].object_types & object_type && (TEST_FLAG(flagbits[i].mask, &fh))) { + if (bp != buf + 1) + *bp++ = ','; + strcpy(bp, flagbits[i].name); + bp += flagbits[i].nlen; + CLEAR_FLAG(flagbits[i].mask, &fh); + } + + if (TEST_ANY_THERMS(&fh)) { + if (bp != buf + 1) + *bp++ = ','; + strcpy(bp, "thermal"); + bp += strlen("thermal"); + grow_layer_list(0); + for (i = 0; i < MAX_LAYER; i++) + if (TEST_THERM(i, &fh)) + set_layer_list(i, GET_THERM(i, &fh)); + strcpy(bp, print_layer_list()); + bp += strlen(bp); + } + + if (flags.q > 0) { + if (bp != buf + 1) + *bp++ = ','; + bp += sprintf(bp, "shape(%d)", flags.q); + } + + if (flags.int_conn_grp > 0) { + if (bp != buf + 1) + *bp++ = ','; + bp += sprintf(bp, "intconn(%d)", flags.int_conn_grp); + } + + for (u = flags.unknowns; u != NULL; u = u->next) { + int len; + len = strlen(u->str); + if (bp != buf + 1) + *bp++ = ','; + memcpy(bp, u->str, len); + bp += len; + } + + *bp++ = '"'; + *bp = 0; + return buf; +} + +char *flags_to_string(FlagType flags, int object_type) +{ + return common_flags_to_string(flags, object_type, object_flagbits, ENTRIES(object_flagbits)); +} + +char *pcbflags_to_string(FlagType flags) +{ + return common_flags_to_string(flags, ALL_TYPES, pcb_flagbits, ENTRIES(pcb_flagbits)); +} + Index: trunk/src_plugins/io_pcb/strflags.h =================================================================== --- trunk/src_plugins/io_pcb/strflags.h (nonexistent) +++ trunk/src_plugins/io_pcb/strflags.h (revision 1761) @@ -0,0 +1,52 @@ +/* $Id$ */ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 2005 DJ Delorie + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Contact addresses for paper mail and Email: + * DJ Delorie, 334 North Road, Deerfield NH 03037-1110, USA + * dj@delorie.com + * + */ + +#ifndef PCB_STRFLAGS_H +#define PCB_STRFLAGS_H + +/* The purpose of this interface is to make the file format able to + handle more than 32 flags, and to hide the internal details of + flags from the file format. */ + +/* When passed a string, parse it and return an appropriate set of + flags. Errors cause error() to be called with a suitable message; + if error is NULL, errors are ignored. */ +FlagType string_to_flags(const char *flagstring, int (*error) (const char *msg)); + +/* Given a set of flags for a given object type, return a string which + can be output to a file. The returned pointer must not be + freed. */ +char *flags_to_string(FlagType flags, int object_type); + +/* Same as above, but for pcb flags. */ +FlagType string_to_pcbflags(const char *flagstring, int (*error) (const char *msg)); +char *pcbflags_to_string(FlagType flags); + +void uninit_strflags_buf(void); +void uninit_strflags_layerlist(void); + +#endif Index: trunk/src_plugins/plugins_io.tmpasm =================================================================== --- trunk/src_plugins/plugins_io.tmpasm (revision 1760) +++ trunk/src_plugins/plugins_io.tmpasm (revision 1761) @@ -12,3 +12,4 @@ include {../src_plugins/hid_batch/Plug.tmpasm} include {../src_plugins/hid_gtk/Plug.tmpasm} include {../src_plugins/hid_lesstif/Plug.tmpasm} +include {../src_plugins/io_pcb/Plug.tmpasm}