home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / plug-ins / imagemap / imap_cern_parse.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-20  |  29.3 KB  |  1,085 lines

  1.  
  2. /*  A Bison parser, made from imap_cern.y
  3.     by GNU Bison version 1.28  */
  4.  
  5. #define YYBISON 1  /* Identify Bison output.  */
  6.  
  7. #define yyparse cern_parse
  8. #define yylex cern_lex
  9. #define yyerror cern_error
  10. #define yylval cern_lval
  11. #define yychar cern_char
  12. #define yydebug cern_debug
  13. #define yynerrs cern_nerrs
  14. #define    RECTANGLE    257
  15. #define    POLYGON    258
  16. #define    CIRCLE    259
  17. #define    DEFAULT    260
  18. #define    AUTHOR    261
  19. #define    DESCRIPTION    262
  20. #define    BEGIN_COMMENT    263
  21. #define    FLOAT    264
  22. #define    COMMENT    265
  23. #define    LINK    266
  24.  
  25. #line 1 "imap_cern.y"
  26.  
  27. /*
  28.  * This is a plug-in for the GIMP.
  29.  *
  30.  * Generates clickable image maps.
  31.  *
  32.  * Copyright (C) 1998-1999 Maurits Rijk  lpeek.mrijk@consunet.nl
  33.  *
  34.  * This program is free software; you can redistribute it and/or modify
  35.  * it under the terms of the GNU General Public License as published by
  36.  * the Free Software Foundation; either version 2 of the License, or
  37.  * (at your option) any later version.
  38.  *
  39.  * This program is distributed in the hope that it will be useful,
  40.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  41.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  42.  * GNU General Public License for more details.
  43.  *
  44.  * You should have received a copy of the GNU General Public License
  45.  * along with this program; if not, write to the Free Software
  46.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  47.  *
  48.  */
  49.  
  50.  
  51. #include <math.h>
  52.  
  53. #include "gtk/gtk.h"
  54.  
  55. #include "imap_circle.h"
  56. #include "imap_file.h"
  57. #include "imap_main.h"
  58. #include "imap_polygon.h"
  59. #include "imap_rectangle.h"
  60. #include "imap_string.h"
  61.  
  62. extern int cern_lex();
  63. extern int cern_restart();
  64. static void cern_error(char* s);
  65.  
  66. static Object_t *current_object;
  67.  
  68.  
  69. #line 45 "imap_cern.y"
  70. typedef union {
  71.    int val;
  72.    double value;
  73.    char id[256];
  74. } YYSTYPE;
  75. #include <stdio.h>
  76.  
  77. #ifndef __cplusplus
  78. #ifndef __STDC__
  79. #define const
  80. #endif
  81. #endif
  82.  
  83.  
  84.  
  85. #define    YYFINAL        51
  86. #define    YYFLAG        -32768
  87. #define    YYNTBASE    16
  88.  
  89. #define YYTRANSLATE(x) ((unsigned)(x) <= 266 ? yytranslate[x] : 30)
  90.  
  91. static const char yytranslate[] = {     0,
  92.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  93.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  94.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  95.      2,     2,     2,     2,     2,     2,     2,     2,     2,    13,
  96.     15,     2,     2,    14,     2,     2,     2,     2,     2,     2,
  97.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  98.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  99.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  100.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  101.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  102.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  103.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  104.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  105.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  106.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  107.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  108.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  109.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  110.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  111.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  112.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  113.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  114.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  115.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  116.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  117.      2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
  118.      7,     8,     9,    10,    11,    12
  119. };
  120.  
  121. #if YYDEBUG != 0
  122. static const short yyprhs[] = {     0,
  123.      0,     2,     3,     6,     8,    10,    12,    14,    16,    19,
  124.     32,    41,    42,    47,    48,    51,    57,    59,    61,    63,
  125.     66,    69
  126. };
  127.  
  128. static const short yyrhs[] = {    17,
  129.      0,     0,    17,    18,     0,    19,     0,    20,     0,    21,
  130.      0,    22,     0,    26,     0,     6,    12,     0,     3,    13,
  131.     10,    14,    10,    15,    13,    10,    14,    10,    15,    12,
  132.      0,     5,    13,    10,    14,    10,    15,    10,    12,     0,
  133.      0,     4,    23,    24,    12,     0,     0,    24,    25,     0,
  134.     13,    10,    14,    10,    15,     0,    28,     0,    29,     0,
  135.     27,     0,     9,    11,     0,     7,    11,     0,     8,    11,
  136.      0
  137. };
  138.  
  139. #endif
  140.  
  141. #if YYDEBUG != 0
  142. static const short yyrline[] = { 0,
  143.     58,    61,    62,    65,    66,    67,    68,    69,    72,    80,
  144.     92,   103,   103,   110,   111,   116,   125,   126,   127,   130,
  145.    135,   143
  146. };
  147. #endif
  148.  
  149.  
  150. #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
  151.  
  152. static const char * const yytname[] = {   "$","error","$undefined.","RECTANGLE",
  153. "POLYGON","CIRCLE","DEFAULT","AUTHOR","DESCRIPTION","BEGIN_COMMENT","FLOAT",
  154. "COMMENT","LINK","'('","','","')'","cern_file","area_list","area","default",
  155. "rectangle","circle","polygon","@1","coord_list","coord","comment_line","real_comment",
  156. "author_line","description_line", NULL
  157. };
  158. #endif
  159.  
  160. static const short yyr1[] = {     0,
  161.     16,    17,    17,    18,    18,    18,    18,    18,    19,    20,
  162.     21,    23,    22,    24,    24,    25,    26,    26,    26,    27,
  163.     28,    29
  164. };
  165.  
  166. static const short yyr2[] = {     0,
  167.      1,     0,     2,     1,     1,     1,     1,     1,     2,    12,
  168.      8,     0,     4,     0,     2,     5,     1,     1,     1,     2,
  169.      2,     2
  170. };
  171.  
  172. static const short yydefact[] = {     2,
  173.      1,     0,    12,     0,     0,     0,     0,     0,     3,     4,
  174.      5,     6,     7,     8,    19,    17,    18,     0,    14,     0,
  175.      9,    21,    22,    20,     0,     0,     0,     0,    13,     0,
  176.     15,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  177.      0,     0,    16,    11,     0,     0,     0,    10,     0,     0,
  178.      0
  179. };
  180.  
  181. static const short yydefgoto[] = {    49,
  182.      1,     9,    10,    11,    12,    13,    19,    26,    31,    14,
  183.     15,    16,    17
  184. };
  185.  
  186. static const short yypact[] = {-32768,
  187.     -3,    -4,-32768,    -2,     0,    -1,     2,     3,-32768,-32768,
  188. -32768,-32768,-32768,-32768,-32768,-32768,-32768,     5,-32768,     6,
  189. -32768,-32768,-32768,-32768,     4,    -5,     7,     9,-32768,    10,
  190. -32768,    12,     8,    11,    13,    14,    16,    19,    20,    17,
  191.     21,    22,-32768,-32768,    24,    23,    25,-32768,    31,    35,
  192. -32768
  193. };
  194.  
  195. static const short yypgoto[] = {-32768,
  196. -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  197. -32768,-32768,-32768
  198. };
  199.  
  200.  
  201. #define    YYLAST        38
  202.  
  203.  
  204. static const short yytable[] = {     2,
  205.      3,     4,     5,     6,     7,     8,    29,    30,    18,    22,
  206.     20,    21,    23,    24,    25,    27,     0,    28,    33,    34,
  207.     32,    35,    36,     0,    37,    40,    39,    38,    41,    42,
  208.     50,    43,    44,    46,    51,    45,    48,    47
  209. };
  210.  
  211. static const short yycheck[] = {     3,
  212.      4,     5,     6,     7,     8,     9,    12,    13,    13,    11,
  213.     13,    12,    11,    11,    10,    10,    -1,    14,    10,    10,
  214.     14,    10,    15,    -1,    14,    10,    13,    15,    10,    10,
  215.      0,    15,    12,    10,     0,    14,    12,    15
  216. };
  217. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  218. #line 3 "/usr/share/misc/bison.simple"
  219. /* This file comes from bison-1.28.  */
  220.  
  221. /* Skeleton output parser for bison,
  222.    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
  223.  
  224.    This program is free software; you can redistribute it and/or modify
  225.    it under the terms of the GNU General Public License as published by
  226.    the Free Software Foundation; either version 2, or (at your option)
  227.    any later version.
  228.  
  229.    This program is distributed in the hope that it will be useful,
  230.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  231.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  232.    GNU General Public License for more details.
  233.  
  234.    You should have received a copy of the GNU General Public License
  235.    along with this program; if not, write to the Free Software
  236.    Foundation, Inc., 59 Temple Place - Suite 330,
  237.    Boston, MA 02111-1307, USA.  */
  238.  
  239. /* As a special exception, when this file is copied by Bison into a
  240.    Bison output file, you may use that output file without restriction.
  241.    This special exception was added by the Free Software Foundation
  242.    in version 1.24 of Bison.  */
  243.  
  244. /* This is the parser code that is written into each bison parser
  245.   when the %semantic_parser declaration is not specified in the grammar.
  246.   It was written by Richard Stallman by simplifying the hairy parser
  247.   used when %semantic_parser is specified.  */
  248.  
  249. #ifndef YYSTACK_USE_ALLOCA
  250. #ifdef alloca
  251. #define YYSTACK_USE_ALLOCA
  252. #else /* alloca not defined */
  253. #ifdef __GNUC__
  254. #define YYSTACK_USE_ALLOCA
  255. #define alloca __builtin_alloca
  256. #else /* not GNU C.  */
  257. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
  258. #define YYSTACK_USE_ALLOCA
  259. #include <alloca.h>
  260. #else /* not sparc */
  261. /* We think this test detects Watcom and Microsoft C.  */
  262. /* This used to test MSDOS, but that is a bad idea
  263.    since that symbol is in the user namespace.  */
  264. #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
  265. #if 0 /* No need for malloc.h, which pollutes the namespace;
  266.      instead, just don't use alloca.  */
  267. #include <malloc.h>
  268. #endif
  269. #else /* not MSDOS, or __TURBOC__ */
  270. #if defined(_AIX)
  271. /* I don't know what this was needed for, but it pollutes the namespace.
  272.    So I turned it off.   rms, 2 May 1997.  */
  273. /* #include <malloc.h>  */
  274.  #pragma alloca
  275. #define YYSTACK_USE_ALLOCA
  276. #else /* not MSDOS, or __TURBOC__, or _AIX */
  277. #if 0
  278. #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
  279.          and on HPUX 10.  Eventually we can turn this on.  */
  280. #define YYSTACK_USE_ALLOCA
  281. #define alloca __builtin_alloca
  282. #endif /* __hpux */
  283. #endif
  284. #endif /* not _AIX */
  285. #endif /* not MSDOS, or __TURBOC__ */
  286. #endif /* not sparc */
  287. #endif /* not GNU C */
  288. #endif /* alloca not defined */
  289. #endif /* YYSTACK_USE_ALLOCA not defined */
  290.  
  291. #ifdef YYSTACK_USE_ALLOCA
  292. #define YYSTACK_ALLOC alloca
  293. #else
  294. #define YYSTACK_ALLOC malloc
  295. #endif
  296.  
  297. /* Note: there must be only one dollar sign in this file.
  298.    It is replaced by the list of actions, each action
  299.    as one case of the switch.  */
  300.  
  301. #define yyerrok        (yyerrstatus = 0)
  302. #define yyclearin    (yychar = YYEMPTY)
  303. #define YYEMPTY        -2
  304. #define YYEOF        0
  305. #define YYACCEPT    goto yyacceptlab
  306. #define YYABORT     goto yyabortlab
  307. #define YYERROR        goto yyerrlab1
  308. /* Like YYERROR except do call yyerror.
  309.    This remains here temporarily to ease the
  310.    transition to the new meaning of YYERROR, for GCC.
  311.    Once GCC version 2 has supplanted version 1, this can go.  */
  312. #define YYFAIL        goto yyerrlab
  313. #define YYRECOVERING()  (!!yyerrstatus)
  314. #define YYBACKUP(token, value) \
  315. do                                \
  316.   if (yychar == YYEMPTY && yylen == 1)                \
  317.     { yychar = (token), yylval = (value);            \
  318.       yychar1 = YYTRANSLATE (yychar);                \
  319.       YYPOPSTACK;                        \
  320.       goto yybackup;                        \
  321.     }                                \
  322.   else                                \
  323.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  324. while (0)
  325.  
  326. #define YYTERROR    1
  327. #define YYERRCODE    256
  328.  
  329. #ifndef YYPURE
  330. #define YYLEX        yylex()
  331. #endif
  332.  
  333. #ifdef YYPURE
  334. #ifdef YYLSP_NEEDED
  335. #ifdef YYLEX_PARAM
  336. #define YYLEX        yylex(&yylval, &yylloc, YYLEX_PARAM)
  337. #else
  338. #define YYLEX        yylex(&yylval, &yylloc)
  339. #endif
  340. #else /* not YYLSP_NEEDED */
  341. #ifdef YYLEX_PARAM
  342. #define YYLEX        yylex(&yylval, YYLEX_PARAM)
  343. #else
  344. #define YYLEX        yylex(&yylval)
  345. #endif
  346. #endif /* not YYLSP_NEEDED */
  347. #endif
  348.  
  349. /* If nonreentrant, generate the variables here */
  350.  
  351. #ifndef YYPURE
  352.  
  353. int    yychar;            /*  the lookahead symbol        */
  354. YYSTYPE    yylval;            /*  the semantic value of the        */
  355.                 /*  lookahead symbol            */
  356.  
  357. #ifdef YYLSP_NEEDED
  358. YYLTYPE yylloc;            /*  location data for the lookahead    */
  359.                 /*  symbol                */
  360. #endif
  361.  
  362. int yynerrs;            /*  number of parse errors so far       */
  363. #endif  /* not YYPURE */
  364.  
  365. #if YYDEBUG != 0
  366. int yydebug;            /*  nonzero means print parse trace    */
  367. /* Since this is uninitialized, it does not stop multiple parsers
  368.    from coexisting.  */
  369. #endif
  370.  
  371. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  372.  
  373. #ifndef    YYINITDEPTH
  374. #define YYINITDEPTH 200
  375. #endif
  376.  
  377. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  378.     (effective only if the built-in stack extension method is used).  */
  379.  
  380. #if YYMAXDEPTH == 0
  381. #undef YYMAXDEPTH
  382. #endif
  383.  
  384. #ifndef YYMAXDEPTH
  385. #define YYMAXDEPTH 10000
  386. #endif
  387.  
  388. /* Define __yy_memcpy.  Note that the size argument
  389.    should be passed with type unsigned int, because that is what the non-GCC
  390.    definitions require.  With GCC, __builtin_memcpy takes an arg
  391.    of type size_t, but it can handle unsigned int.  */
  392.  
  393. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  394. #define __yy_memcpy(TO,FROM,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  395. #else                /* not GNU C or C++ */
  396. #ifndef __cplusplus
  397.  
  398. /* This is the most reliable way to avoid incompatibilities
  399.    in available built-in functions on various systems.  */
  400. static void
  401. __yy_memcpy (to, from, count)
  402.      char *to;
  403.      char *from;
  404.      unsigned int count;
  405. {
  406.   register char *f = from;
  407.   register char *t = to;
  408.   register int i = count;
  409.  
  410.   while (i-- > 0)
  411.     *t++ = *f++;
  412. }
  413.  
  414. #else /* __cplusplus */
  415.  
  416. /* This is the most reliable way to avoid incompatibilities
  417.    in available built-in functions on various systems.  */
  418. static void
  419. __yy_memcpy (char *to, char *from, unsigned int count)
  420. {
  421.   register char *t = to;
  422.   register char *f = from;
  423.   register int i = count;
  424.  
  425.   while (i-- > 0)
  426.     *t++ = *f++;
  427. }
  428.  
  429. #endif
  430. #endif
  431.  
  432. #line 217 "/usr/share/misc/bison.simple"
  433.  
  434. /* The user can define YYPARSE_PARAM as the name of an argument to be passed
  435.    into yyparse.  The argument should have type void *.
  436.    It should actually point to an object.
  437.    Grammar actions can access the variable by casting it
  438.    to the proper pointer type.  */
  439.  
  440. #ifdef YYPARSE_PARAM
  441. #ifdef __cplusplus
  442. #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
  443. #define YYPARSE_PARAM_DECL
  444. #else /* not __cplusplus */
  445. #define YYPARSE_PARAM_ARG YYPARSE_PARAM
  446. #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
  447. #endif /* not __cplusplus */
  448. #else /* not YYPARSE_PARAM */
  449. #define YYPARSE_PARAM_ARG
  450. #define YYPARSE_PARAM_DECL
  451. #endif /* not YYPARSE_PARAM */
  452.  
  453. /* Prevent warning if -Wstrict-prototypes.  */
  454. #ifdef __GNUC__
  455. #ifdef YYPARSE_PARAM
  456. int yyparse (void *);
  457. #else
  458. int yyparse (void);
  459. #endif
  460. #endif
  461.  
  462. int
  463. yyparse(YYPARSE_PARAM_ARG)
  464.      YYPARSE_PARAM_DECL
  465. {
  466.   register int yystate;
  467.   register int yyn;
  468.   register short *yyssp;
  469.   register YYSTYPE *yyvsp;
  470.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  471.   int yychar1 = 0;        /*  lookahead token as an internal (translated) token number */
  472.  
  473.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  474.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  475.  
  476.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  477.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  478.  
  479. #ifdef YYLSP_NEEDED
  480.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  481.   YYLTYPE *yyls = yylsa;
  482.   YYLTYPE *yylsp;
  483.  
  484. #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  485. #else
  486. #define YYPOPSTACK   (yyvsp--, yyssp--)
  487. #endif
  488.  
  489.   int yystacksize = YYINITDEPTH;
  490.   int yyfree_stacks = 0;
  491.  
  492. #ifdef YYPURE
  493.   int yychar;
  494.   YYSTYPE yylval;
  495.   int yynerrs;
  496. #ifdef YYLSP_NEEDED
  497.   YYLTYPE yylloc;
  498. #endif
  499. #endif
  500.  
  501.   YYSTYPE yyval;        /*  the variable used to return        */
  502.                 /*  semantic values from the action    */
  503.                 /*  routines                */
  504.  
  505.   int yylen;
  506.  
  507. #if YYDEBUG != 0
  508.   if (yydebug)
  509.     fprintf(stderr, "Starting parse\n");
  510. #endif
  511.  
  512.   yystate = 0;
  513.   yyerrstatus = 0;
  514.   yynerrs = 0;
  515.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  516.  
  517.   /* Initialize stack pointers.
  518.      Waste one element of value and location stack
  519.      so that they stay on the same level as the state stack.
  520.      The wasted elements are never initialized.  */
  521.  
  522.   yyssp = yyss - 1;
  523.   yyvsp = yyvs;
  524. #ifdef YYLSP_NEEDED
  525.   yylsp = yyls;
  526. #endif
  527.  
  528. /* Push a new state, which is found in  yystate  .  */
  529. /* In all cases, when you get here, the value and location stacks
  530.    have just been pushed. so pushing a state here evens the stacks.  */
  531. yynewstate:
  532.  
  533.   *++yyssp = yystate;
  534.  
  535.   if (yyssp >= yyss + yystacksize - 1)
  536.     {
  537.       /* Give user a chance to reallocate the stack */
  538.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  539.       YYSTYPE *yyvs1 = yyvs;
  540.       short *yyss1 = yyss;
  541. #ifdef YYLSP_NEEDED
  542.       YYLTYPE *yyls1 = yyls;
  543. #endif
  544.  
  545.       /* Get the current used size of the three stacks, in elements.  */
  546.       int size = yyssp - yyss + 1;
  547.  
  548. #ifdef yyoverflow
  549.       /* Each stack pointer address is followed by the size of
  550.      the data in use in that stack, in bytes.  */
  551. #ifdef YYLSP_NEEDED
  552.       /* This used to be a conditional around just the two extra args,
  553.      but that might be undefined if yyoverflow is a macro.  */
  554.       yyoverflow("parser stack overflow",
  555.          &yyss1, size * sizeof (*yyssp),
  556.          &yyvs1, size * sizeof (*yyvsp),
  557.          &yyls1, size * sizeof (*yylsp),
  558.          &yystacksize);
  559. #else
  560.       yyoverflow("parser stack overflow",
  561.          &yyss1, size * sizeof (*yyssp),
  562.          &yyvs1, size * sizeof (*yyvsp),
  563.          &yystacksize);
  564. #endif
  565.  
  566.       yyss = yyss1; yyvs = yyvs1;
  567. #ifdef YYLSP_NEEDED
  568.       yyls = yyls1;
  569. #endif
  570. #else /* no yyoverflow */
  571.       /* Extend the stack our own way.  */
  572.       if (yystacksize >= YYMAXDEPTH)
  573.     {
  574.       yyerror("parser stack overflow");
  575.       if (yyfree_stacks)
  576.         {
  577.           free (yyss);
  578.           free (yyvs);
  579. #ifdef YYLSP_NEEDED
  580.           free (yyls);
  581. #endif
  582.         }
  583.       return 2;
  584.     }
  585.       yystacksize *= 2;
  586.       if (yystacksize > YYMAXDEPTH)
  587.     yystacksize = YYMAXDEPTH;
  588. #ifndef YYSTACK_USE_ALLOCA
  589.       yyfree_stacks = 1;
  590. #endif
  591.       yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
  592.       __yy_memcpy ((char *)yyss, (char *)yyss1,
  593.            size * (unsigned int) sizeof (*yyssp));
  594.       yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
  595.       __yy_memcpy ((char *)yyvs, (char *)yyvs1,
  596.            size * (unsigned int) sizeof (*yyvsp));
  597. #ifdef YYLSP_NEEDED
  598.       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
  599.       __yy_memcpy ((char *)yyls, (char *)yyls1,
  600.            size * (unsigned int) sizeof (*yylsp));
  601. #endif
  602. #endif /* no yyoverflow */
  603.  
  604.       yyssp = yyss + size - 1;
  605.       yyvsp = yyvs + size - 1;
  606. #ifdef YYLSP_NEEDED
  607.       yylsp = yyls + size - 1;
  608. #endif
  609.  
  610. #if YYDEBUG != 0
  611.       if (yydebug)
  612.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  613. #endif
  614.  
  615.       if (yyssp >= yyss + yystacksize - 1)
  616.     YYABORT;
  617.     }
  618.  
  619. #if YYDEBUG != 0
  620.   if (yydebug)
  621.     fprintf(stderr, "Entering state %d\n", yystate);
  622. #endif
  623.  
  624.   goto yybackup;
  625.  yybackup:
  626.  
  627. /* Do appropriate processing given the current state.  */
  628. /* Read a lookahead token if we need one and don't already have one.  */
  629. /* yyresume: */
  630.  
  631.   /* First try to decide what to do without reference to lookahead token.  */
  632.  
  633.   yyn = yypact[yystate];
  634.   if (yyn == YYFLAG)
  635.     goto yydefault;
  636.  
  637.   /* Not known => get a lookahead token if don't already have one.  */
  638.  
  639.   /* yychar is either YYEMPTY or YYEOF
  640.      or a valid token in external form.  */
  641.  
  642.   if (yychar == YYEMPTY)
  643.     {
  644. #if YYDEBUG != 0
  645.       if (yydebug)
  646.     fprintf(stderr, "Reading a token: ");
  647. #endif
  648.       yychar = YYLEX;
  649.     }
  650.  
  651.   /* Convert token to internal form (in yychar1) for indexing tables with */
  652.  
  653.   if (yychar <= 0)        /* This means end of input. */
  654.     {
  655.       yychar1 = 0;
  656.       yychar = YYEOF;        /* Don't call YYLEX any more */
  657.  
  658. #if YYDEBUG != 0
  659.       if (yydebug)
  660.     fprintf(stderr, "Now at end of input.\n");
  661. #endif
  662.     }
  663.   else
  664.     {
  665.       yychar1 = YYTRANSLATE(yychar);
  666.  
  667. #if YYDEBUG != 0
  668.       if (yydebug)
  669.     {
  670.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  671.       /* Give the individual parser a way to print the precise meaning
  672.          of a token, for further debugging info.  */
  673. #ifdef YYPRINT
  674.       YYPRINT (stderr, yychar, yylval);
  675. #endif
  676.       fprintf (stderr, ")\n");
  677.     }
  678. #endif
  679.     }
  680.  
  681.   yyn += yychar1;
  682.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  683.     goto yydefault;
  684.  
  685.   yyn = yytable[yyn];
  686.  
  687.   /* yyn is what to do for this token type in this state.
  688.      Negative => reduce, -yyn is rule number.
  689.      Positive => shift, yyn is new state.
  690.        New state is final state => don't bother to shift,
  691.        just return success.
  692.      0, or most negative number => error.  */
  693.  
  694.   if (yyn < 0)
  695.     {
  696.       if (yyn == YYFLAG)
  697.     goto yyerrlab;
  698.       yyn = -yyn;
  699.       goto yyreduce;
  700.     }
  701.   else if (yyn == 0)
  702.     goto yyerrlab;
  703.  
  704.   if (yyn == YYFINAL)
  705.     YYACCEPT;
  706.  
  707.   /* Shift the lookahead token.  */
  708.  
  709. #if YYDEBUG != 0
  710.   if (yydebug)
  711.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  712. #endif
  713.  
  714.   /* Discard the token being shifted unless it is eof.  */
  715.   if (yychar != YYEOF)
  716.     yychar = YYEMPTY;
  717.  
  718.   *++yyvsp = yylval;
  719. #ifdef YYLSP_NEEDED
  720.   *++yylsp = yylloc;
  721. #endif
  722.  
  723.   /* count tokens shifted since error; after three, turn off error status.  */
  724.   if (yyerrstatus) yyerrstatus--;
  725.  
  726.   yystate = yyn;
  727.   goto yynewstate;
  728.  
  729. /* Do the default action for the current state.  */
  730. yydefault:
  731.  
  732.   yyn = yydefact[yystate];
  733.   if (yyn == 0)
  734.     goto yyerrlab;
  735.  
  736. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  737. yyreduce:
  738.   yylen = yyr2[yyn];
  739.   if (yylen > 0)
  740.     yyval = yyvsp[1-yylen]; /* implement default value of the action */
  741.  
  742. #if YYDEBUG != 0
  743.   if (yydebug)
  744.     {
  745.       int i;
  746.  
  747.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  748.            yyn, yyrline[yyn]);
  749.  
  750.       /* Print the symbols being reduced, and their result.  */
  751.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  752.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  753.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  754.     }
  755. #endif
  756.  
  757.  
  758.   switch (yyn) {
  759.  
  760. case 9:
  761. #line 73 "imap_cern.y"
  762. {
  763.            MapInfo_t *info = get_map_info();
  764.            g_strreplace(&info->default_url, yyvsp[0].id);
  765.         ;
  766.     break;}
  767. case 10:
  768. #line 81 "imap_cern.y"
  769. {
  770.            gint x = (gint) yyvsp[-9].value;
  771.            gint y = (gint) yyvsp[-7].value;
  772.            gint width = (gint) fabs(yyvsp[-4].value - x);
  773.            gint height = (gint) fabs(yyvsp[-2].value - y);
  774.            current_object = create_rectangle(x, y, width, height);
  775.            object_set_url(current_object, yyvsp[0].id);
  776.            add_shape(current_object);
  777.         ;
  778.     break;}
  779. case 11:
  780. #line 93 "imap_cern.y"
  781. {
  782.            gint x = (gint) yyvsp[-5].value;
  783.            gint y = (gint) yyvsp[-3].value;
  784.            gint r = (gint) yyvsp[-1].value;
  785.            current_object = create_circle(x, y, r);
  786.            object_set_url(current_object, yyvsp[0].id);
  787.            add_shape(current_object);
  788.         ;
  789.     break;}
  790. case 12:
  791. #line 103 "imap_cern.y"
  792. {current_object = create_polygon(NULL);;
  793.     break;}
  794. case 13:
  795. #line 104 "imap_cern.y"
  796. {
  797.            object_set_url(current_object, yyvsp[0].id);
  798.            add_shape(current_object);
  799.         ;
  800.     break;}
  801. case 15:
  802. #line 112 "imap_cern.y"
  803. {
  804.         ;
  805.     break;}
  806. case 16:
  807. #line 117 "imap_cern.y"
  808. {
  809.            Polygon_t *polygon = ObjectToPolygon(current_object);
  810.            GdkPoint *point = new_point((gint) yyvsp[-3].value, (gint) yyvsp[-1].value);
  811.            polygon->points = g_list_append(polygon->points, 
  812.                            (gpointer) point);
  813.         ;
  814.     break;}
  815. case 20:
  816. #line 131 "imap_cern.y"
  817. {
  818.         ;
  819.     break;}
  820. case 21:
  821. #line 136 "imap_cern.y"
  822. {
  823.            MapInfo_t *info = get_map_info();
  824.            g_strreplace(&info->author, yyvsp[0].id);
  825.  
  826.         ;
  827.     break;}
  828. case 22:
  829. #line 144 "imap_cern.y"
  830. {
  831.            MapInfo_t *info = get_map_info();
  832.            gchar *description;
  833.  
  834.            description = g_strconcat(info->description, yyvsp[0].id, "\n", 
  835.                          NULL);
  836.            g_strreplace(&info->description, description);
  837.         ;
  838.     break;}
  839. }
  840.    /* the action file gets copied in in place of this dollarsign */
  841. #line 543 "/usr/share/misc/bison.simple"
  842.  
  843.   yyvsp -= yylen;
  844.   yyssp -= yylen;
  845. #ifdef YYLSP_NEEDED
  846.   yylsp -= yylen;
  847. #endif
  848.  
  849. #if YYDEBUG != 0
  850.   if (yydebug)
  851.     {
  852.       short *ssp1 = yyss - 1;
  853.       fprintf (stderr, "state stack now");
  854.       while (ssp1 != yyssp)
  855.     fprintf (stderr, " %d", *++ssp1);
  856.       fprintf (stderr, "\n");
  857.     }
  858. #endif
  859.  
  860.   *++yyvsp = yyval;
  861.  
  862. #ifdef YYLSP_NEEDED
  863.   yylsp++;
  864.   if (yylen == 0)
  865.     {
  866.       yylsp->first_line = yylloc.first_line;
  867.       yylsp->first_column = yylloc.first_column;
  868.       yylsp->last_line = (yylsp-1)->last_line;
  869.       yylsp->last_column = (yylsp-1)->last_column;
  870.       yylsp->text = 0;
  871.     }
  872.   else
  873.     {
  874.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  875.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  876.     }
  877. #endif
  878.  
  879.   /* Now "shift" the result of the reduction.
  880.      Determine what state that goes to,
  881.      based on the state we popped back to
  882.      and the rule number reduced by.  */
  883.  
  884.   yyn = yyr1[yyn];
  885.  
  886.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  887.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  888.     yystate = yytable[yystate];
  889.   else
  890.     yystate = yydefgoto[yyn - YYNTBASE];
  891.  
  892.   goto yynewstate;
  893.  
  894. yyerrlab:   /* here on detecting error */
  895.  
  896.   if (! yyerrstatus)
  897.     /* If not already recovering from an error, report this error.  */
  898.     {
  899.       ++yynerrs;
  900.  
  901. #ifdef YYERROR_VERBOSE
  902.       yyn = yypact[yystate];
  903.  
  904.       if (yyn > YYFLAG && yyn < YYLAST)
  905.     {
  906.       int size = 0;
  907.       char *msg;
  908.       int x, count;
  909.  
  910.       count = 0;
  911.       /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
  912.       for (x = (yyn < 0 ? -yyn : 0);
  913.            x < (sizeof(yytname) / sizeof(char *)); x++)
  914.         if (yycheck[x + yyn] == x)
  915.           size += strlen(yytname[x]) + 15, count++;
  916.       msg = (char *) malloc(size + 15);
  917.       if (msg != 0)
  918.         {
  919.           strcpy(msg, "parse error");
  920.  
  921.           if (count < 5)
  922.         {
  923.           count = 0;
  924.           for (x = (yyn < 0 ? -yyn : 0);
  925.                x < (sizeof(yytname) / sizeof(char *)); x++)
  926.             if (yycheck[x + yyn] == x)
  927.               {
  928.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  929.             strcat(msg, yytname[x]);
  930.             strcat(msg, "'");
  931.             count++;
  932.               }
  933.         }
  934.           yyerror(msg);
  935.           free(msg);
  936.         }
  937.       else
  938.         yyerror ("parse error; also virtual memory exceeded");
  939.     }
  940.       else
  941. #endif /* YYERROR_VERBOSE */
  942.     yyerror("parse error");
  943.     }
  944.  
  945.   goto yyerrlab1;
  946. yyerrlab1:   /* here on error raised explicitly by an action */
  947.  
  948.   if (yyerrstatus == 3)
  949.     {
  950.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  951.  
  952.       /* return failure if at end of input */
  953.       if (yychar == YYEOF)
  954.     YYABORT;
  955.  
  956. #if YYDEBUG != 0
  957.       if (yydebug)
  958.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  959. #endif
  960.  
  961.       yychar = YYEMPTY;
  962.     }
  963.  
  964.   /* Else will try to reuse lookahead token
  965.      after shifting the error token.  */
  966.  
  967.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  968.  
  969.   goto yyerrhandle;
  970.  
  971. yyerrdefault:  /* current state does not do anything special for the error token. */
  972.  
  973. #if 0
  974.   /* This is wrong; only states that explicitly want error tokens
  975.      should shift them.  */
  976.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  977.   if (yyn) goto yydefault;
  978. #endif
  979.  
  980. yyerrpop:   /* pop the current state because it cannot handle the error token */
  981.  
  982.   if (yyssp == yyss) YYABORT;
  983.   yyvsp--;
  984.   yystate = *--yyssp;
  985. #ifdef YYLSP_NEEDED
  986.   yylsp--;
  987. #endif
  988.  
  989. #if YYDEBUG != 0
  990.   if (yydebug)
  991.     {
  992.       short *ssp1 = yyss - 1;
  993.       fprintf (stderr, "Error: state stack now");
  994.       while (ssp1 != yyssp)
  995.     fprintf (stderr, " %d", *++ssp1);
  996.       fprintf (stderr, "\n");
  997.     }
  998. #endif
  999.  
  1000. yyerrhandle:
  1001.  
  1002.   yyn = yypact[yystate];
  1003.   if (yyn == YYFLAG)
  1004.     goto yyerrdefault;
  1005.  
  1006.   yyn += YYTERROR;
  1007.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1008.     goto yyerrdefault;
  1009.  
  1010.   yyn = yytable[yyn];
  1011.   if (yyn < 0)
  1012.     {
  1013.       if (yyn == YYFLAG)
  1014.     goto yyerrpop;
  1015.       yyn = -yyn;
  1016.       goto yyreduce;
  1017.     }
  1018.   else if (yyn == 0)
  1019.     goto yyerrpop;
  1020.  
  1021.   if (yyn == YYFINAL)
  1022.     YYACCEPT;
  1023.  
  1024. #if YYDEBUG != 0
  1025.   if (yydebug)
  1026.     fprintf(stderr, "Shifting error token, ");
  1027. #endif
  1028.  
  1029.   *++yyvsp = yylval;
  1030. #ifdef YYLSP_NEEDED
  1031.   *++yylsp = yylloc;
  1032. #endif
  1033.  
  1034.   yystate = yyn;
  1035.   goto yynewstate;
  1036.  
  1037.  yyacceptlab:
  1038.   /* YYACCEPT comes here.  */
  1039.   if (yyfree_stacks)
  1040.     {
  1041.       free (yyss);
  1042.       free (yyvs);
  1043. #ifdef YYLSP_NEEDED
  1044.       free (yyls);
  1045. #endif
  1046.     }
  1047.   return 0;
  1048.  
  1049.  yyabortlab:
  1050.   /* YYABORT comes here.  */
  1051.   if (yyfree_stacks)
  1052.     {
  1053.       free (yyss);
  1054.       free (yyvs);
  1055. #ifdef YYLSP_NEEDED
  1056.       free (yyls);
  1057. #endif
  1058.     }
  1059.   return 1;
  1060. }
  1061. #line 155 "imap_cern.y"
  1062.  
  1063.  
  1064. static void 
  1065. cern_error(char* s)
  1066. {
  1067.    extern FILE *cern_in;
  1068.    cern_restart(cern_in);
  1069. }
  1070.  
  1071. gboolean
  1072. load_cern(const char* filename)
  1073. {
  1074.    gboolean status;
  1075.    extern FILE *cern_in;
  1076.    cern_in = fopen(filename, "r");
  1077.    if (cern_in) {
  1078.       status = !cern_parse();
  1079.       fclose(cern_in);
  1080.    } else {
  1081.       status = FALSE;
  1082.    }
  1083.    return status;
  1084. }
  1085.