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_ncsa_parse.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-20  |  29.6 KB  |  1,089 lines

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