~ubuntu-branches/ubuntu/hoary/gimp/hoary

1 by Sebastien Bacher
Import upstream version 2.2.2
1
/* A Bison parser, made from imap_cern.y
2
   by GNU bison 1.35.  */
3
4
#define YYBISON 1  /* Identify Bison output.  */
5
6
#define yyparse cern_parse
7
#define yylex cern_lex
8
#define yyerror cern_error
9
#define yylval cern_lval
10
#define yychar cern_char
11
#define yydebug cern_debug
12
#define yynerrs cern_nerrs
13
# define	RECTANGLE	257
14
# define	POLYGON	258
15
# define	CIRCLE	259
16
# define	DEFAULT	260
17
# define	AUTHOR	261
18
# define	DESCRIPTION	262
19
# define	BEGIN_COMMENT	263
20
# define	FLOAT	264
21
# define	COMMENT	265
22
# define	LINK	266
23
24
#line 1 "imap_cern.y"
25
26
/*
27
 * This is a plug-in for the GIMP.
28
 *
29
 * Generates clickable image maps.
30
 *
31
 * Copyright (C) 1998-1999 Maurits Rijk  lpeek.mrijk@consunet.nl
32
 *
33
 * This program is free software; you can redistribute it and/or modify
34
 * it under the terms of the GNU General Public License as published by
35
 * the Free Software Foundation; either version 2 of the License, or
36
 * (at your option) any later version.
37
 *
38
 * This program is distributed in the hope that it will be useful,
39
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
40
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
41
 * GNU General Public License for more details.
42
 *
43
 * You should have received a copy of the GNU General Public License
44
 * along with this program; if not, write to the Free Software
45
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
46
 *
47
 */
48
49
50
#include <math.h>
51
52
#include <gtk/gtk.h>
53
54
#include "imap_circle.h"
55
#include "imap_file.h"
56
#include "imap_main.h"
57
#include "imap_polygon.h"
58
#include "imap_rectangle.h"
59
#include "imap_string.h"
60
61
extern int cern_lex();
62
extern int cern_restart();
63
static void cern_error(char* s);
64
65
static Object_t *current_object;
66
67
68
#line 45 "imap_cern.y"
69
#ifndef YYSTYPE
70
typedef union {
71
   int val;
72
   double value;
73
   char id[256];
74
} yystype;
75
# define YYSTYPE yystype
76
# define YYSTYPE_IS_TRIVIAL 1
77
#endif
78
#ifndef YYDEBUG
79
# define YYDEBUG 0
80
#endif
81
82
83
84
#define	YYFINAL		51
85
#define	YYFLAG		-32768
86
#define	YYNTBASE	16
87
88
/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
89
#define YYTRANSLATE(x) ((unsigned)(x) <= 266 ? yytranslate[x] : 30)
90
91
/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
92
static const char yytranslate[] =
93
{
94
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
95
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
96
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
97
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
98
      13,    15,     2,     2,    14,     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,     2,     2,     2,     2,     2,
118
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
119
       2,     2,     2,     2,     2,     2,     1,     3,     4,     5,
120
       6,     7,     8,     9,    10,    11,    12
121
};
122
123
#if YYDEBUG
124
static const short yyprhs[] =
125
{
126
       0,     0,     2,     3,     6,     8,    10,    12,    14,    16,
127
      19,    32,    41,    42,    47,    48,    51,    57,    59,    61,
128
      63,    66,    69
129
};
130
static const short yyrhs[] =
131
{
132
      17,     0,     0,    17,    18,     0,    19,     0,    20,     0,
133
      21,     0,    22,     0,    26,     0,     6,    12,     0,     3,
134
      13,    10,    14,    10,    15,    13,    10,    14,    10,    15,
135
      12,     0,     5,    13,    10,    14,    10,    15,    10,    12,
136
       0,     0,     4,    23,    24,    12,     0,     0,    24,    25,
137
       0,    13,    10,    14,    10,    15,     0,    28,     0,    29,
138
       0,    27,     0,     9,    11,     0,     7,    11,     0,     8,
139
      11,     0
140
};
141
142
#endif
143
144
#if YYDEBUG
145
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
146
static const short yyrline[] =
147
{
148
       0,    58,    61,    62,    65,    66,    67,    68,    69,    72,
149
      80,    92,   103,   103,   110,   111,   116,   125,   126,   127,
150
     130,   135,   143
151
};
152
#endif
153
154
155
#if (YYDEBUG) || defined YYERROR_VERBOSE
156
157
/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
158
static const char *const yytname[] =
159
{
160
  "$", "error", "$undefined.", "RECTANGLE", "POLYGON", "CIRCLE", "DEFAULT", 
161
  "AUTHOR", "DESCRIPTION", "BEGIN_COMMENT", "FLOAT", "COMMENT", "LINK", 
162
  "'('", "','", "')'", "cern_file", "area_list", "area", "default", 
163
  "rectangle", "circle", "polygon", "@1", "coord_list", "coord", 
164
  "comment_line", "real_comment", "author_line", "description_line", 0
165
};
166
#endif
167
168
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
169
static const short yyr1[] =
170
{
171
       0,    16,    17,    17,    18,    18,    18,    18,    18,    19,
172
      20,    21,    23,    22,    24,    24,    25,    26,    26,    26,
173
      27,    28,    29
174
};
175
176
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
177
static const short yyr2[] =
178
{
179
       0,     1,     0,     2,     1,     1,     1,     1,     1,     2,
180
      12,     8,     0,     4,     0,     2,     5,     1,     1,     1,
181
       2,     2,     2
182
};
183
184
/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
185
   doesn't specify something else to do.  Zero means the default is an
186
   error. */
187
static const short yydefact[] =
188
{
189
       2,     1,     0,    12,     0,     0,     0,     0,     0,     3,
190
       4,     5,     6,     7,     8,    19,    17,    18,     0,    14,
191
       0,     9,    21,    22,    20,     0,     0,     0,     0,    13,
192
       0,    15,     0,     0,     0,     0,     0,     0,     0,     0,
193
       0,     0,     0,    16,    11,     0,     0,     0,    10,     0,
194
       0,     0
195
};
196
197
static const short yydefgoto[] =
198
{
199
      49,     1,     9,    10,    11,    12,    13,    19,    26,    31,
200
      14,    15,    16,    17
201
};
202
203
static const short yypact[] =
204
{
205
  -32768,    -3,    -4,-32768,    -2,     0,    -1,     2,     3,-32768,
206
  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,     5,-32768,
207
       6,-32768,-32768,-32768,-32768,     4,    -5,     7,     9,-32768,
208
      10,-32768,    12,     8,    11,    13,    14,    16,    19,    20,
209
      17,    21,    22,-32768,-32768,    24,    23,    25,-32768,    31,
210
      35,-32768
211
};
212
213
static const short yypgoto[] =
214
{
215
  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
216
  -32768,-32768,-32768,-32768
217
};
218
219
220
#define	YYLAST		38
221
222
223
static const short yytable[] =
224
{
225
       2,     3,     4,     5,     6,     7,     8,    29,    30,    18,
226
      22,    20,    21,    23,    24,    25,    27,     0,    28,    33,
227
      34,    32,    35,    36,     0,    37,    40,    39,    38,    41,
228
      42,    50,    43,    44,    46,    51,    45,    48,    47
229
};
230
231
static const short yycheck[] =
232
{
233
       3,     4,     5,     6,     7,     8,     9,    12,    13,    13,
234
      11,    13,    12,    11,    11,    10,    10,    -1,    14,    10,
235
      10,    14,    10,    15,    -1,    14,    10,    13,    15,    10,
236
      10,     0,    15,    12,    10,     0,    14,    12,    15
237
};
238
/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
239
#line 3 "/usr/share/bison/bison.simple"
240
241
/* Skeleton output parser for bison,
242
243
   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
244
   Foundation, Inc.
245
246
   This program is free software; you can redistribute it and/or modify
247
   it under the terms of the GNU General Public License as published by
248
   the Free Software Foundation; either version 2, or (at your option)
249
   any later version.
250
251
   This program is distributed in the hope that it will be useful,
252
   but WITHOUT ANY WARRANTY; without even the implied warranty of
253
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
254
   GNU General Public License for more details.
255
256
   You should have received a copy of the GNU General Public License
257
   along with this program; if not, write to the Free Software
258
   Foundation, Inc., 59 Temple Place - Suite 330,
259
   Boston, MA 02111-1307, USA.  */
260
261
/* As a special exception, when this file is copied by Bison into a
262
   Bison output file, you may use that output file without restriction.
263
   This special exception was added by the Free Software Foundation
264
   in version 1.24 of Bison.  */
265
266
/* This is the parser code that is written into each bison parser when
267
   the %semantic_parser declaration is not specified in the grammar.
268
   It was written by Richard Stallman by simplifying the hairy parser
269
   used when %semantic_parser is specified.  */
270
271
/* All symbols defined below should begin with yy or YY, to avoid
272
   infringing on user name space.  This should be done even for local
273
   variables, as they might otherwise be expanded by user macros.
274
   There are some unavoidable exceptions within include files to
275
   define necessary library symbols; they are noted "INFRINGES ON
276
   USER NAME SPACE" below.  */
277
278
#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
279
280
/* The parser invokes alloca or malloc; define the necessary symbols.  */
281
282
# if YYSTACK_USE_ALLOCA
283
#  define YYSTACK_ALLOC alloca
284
# else
285
#  ifndef YYSTACK_USE_ALLOCA
286
#   if defined (alloca) || defined (_ALLOCA_H)
287
#    define YYSTACK_ALLOC alloca
288
#   else
289
#    ifdef __GNUC__
290
#     define YYSTACK_ALLOC __builtin_alloca
291
#    endif
292
#   endif
293
#  endif
294
# endif
295
296
# ifdef YYSTACK_ALLOC
297
   /* Pacify GCC's `empty if-body' warning. */
298
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
299
# else
300
#  if defined (__STDC__) || defined (__cplusplus)
301
#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
302
#   define YYSIZE_T size_t
303
#  endif
304
#  define YYSTACK_ALLOC malloc
305
#  define YYSTACK_FREE free
306
# endif
307
#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
308
309
310
#if (! defined (yyoverflow) \
311
     && (! defined (__cplusplus) \
312
	 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
313
314
/* A type that is properly aligned for any stack member.  */
315
union yyalloc
316
{
317
  short yyss;
318
  YYSTYPE yyvs;
319
# if YYLSP_NEEDED
320
  YYLTYPE yyls;
321
# endif
322
};
323
324
/* The size of the maximum gap between one aligned stack and the next.  */
325
# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
326
327
/* The size of an array large to enough to hold all stacks, each with
328
   N elements.  */
329
# if YYLSP_NEEDED
330
#  define YYSTACK_BYTES(N) \
331
     ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE))	\
332
      + 2 * YYSTACK_GAP_MAX)
333
# else
334
#  define YYSTACK_BYTES(N) \
335
     ((N) * (sizeof (short) + sizeof (YYSTYPE))				\
336
      + YYSTACK_GAP_MAX)
337
# endif
338
339
/* Copy COUNT objects from FROM to TO.  The source and destination do
340
   not overlap.  */
341
# ifndef YYCOPY
342
#  if 1 < __GNUC__
343
#   define YYCOPY(To, From, Count) \
344
      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
345
#  else
346
#   define YYCOPY(To, From, Count)		\
347
      do					\
348
	{					\
349
	  register YYSIZE_T yyi;		\
350
	  for (yyi = 0; yyi < (Count); yyi++)	\
351
	    (To)[yyi] = (From)[yyi];		\
352
	}					\
353
      while (0)
354
#  endif
355
# endif
356
357
/* Relocate STACK from its old location to the new one.  The
358
   local variables YYSIZE and YYSTACKSIZE give the old and new number of
359
   elements in the stack, and YYPTR gives the new location of the
360
   stack.  Advance YYPTR to a properly aligned location for the next
361
   stack.  */
362
# define YYSTACK_RELOCATE(Stack)					\
363
    do									\
364
      {									\
365
	YYSIZE_T yynewbytes;						\
366
	YYCOPY (&yyptr->Stack, Stack, yysize);				\
367
	Stack = &yyptr->Stack;						\
368
	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX;	\
369
	yyptr += yynewbytes / sizeof (*yyptr);				\
370
      }									\
371
    while (0)
372
373
#endif
374
375
376
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
377
# define YYSIZE_T __SIZE_TYPE__
378
#endif
379
#if ! defined (YYSIZE_T) && defined (size_t)
380
# define YYSIZE_T size_t
381
#endif
382
#if ! defined (YYSIZE_T)
383
# if defined (__STDC__) || defined (__cplusplus)
384
#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
385
#  define YYSIZE_T size_t
386
# endif
387
#endif
388
#if ! defined (YYSIZE_T)
389
# define YYSIZE_T unsigned int
390
#endif
391
392
#define yyerrok		(yyerrstatus = 0)
393
#define yyclearin	(yychar = YYEMPTY)
394
#define YYEMPTY		-2
395
#define YYEOF		0
396
#define YYACCEPT	goto yyacceptlab
397
#define YYABORT 	goto yyabortlab
398
#define YYERROR		goto yyerrlab1
399
/* Like YYERROR except do call yyerror.  This remains here temporarily
400
   to ease the transition to the new meaning of YYERROR, for GCC.
401
   Once GCC version 2 has supplanted version 1, this can go.  */
402
#define YYFAIL		goto yyerrlab
403
#define YYRECOVERING()  (!!yyerrstatus)
404
#define YYBACKUP(Token, Value)					\
405
do								\
406
  if (yychar == YYEMPTY && yylen == 1)				\
407
    {								\
408
      yychar = (Token);						\
409
      yylval = (Value);						\
410
      yychar1 = YYTRANSLATE (yychar);				\
411
      YYPOPSTACK;						\
412
      goto yybackup;						\
413
    }								\
414
  else								\
415
    { 								\
416
      yyerror ("syntax error: cannot back up");			\
417
      YYERROR;							\
418
    }								\
419
while (0)
420
421
#define YYTERROR	1
422
#define YYERRCODE	256
423
424
425
/* YYLLOC_DEFAULT -- Compute the default location (before the actions
426
   are run).
427
428
   When YYLLOC_DEFAULT is run, CURRENT is set the location of the
429
   first token.  By default, to implement support for ranges, extend
430
   its range to the last symbol.  */
431
432
#ifndef YYLLOC_DEFAULT
433
# define YYLLOC_DEFAULT(Current, Rhs, N)       	\
434
   Current.last_line   = Rhs[N].last_line;	\
435
   Current.last_column = Rhs[N].last_column;
436
#endif
437
438
439
/* YYLEX -- calling `yylex' with the right arguments.  */
440
441
#if YYPURE
442
# if YYLSP_NEEDED
443
#  ifdef YYLEX_PARAM
444
#   define YYLEX		yylex (&yylval, &yylloc, YYLEX_PARAM)
445
#  else
446
#   define YYLEX		yylex (&yylval, &yylloc)
447
#  endif
448
# else /* !YYLSP_NEEDED */
449
#  ifdef YYLEX_PARAM
450
#   define YYLEX		yylex (&yylval, YYLEX_PARAM)
451
#  else
452
#   define YYLEX		yylex (&yylval)
453
#  endif
454
# endif /* !YYLSP_NEEDED */
455
#else /* !YYPURE */
456
# define YYLEX			yylex ()
457
#endif /* !YYPURE */
458
459
460
/* Enable debugging if requested.  */
461
#if YYDEBUG
462
463
# ifndef YYFPRINTF
464
#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
465
#  define YYFPRINTF fprintf
466
# endif
467
468
# define YYDPRINTF(Args)			\
469
do {						\
470
  if (yydebug)					\
471
    YYFPRINTF Args;				\
472
} while (0)
473
/* Nonzero means print parse trace.  It is left uninitialized so that
474
   multiple parsers can coexist.  */
475
int yydebug;
476
#else /* !YYDEBUG */
477
# define YYDPRINTF(Args)
478
#endif /* !YYDEBUG */
479
480
/* YYINITDEPTH -- initial size of the parser's stacks.  */
481
#ifndef	YYINITDEPTH
482
# define YYINITDEPTH 200
483
#endif
484
485
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
486
   if the built-in stack extension method is used).
487
488
   Do not make this value too large; the results are undefined if
489
   SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
490
   evaluated with infinite-precision integer arithmetic.  */
491
492
#if YYMAXDEPTH == 0
493
# undef YYMAXDEPTH
494
#endif
495
496
#ifndef YYMAXDEPTH
497
# define YYMAXDEPTH 10000
498
#endif
499

500
#ifdef YYERROR_VERBOSE
501
502
# ifndef yystrlen
503
#  if defined (__GLIBC__) && defined (_STRING_H)
504
#   define yystrlen strlen
505
#  else
506
/* Return the length of YYSTR.  */
507
static YYSIZE_T
508
#   if defined (__STDC__) || defined (__cplusplus)
509
yystrlen (const char *yystr)
510
#   else
511
yystrlen (yystr)
512
     const char *yystr;
513
#   endif
514
{
515
  register const char *yys = yystr;
516
517
  while (*yys++ != '\0')
518
    continue;
519
520
  return yys - yystr - 1;
521
}
522
#  endif
523
# endif
524
525
# ifndef yystpcpy
526
#  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
527
#   define yystpcpy stpcpy
528
#  else
529
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
530
   YYDEST.  */
531
static char *
532
#   if defined (__STDC__) || defined (__cplusplus)
533
yystpcpy (char *yydest, const char *yysrc)
534
#   else
535
yystpcpy (yydest, yysrc)
536
     char *yydest;
537
     const char *yysrc;
538
#   endif
539
{
540
  register char *yyd = yydest;
541
  register const char *yys = yysrc;
542
543
  while ((*yyd++ = *yys++) != '\0')
544
    continue;
545
546
  return yyd - 1;
547
}
548
#  endif
549
# endif
550
#endif
551

552
#line 315 "/usr/share/bison/bison.simple"
553
554
555
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
556
   into yyparse.  The argument should have type void *.
557
   It should actually point to an object.
558
   Grammar actions can access the variable by casting it
559
   to the proper pointer type.  */
560
561
#ifdef YYPARSE_PARAM
562
# if defined (__STDC__) || defined (__cplusplus)
563
#  define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
564
#  define YYPARSE_PARAM_DECL
565
# else
566
#  define YYPARSE_PARAM_ARG YYPARSE_PARAM
567
#  define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
568
# endif
569
#else /* !YYPARSE_PARAM */
570
# define YYPARSE_PARAM_ARG
571
# define YYPARSE_PARAM_DECL
572
#endif /* !YYPARSE_PARAM */
573
574
/* Prevent warning if -Wstrict-prototypes.  */
575
#ifdef __GNUC__
576
# ifdef YYPARSE_PARAM
577
int yyparse (void *);
578
# else
579
int yyparse (void);
580
# endif
581
#endif
582
583
/* YY_DECL_VARIABLES -- depending whether we use a pure parser,
584
   variables are global, or local to YYPARSE.  */
585
586
#define YY_DECL_NON_LSP_VARIABLES			\
587
/* The lookahead symbol.  */				\
588
int yychar;						\
589
							\
590
/* The semantic value of the lookahead symbol. */	\
591
YYSTYPE yylval;						\
592
							\
593
/* Number of parse errors so far.  */			\
594
int yynerrs;
595
596
#if YYLSP_NEEDED
597
# define YY_DECL_VARIABLES			\
598
YY_DECL_NON_LSP_VARIABLES			\
599
						\
600
/* Location data for the lookahead symbol.  */	\
601
YYLTYPE yylloc;
602
#else
603
# define YY_DECL_VARIABLES			\
604
YY_DECL_NON_LSP_VARIABLES
605
#endif
606
607
608
/* If nonreentrant, generate the variables here. */
609
610
#if !YYPURE
611
YY_DECL_VARIABLES
612
#endif  /* !YYPURE */
613
614
int
615
yyparse (YYPARSE_PARAM_ARG)
616
     YYPARSE_PARAM_DECL
617
{
618
  /* If reentrant, generate the variables here. */
619
#if YYPURE
620
  YY_DECL_VARIABLES
621
#endif  /* !YYPURE */
622
623
  register int yystate;
624
  register int yyn;
625
  int yyresult;
626
  /* Number of tokens to shift before error messages enabled.  */
627
  int yyerrstatus;
628
  /* Lookahead token as an internal (translated) token number.  */
629
  int yychar1 = 0;
630
631
  /* Three stacks and their tools:
632
     `yyss': related to states,
633
     `yyvs': related to semantic values,
634
     `yyls': related to locations.
635
636
     Refer to the stacks thru separate pointers, to allow yyoverflow
637
     to reallocate them elsewhere.  */
638
639
  /* The state stack. */
640
  short	yyssa[YYINITDEPTH];
641
  short *yyss = yyssa;
642
  register short *yyssp;
643
644
  /* The semantic value stack.  */
645
  YYSTYPE yyvsa[YYINITDEPTH];
646
  YYSTYPE *yyvs = yyvsa;
647
  register YYSTYPE *yyvsp;
648
649
#if YYLSP_NEEDED
650
  /* The location stack.  */
651
  YYLTYPE yylsa[YYINITDEPTH];
652
  YYLTYPE *yyls = yylsa;
653
  YYLTYPE *yylsp;
654
#endif
655
656
#if YYLSP_NEEDED
657
# define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
658
#else
659
# define YYPOPSTACK   (yyvsp--, yyssp--)
660
#endif
661
662
  YYSIZE_T yystacksize = YYINITDEPTH;
663
664
665
  /* The variables used to return semantic value and location from the
666
     action routines.  */
667
  YYSTYPE yyval;
668
#if YYLSP_NEEDED
669
  YYLTYPE yyloc;
670
#endif
671
672
  /* When reducing, the number of symbols on the RHS of the reduced
673
     rule. */
674
  int yylen;
675
676
  YYDPRINTF ((stderr, "Starting parse\n"));
677
678
  yystate = 0;
679
  yyerrstatus = 0;
680
  yynerrs = 0;
681
  yychar = YYEMPTY;		/* Cause a token to be read.  */
682
683
  /* Initialize stack pointers.
684
     Waste one element of value and location stack
685
     so that they stay on the same level as the state stack.
686
     The wasted elements are never initialized.  */
687
688
  yyssp = yyss;
689
  yyvsp = yyvs;
690
#if YYLSP_NEEDED
691
  yylsp = yyls;
692
#endif
693
  goto yysetstate;
694
695
/*------------------------------------------------------------.
696
| yynewstate -- Push a new state, which is found in yystate.  |
697
`------------------------------------------------------------*/
698
 yynewstate:
699
  /* In all cases, when you get here, the value and location stacks
700
     have just been pushed. so pushing a state here evens the stacks.
701
     */
702
  yyssp++;
703
704
 yysetstate:
705
  *yyssp = yystate;
706
707
  if (yyssp >= yyss + yystacksize - 1)
708
    {
709
      /* Get the current used size of the three stacks, in elements.  */
710
      YYSIZE_T yysize = yyssp - yyss + 1;
711
712
#ifdef yyoverflow
713
      {
714
	/* Give user a chance to reallocate the stack. Use copies of
715
	   these so that the &'s don't force the real ones into
716
	   memory.  */
717
	YYSTYPE *yyvs1 = yyvs;
718
	short *yyss1 = yyss;
719
720
	/* Each stack pointer address is followed by the size of the
721
	   data in use in that stack, in bytes.  */
722
# if YYLSP_NEEDED
723
	YYLTYPE *yyls1 = yyls;
724
	/* This used to be a conditional around just the two extra args,
725
	   but that might be undefined if yyoverflow is a macro.  */
726
	yyoverflow ("parser stack overflow",
727
		    &yyss1, yysize * sizeof (*yyssp),
728
		    &yyvs1, yysize * sizeof (*yyvsp),
729
		    &yyls1, yysize * sizeof (*yylsp),
730
		    &yystacksize);
731
	yyls = yyls1;
732
# else
733
	yyoverflow ("parser stack overflow",
734
		    &yyss1, yysize * sizeof (*yyssp),
735
		    &yyvs1, yysize * sizeof (*yyvsp),
736
		    &yystacksize);
737
# endif
738
	yyss = yyss1;
739
	yyvs = yyvs1;
740
      }
741
#else /* no yyoverflow */
742
# ifndef YYSTACK_RELOCATE
743
      goto yyoverflowlab;
744
# else
745
      /* Extend the stack our own way.  */
746
      if (yystacksize >= YYMAXDEPTH)
747
	goto yyoverflowlab;
748
      yystacksize *= 2;
749
      if (yystacksize > YYMAXDEPTH)
750
	yystacksize = YYMAXDEPTH;
751
752
      {
753
	short *yyss1 = yyss;
754
	union yyalloc *yyptr =
755
	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
756
	if (! yyptr)
757
	  goto yyoverflowlab;
758
	YYSTACK_RELOCATE (yyss);
759
	YYSTACK_RELOCATE (yyvs);
760
# if YYLSP_NEEDED
761
	YYSTACK_RELOCATE (yyls);
762
# endif
763
# undef YYSTACK_RELOCATE
764
	if (yyss1 != yyssa)
765
	  YYSTACK_FREE (yyss1);
766
      }
767
# endif
768
#endif /* no yyoverflow */
769
770
      yyssp = yyss + yysize - 1;
771
      yyvsp = yyvs + yysize - 1;
772
#if YYLSP_NEEDED
773
      yylsp = yyls + yysize - 1;
774
#endif
775
776
      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
777
		  (unsigned long int) yystacksize));
778
779
      if (yyssp >= yyss + yystacksize - 1)
780
	YYABORT;
781
    }
782
783
  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
784
785
  goto yybackup;
786
787
788
/*-----------.
789
| yybackup.  |
790
`-----------*/
791
yybackup:
792
793
/* Do appropriate processing given the current state.  */
794
/* Read a lookahead token if we need one and don't already have one.  */
795
/* yyresume: */
796
797
  /* First try to decide what to do without reference to lookahead token.  */
798
799
  yyn = yypact[yystate];
800
  if (yyn == YYFLAG)
801
    goto yydefault;
802
803
  /* Not known => get a lookahead token if don't already have one.  */
804
805
  /* yychar is either YYEMPTY or YYEOF
806
     or a valid token in external form.  */
807
808
  if (yychar == YYEMPTY)
809
    {
810
      YYDPRINTF ((stderr, "Reading a token: "));
811
      yychar = YYLEX;
812
    }
813
814
  /* Convert token to internal form (in yychar1) for indexing tables with */
815
816
  if (yychar <= 0)		/* This means end of input. */
817
    {
818
      yychar1 = 0;
819
      yychar = YYEOF;		/* Don't call YYLEX any more */
820
821
      YYDPRINTF ((stderr, "Now at end of input.\n"));
822
    }
823
  else
824
    {
825
      yychar1 = YYTRANSLATE (yychar);
826
827
#if YYDEBUG
828
     /* We have to keep this `#if YYDEBUG', since we use variables
829
	which are defined only if `YYDEBUG' is set.  */
830
      if (yydebug)
831
	{
832
	  YYFPRINTF (stderr, "Next token is %d (%s",
833
		     yychar, yytname[yychar1]);
834
	  /* Give the individual parser a way to print the precise
835
	     meaning of a token, for further debugging info.  */
836
# ifdef YYPRINT
837
	  YYPRINT (stderr, yychar, yylval);
838
# endif
839
	  YYFPRINTF (stderr, ")\n");
840
	}
841
#endif
842
    }
843
844
  yyn += yychar1;
845
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
846
    goto yydefault;
847
848
  yyn = yytable[yyn];
849
850
  /* yyn is what to do for this token type in this state.
851
     Negative => reduce, -yyn is rule number.
852
     Positive => shift, yyn is new state.
853
       New state is final state => don't bother to shift,
854
       just return success.
855
     0, or most negative number => error.  */
856
857
  if (yyn < 0)
858
    {
859
      if (yyn == YYFLAG)
860
	goto yyerrlab;
861
      yyn = -yyn;
862
      goto yyreduce;
863
    }
864
  else if (yyn == 0)
865
    goto yyerrlab;
866
867
  if (yyn == YYFINAL)
868
    YYACCEPT;
869
870
  /* Shift the lookahead token.  */
871
  YYDPRINTF ((stderr, "Shifting token %d (%s), ",
872
	      yychar, yytname[yychar1]));
873
874
  /* Discard the token being shifted unless it is eof.  */
875
  if (yychar != YYEOF)
876
    yychar = YYEMPTY;
877
878
  *++yyvsp = yylval;
879
#if YYLSP_NEEDED
880
  *++yylsp = yylloc;
881
#endif
882
883
  /* Count tokens shifted since error; after three, turn off error
884
     status.  */
885
  if (yyerrstatus)
886
    yyerrstatus--;
887
888
  yystate = yyn;
889
  goto yynewstate;
890
891
892
/*-----------------------------------------------------------.
893
| yydefault -- do the default action for the current state.  |
894
`-----------------------------------------------------------*/
895
yydefault:
896
  yyn = yydefact[yystate];
897
  if (yyn == 0)
898
    goto yyerrlab;
899
  goto yyreduce;
900
901
902
/*-----------------------------.
903
| yyreduce -- Do a reduction.  |
904
`-----------------------------*/
905
yyreduce:
906
  /* yyn is the number of a rule to reduce with.  */
907
  yylen = yyr2[yyn];
908
909
  /* If YYLEN is nonzero, implement the default value of the action:
910
     `$$ = $1'.
911
912
     Otherwise, the following line sets YYVAL to the semantic value of
913
     the lookahead token.  This behavior is undocumented and Bison
914
     users should not rely upon it.  Assigning to YYVAL
915
     unconditionally makes the parser a bit smaller, and it avoids a
916
     GCC warning that YYVAL may be used uninitialized.  */
917
  yyval = yyvsp[1-yylen];
918
919
#if YYLSP_NEEDED
920
  /* Similarly for the default location.  Let the user run additional
921
     commands if for instance locations are ranges.  */
922
  yyloc = yylsp[1-yylen];
923
  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
924
#endif
925
926
#if YYDEBUG
927
  /* We have to keep this `#if YYDEBUG', since we use variables which
928
     are defined only if `YYDEBUG' is set.  */
929
  if (yydebug)
930
    {
931
      int yyi;
932
933
      YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
934
		 yyn, yyrline[yyn]);
935
936
      /* Print the symbols being reduced, and their result.  */
937
      for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
938
	YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
939
      YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
940
    }
941
#endif
942
943
  switch (yyn) {
944
945
case 9:
946
#line 73 "imap_cern.y"
947
{
948
		   MapInfo_t *info = get_map_info();
949
		   g_strreplace(&info->default_url, yyvsp[0].id);
950
		}
951
    break;
952
case 10:
953
#line 81 "imap_cern.y"
954
{
955
		   gint x = (gint) yyvsp[-9].value;
956
		   gint y = (gint) yyvsp[-7].value;
957
		   gint width = (gint) fabs(yyvsp[-4].value - x);
958
		   gint height = (gint) fabs(yyvsp[-2].value - y);
959
		   current_object = create_rectangle(x, y, width, height);
960
		   object_set_url(current_object, yyvsp[0].id);
961
		   add_shape(current_object);
962
		}
963
    break;
964
case 11:
965
#line 93 "imap_cern.y"
966
{
967
		   gint x = (gint) yyvsp[-5].value;
968
		   gint y = (gint) yyvsp[-3].value;
969
		   gint r = (gint) yyvsp[-1].value;
970
		   current_object = create_circle(x, y, r);
971
		   object_set_url(current_object, yyvsp[0].id);
972
		   add_shape(current_object);
973
		}
974
    break;
975
case 12:
976
#line 103 "imap_cern.y"
977
{current_object = create_polygon(NULL);}
978
    break;
979
case 13:
980
#line 104 "imap_cern.y"
981
{
982
		   object_set_url(current_object, yyvsp[0].id);
983
		   add_shape(current_object);
984
		}
985
    break;
986
case 15:
987
#line 112 "imap_cern.y"
988
{
989
		}
990
    break;
991
case 16:
992
#line 117 "imap_cern.y"
993
{
994
		   Polygon_t *polygon = ObjectToPolygon(current_object);
995
		   GdkPoint *point = new_point((gint) yyvsp[-3].value, (gint) yyvsp[-1].value);
996
		   polygon->points = g_list_append(polygon->points, 
997
						   (gpointer) point);
998
		}
999
    break;
1000
case 20:
1001
#line 131 "imap_cern.y"
1002
{
1003
		}
1004
    break;
1005
case 21:
1006
#line 136 "imap_cern.y"
1007
{
1008
		   MapInfo_t *info = get_map_info();
1009
		   g_strreplace(&info->author, yyvsp[0].id);
1010
1011
		}
1012
    break;
1013
case 22:
1014
#line 144 "imap_cern.y"
1015
{
1016
		   MapInfo_t *info = get_map_info();
1017
		   gchar *description;
1018
1019
		   description = g_strconcat(info->description, yyvsp[0].id, "\n", 
1020
					     NULL);
1021
		   g_strreplace(&info->description, description);
1022
		}
1023
    break;
1024
}
1025
1026
#line 705 "/usr/share/bison/bison.simple"
1027
1028

1029
  yyvsp -= yylen;
1030
  yyssp -= yylen;
1031
#if YYLSP_NEEDED
1032
  yylsp -= yylen;
1033
#endif
1034
1035
#if YYDEBUG
1036
  if (yydebug)
1037
    {
1038
      short *yyssp1 = yyss - 1;
1039
      YYFPRINTF (stderr, "state stack now");
1040
      while (yyssp1 != yyssp)
1041
	YYFPRINTF (stderr, " %d", *++yyssp1);
1042
      YYFPRINTF (stderr, "\n");
1043
    }
1044
#endif
1045
1046
  *++yyvsp = yyval;
1047
#if YYLSP_NEEDED
1048
  *++yylsp = yyloc;
1049
#endif
1050
1051
  /* Now `shift' the result of the reduction.  Determine what state
1052
     that goes to, based on the state we popped back to and the rule
1053
     number reduced by.  */
1054
1055
  yyn = yyr1[yyn];
1056
1057
  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1058
  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1059
    yystate = yytable[yystate];
1060
  else
1061
    yystate = yydefgoto[yyn - YYNTBASE];
1062
1063
  goto yynewstate;
1064
1065
1066
/*------------------------------------.
1067
| yyerrlab -- here on detecting error |
1068
`------------------------------------*/
1069
yyerrlab:
1070
  /* If not already recovering from an error, report this error.  */
1071
  if (!yyerrstatus)
1072
    {
1073
      ++yynerrs;
1074
1075
#ifdef YYERROR_VERBOSE
1076
      yyn = yypact[yystate];
1077
1078
      if (yyn > YYFLAG && yyn < YYLAST)
1079
	{
1080
	  YYSIZE_T yysize = 0;
1081
	  char *yymsg;
1082
	  int yyx, yycount;
1083
1084
	  yycount = 0;
1085
	  /* Start YYX at -YYN if negative to avoid negative indexes in
1086
	     YYCHECK.  */
1087
	  for (yyx = yyn < 0 ? -yyn : 0;
1088
	       yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1089
	    if (yycheck[yyx + yyn] == yyx)
1090
	      yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1091
	  yysize += yystrlen ("parse error, unexpected ") + 1;
1092
	  yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
1093
	  yymsg = (char *) YYSTACK_ALLOC (yysize);
1094
	  if (yymsg != 0)
1095
	    {
1096
	      char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
1097
	      yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
1098
1099
	      if (yycount < 5)
1100
		{
1101
		  yycount = 0;
1102
		  for (yyx = yyn < 0 ? -yyn : 0;
1103
		       yyx < (int) (sizeof (yytname) / sizeof (char *));
1104
		       yyx++)
1105
		    if (yycheck[yyx + yyn] == yyx)
1106
		      {
1107
			const char *yyq = ! yycount ? ", expecting " : " or ";
1108
			yyp = yystpcpy (yyp, yyq);
1109
			yyp = yystpcpy (yyp, yytname[yyx]);
1110
			yycount++;
1111
		      }
1112
		}
1113
	      yyerror (yymsg);
1114
	      YYSTACK_FREE (yymsg);
1115
	    }
1116
	  else
1117
	    yyerror ("parse error; also virtual memory exhausted");
1118
	}
1119
      else
1120
#endif /* defined (YYERROR_VERBOSE) */
1121
	yyerror ("parse error");
1122
    }
1123
  goto yyerrlab1;
1124
1125
1126
/*--------------------------------------------------.
1127
| yyerrlab1 -- error raised explicitly by an action |
1128
`--------------------------------------------------*/
1129
yyerrlab1:
1130
  if (yyerrstatus == 3)
1131
    {
1132
      /* If just tried and failed to reuse lookahead token after an
1133
	 error, discard it.  */
1134
1135
      /* return failure if at end of input */
1136
      if (yychar == YYEOF)
1137
	YYABORT;
1138
      YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
1139
		  yychar, yytname[yychar1]));
1140
      yychar = YYEMPTY;
1141
    }
1142
1143
  /* Else will try to reuse lookahead token after shifting the error
1144
     token.  */
1145
1146
  yyerrstatus = 3;		/* Each real token shifted decrements this */
1147
1148
  goto yyerrhandle;
1149
1150
1151
/*-------------------------------------------------------------------.
1152
| yyerrdefault -- current state does not do anything special for the |
1153
| error token.                                                       |
1154
`-------------------------------------------------------------------*/
1155
yyerrdefault:
1156
#if 0
1157
  /* This is wrong; only states that explicitly want error tokens
1158
     should shift them.  */
1159
1160
  /* If its default is to accept any token, ok.  Otherwise pop it.  */
1161
  yyn = yydefact[yystate];
1162
  if (yyn)
1163
    goto yydefault;
1164
#endif
1165
1166
1167
/*---------------------------------------------------------------.
1168
| yyerrpop -- pop the current state because it cannot handle the |
1169
| error token                                                    |
1170
`---------------------------------------------------------------*/
1171
yyerrpop:
1172
  if (yyssp == yyss)
1173
    YYABORT;
1174
  yyvsp--;
1175
  yystate = *--yyssp;
1176
#if YYLSP_NEEDED
1177
  yylsp--;
1178
#endif
1179
1180
#if YYDEBUG
1181
  if (yydebug)
1182
    {
1183
      short *yyssp1 = yyss - 1;
1184
      YYFPRINTF (stderr, "Error: state stack now");
1185
      while (yyssp1 != yyssp)
1186
	YYFPRINTF (stderr, " %d", *++yyssp1);
1187
      YYFPRINTF (stderr, "\n");
1188
    }
1189
#endif
1190
1191
/*--------------.
1192
| yyerrhandle.  |
1193
`--------------*/
1194
yyerrhandle:
1195
  yyn = yypact[yystate];
1196
  if (yyn == YYFLAG)
1197
    goto yyerrdefault;
1198
1199
  yyn += YYTERROR;
1200
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1201
    goto yyerrdefault;
1202
1203
  yyn = yytable[yyn];
1204
  if (yyn < 0)
1205
    {
1206
      if (yyn == YYFLAG)
1207
	goto yyerrpop;
1208
      yyn = -yyn;
1209
      goto yyreduce;
1210
    }
1211
  else if (yyn == 0)
1212
    goto yyerrpop;
1213
1214
  if (yyn == YYFINAL)
1215
    YYACCEPT;
1216
1217
  YYDPRINTF ((stderr, "Shifting error token, "));
1218
1219
  *++yyvsp = yylval;
1220
#if YYLSP_NEEDED
1221
  *++yylsp = yylloc;
1222
#endif
1223
1224
  yystate = yyn;
1225
  goto yynewstate;
1226
1227
1228
/*-------------------------------------.
1229
| yyacceptlab -- YYACCEPT comes here.  |
1230
`-------------------------------------*/
1231
yyacceptlab:
1232
  yyresult = 0;
1233
  goto yyreturn;
1234
1235
/*-----------------------------------.
1236
| yyabortlab -- YYABORT comes here.  |
1237
`-----------------------------------*/
1238
yyabortlab:
1239
  yyresult = 1;
1240
  goto yyreturn;
1241
1242
/*---------------------------------------------.
1243
| yyoverflowab -- parser overflow comes here.  |
1244
`---------------------------------------------*/
1245
yyoverflowlab:
1246
  yyerror ("parser stack overflow");
1247
  yyresult = 2;
1248
  /* Fall through.  */
1249
1250
yyreturn:
1251
#ifndef yyoverflow
1252
  if (yyss != yyssa)
1253
    YYSTACK_FREE (yyss);
1254
#endif
1255
  return yyresult;
1256
}
1257
#line 155 "imap_cern.y"
1258
1259
1260
static void 
1261
cern_error(char* s)
1262
{
1263
   extern FILE *cern_in;
1264
   cern_restart(cern_in);
1265
}
1266
1267
gboolean
1268
load_cern(const char* filename)
1269
{
1270
   gboolean status;
1271
   extern FILE *cern_in;
1272
   cern_in = fopen(filename, "r");
1273
   if (cern_in) {
1274
      status = !cern_parse();
1275
      fclose(cern_in);
1276
   } else {
1277
      status = FALSE;
1278
   }
1279
   return status;
1280
}