1 /* A Bison parser, made by GNU Bison 2.6.1.  */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5       Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
6 
7    This program is free software: you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation, either version 3 of the License, or
10    (at your option) any later version.
11 
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16 
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
19 
20 /* As a special exception, you may create a larger work that contains
21    part or all of the Bison parser skeleton and distribute that work
22    under terms of your choice, so long as that work isn't itself a
23    parser generator using the skeleton or a modified version thereof
24    as a parser skeleton.  Alternatively, if you modify or redistribute
25    the parser skeleton itself, you may (at your option) remove this
26    special exception, which will cause the skeleton and the resulting
27    Bison output files to be licensed under the GNU General Public
28    License without this special exception.
29 
30    This special exception was added by the Free Software Foundation in
31    version 2.2 of Bison.  */
32 
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34    simplifying the original so-called "semantic" parser.  */
35 
36 /* All symbols defined below should begin with yy or YY, to avoid
37    infringing on user name space.  This should be done even for local
38    variables, as they might otherwise be expanded by user macros.
39    There are some unavoidable exceptions within include files to
40    define necessary library symbols; they are noted "INFRINGES ON
41    USER NAME SPACE" below.  */
42 
43 /* Identify Bison output.  */
44 #define YYBISON 1
45 
46 /* Bison version.  */
47 #define YYBISON_VERSION "2.6.1"
48 
49 /* Skeleton name.  */
50 #define YYSKELETON_NAME "yacc.c"
51 
52 /* Pure parsers.  */
53 #define YYPURE 0
54 
55 /* Push parsers.  */
56 #define YYPUSH 0
57 
58 /* Pull parsers.  */
59 #define YYPULL 1
60 
61 
62 /* Substitute the variable and function names.  */
63 #define yyparse         csim_parse
64 #define yylex           csim_lex
65 #define yyerror         csim_error
66 #define yylval          csim_lval
67 #define yychar          csim_char
68 #define yydebug         csim_debug
69 #define yynerrs         csim_nerrs
70 
71 /* Copy the first part of user declarations.  */
72 /* Line 336 of yacc.c  */
73 #line 1 "imap_csim.y"
74 
75 /*
76  * This is a plug-in for GIMP.
77  *
78  * Generates clickable image maps.
79  *
80  * Copyright (C) 1998-2005 Maurits Rijk  lpeek.mrijk@consunet.nl
81  *
82  * This program is free software: you can redistribute it and/or modify
83  * it under the terms of the GNU General Public License as published by
84  * the Free Software Foundation; either version 3 of the License, or
85  * (at your option) any later version.
86  *
87  * This program is distributed in the hope that it will be useful,
88  * but WITHOUT ANY WARRANTY; without even the implied warranty of
89  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
90  * GNU General Public License for more details.
91  *
92  * You should have received a copy of the GNU General Public License
93  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
94  *
95  */
96 
97 #include <stdlib.h>
98 #include <string.h>
99 
100 #include <glib/gstdio.h>
101 
102 #include <gtk/gtk.h>
103 
104 #include "imap_circle.h"
105 #include "imap_file.h"
106 #include "imap_main.h"
107 #include "imap_polygon.h"
108 #include "imap_rectangle.h"
109 #include "imap_string.h"
110 
111 extern int csim_lex(void);
112 extern int csim_restart(FILE *csim_in);
113 static void csim_error(char* s);
114 static gchar * unescape_text(gchar *input);
115 
116 static enum {UNDEFINED, RECTANGLE, CIRCLE, POLYGON} current_type;
117 static Object_t *current_object;
118 static MapInfo_t *_map_info;
119 
120 
121 /* Line 336 of yacc.c  */
122 #line 123 "y.tab.c"
123 
124 # ifndef YY_NULL
125 #  if defined __cplusplus && 201103L <= __cplusplus
126 #   define YY_NULL nullptr
127 #  else
128 #   define YY_NULL 0
129 #  endif
130 # endif
131 
132 /* Enabling verbose error messages.  */
133 #ifdef YYERROR_VERBOSE
134 # undef YYERROR_VERBOSE
135 # define YYERROR_VERBOSE 1
136 #else
137 # define YYERROR_VERBOSE 0
138 #endif
139 
140 /* In a future release of Bison, this section will be replaced
141    by #include "y.tab.h".  */
142 #ifndef CSIM_Y_TAB_H
143 # define CSIM_Y_TAB_H
144 /* Enabling traces.  */
145 #ifndef YYDEBUG
146 # define YYDEBUG 0
147 #endif
148 #if YYDEBUG
149 extern int csim_debug;
150 #endif
151 
152 /* Tokens.  */
153 #ifndef YYTOKENTYPE
154 # define YYTOKENTYPE
155    /* Put the tokens into the symbol table, so that GDB and other debuggers
156       know about them.  */
157    enum yytokentype {
158      IMG = 258,
159      SRC = 259,
160      WIDTH = 260,
161      HEIGHT = 261,
162      BORDER = 262,
163      USEMAP = 263,
164      START_MAP = 264,
165      END_MAP = 265,
166      NAME = 266,
167      AREA = 267,
168      SHAPE = 268,
169      COORDS = 269,
170      ALT = 270,
171      HREF = 271,
172      NOHREF = 272,
173      TARGET = 273,
174      ONMOUSEOVER = 274,
175      ONMOUSEOUT = 275,
176      ONFOCUS = 276,
177      ONBLUR = 277,
178      AUTHOR = 278,
179      DESCRIPTION = 279,
180      BEGIN_COMMENT = 280,
181      END_COMMENT = 281,
182      FLOAT = 282,
183      STRING = 283
184    };
185 #endif
186 /* Tokens.  */
187 #define IMG 258
188 #define SRC 259
189 #define WIDTH 260
190 #define HEIGHT 261
191 #define BORDER 262
192 #define USEMAP 263
193 #define START_MAP 264
194 #define END_MAP 265
195 #define NAME 266
196 #define AREA 267
197 #define SHAPE 268
198 #define COORDS 269
199 #define ALT 270
200 #define HREF 271
201 #define NOHREF 272
202 #define TARGET 273
203 #define ONMOUSEOVER 274
204 #define ONMOUSEOUT 275
205 #define ONFOCUS 276
206 #define ONBLUR 277
207 #define AUTHOR 278
208 #define DESCRIPTION 279
209 #define BEGIN_COMMENT 280
210 #define END_COMMENT 281
211 #define FLOAT 282
212 #define STRING 283
213 
214 
215 
216 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
217 typedef union YYSTYPE
218 {
219 /* Line 350 of yacc.c  */
220 #line 49 "imap_csim.y"
221 
222   int val;
223   double value;
224   char *id;
225 
226 
227 /* Line 350 of yacc.c  */
228 #line 229 "y.tab.c"
229 } YYSTYPE;
230 # define YYSTYPE_IS_TRIVIAL 1
231 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
232 # define YYSTYPE_IS_DECLARED 1
233 #endif
234 
235 extern YYSTYPE csim_lval;
236 
237 #ifdef YYPARSE_PARAM
238 #if defined __STDC__ || defined __cplusplus
239 int csim_parse (void *YYPARSE_PARAM);
240 #else
241 int csim_parse ();
242 #endif
243 #else /* ! YYPARSE_PARAM */
244 #if defined __STDC__ || defined __cplusplus
245 int csim_parse (void);
246 #else
247 int csim_parse ();
248 #endif
249 #endif /* ! YYPARSE_PARAM */
250 
251 #endif /* !CSIM_Y_TAB_H  */
252 
253 /* Copy the second part of user declarations.  */
254 
255 /* Line 353 of yacc.c  */
256 #line 257 "y.tab.c"
257 
258 #ifdef short
259 # undef short
260 #endif
261 
262 #ifdef YYTYPE_UINT8
263 typedef YYTYPE_UINT8 yytype_uint8;
264 #else
265 typedef unsigned char yytype_uint8;
266 #endif
267 
268 #ifdef YYTYPE_INT8
269 typedef YYTYPE_INT8 yytype_int8;
270 #elif (defined __STDC__ || defined __C99__FUNC__ \
271      || defined __cplusplus || defined _MSC_VER)
272 typedef signed char yytype_int8;
273 #else
274 typedef short int yytype_int8;
275 #endif
276 
277 #ifdef YYTYPE_UINT16
278 typedef YYTYPE_UINT16 yytype_uint16;
279 #else
280 typedef unsigned short int yytype_uint16;
281 #endif
282 
283 #ifdef YYTYPE_INT16
284 typedef YYTYPE_INT16 yytype_int16;
285 #else
286 typedef short int yytype_int16;
287 #endif
288 
289 #ifndef YYSIZE_T
290 # ifdef __SIZE_TYPE__
291 #  define YYSIZE_T __SIZE_TYPE__
292 # elif defined size_t
293 #  define YYSIZE_T size_t
294 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
295      || defined __cplusplus || defined _MSC_VER)
296 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
297 #  define YYSIZE_T size_t
298 # else
299 #  define YYSIZE_T unsigned int
300 # endif
301 #endif
302 
303 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
304 
305 #ifndef YY_
306 # if defined YYENABLE_NLS && YYENABLE_NLS
307 #  if ENABLE_NLS
308 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
309 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
310 #  endif
311 # endif
312 # ifndef YY_
313 #  define YY_(msgid) msgid
314 # endif
315 #endif
316 
317 /* Suppress unused-variable warnings by "using" E.  */
318 #if ! defined lint || defined __GNUC__
319 # define YYUSE(e) ((void) (e))
320 #else
321 # define YYUSE(e) /* empty */
322 #endif
323 
324 /* Identity function, used to suppress warnings about constant conditions.  */
325 #ifndef lint
326 # define YYID(n) (n)
327 #else
328 #if (defined __STDC__ || defined __C99__FUNC__ \
329      || defined __cplusplus || defined _MSC_VER)
330 static int
YYID(int yyi)331 YYID (int yyi)
332 #else
333 static int
334 YYID (yyi)
335     int yyi;
336 #endif
337 {
338   return yyi;
339 }
340 #endif
341 
342 #if ! defined yyoverflow || YYERROR_VERBOSE
343 
344 /* The parser invokes alloca or malloc; define the necessary symbols.  */
345 
346 # ifdef YYSTACK_USE_ALLOCA
347 #  if YYSTACK_USE_ALLOCA
348 #   ifdef __GNUC__
349 #    define YYSTACK_ALLOC __builtin_alloca
350 #   elif defined __BUILTIN_VA_ARG_INCR
351 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
352 #   elif defined _AIX
353 #    define YYSTACK_ALLOC __alloca
354 #   elif defined _MSC_VER
355 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
356 #    define alloca _alloca
357 #   else
358 #    define YYSTACK_ALLOC alloca
359 #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
360      || defined __cplusplus || defined _MSC_VER)
361 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
362       /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
363 #     ifndef EXIT_SUCCESS
364 #      define EXIT_SUCCESS 0
365 #     endif
366 #    endif
367 #   endif
368 #  endif
369 # endif
370 
371 # ifdef YYSTACK_ALLOC
372    /* Pacify GCC's `empty if-body' warning.  */
373 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
374 #  ifndef YYSTACK_ALLOC_MAXIMUM
375     /* The OS might guarantee only one guard page at the bottom of the stack,
376        and a page size can be as small as 4096 bytes.  So we cannot safely
377        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
378        to allow for a few compiler-allocated temporary stack slots.  */
379 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
380 #  endif
381 # else
382 #  define YYSTACK_ALLOC YYMALLOC
383 #  define YYSTACK_FREE YYFREE
384 #  ifndef YYSTACK_ALLOC_MAXIMUM
385 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
386 #  endif
387 #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
388        && ! ((defined YYMALLOC || defined malloc) \
389 	     && (defined YYFREE || defined free)))
390 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
391 #   ifndef EXIT_SUCCESS
392 #    define EXIT_SUCCESS 0
393 #   endif
394 #  endif
395 #  ifndef YYMALLOC
396 #   define YYMALLOC malloc
397 #   if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
398      || defined __cplusplus || defined _MSC_VER)
399 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
400 #   endif
401 #  endif
402 #  ifndef YYFREE
403 #   define YYFREE free
404 #   if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
405      || defined __cplusplus || defined _MSC_VER)
406 void free (void *); /* INFRINGES ON USER NAME SPACE */
407 #   endif
408 #  endif
409 # endif
410 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
411 
412 
413 #if (! defined yyoverflow \
414      && (! defined __cplusplus \
415 	 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
416 
417 /* A type that is properly aligned for any stack member.  */
418 union yyalloc
419 {
420   yytype_int16 yyss_alloc;
421   YYSTYPE yyvs_alloc;
422 };
423 
424 /* The size of the maximum gap between one aligned stack and the next.  */
425 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
426 
427 /* The size of an array large to enough to hold all stacks, each with
428    N elements.  */
429 # define YYSTACK_BYTES(N) \
430      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
431       + YYSTACK_GAP_MAXIMUM)
432 
433 # define YYCOPY_NEEDED 1
434 
435 /* Relocate STACK from its old location to the new one.  The
436    local variables YYSIZE and YYSTACKSIZE give the old and new number of
437    elements in the stack, and YYPTR gives the new location of the
438    stack.  Advance YYPTR to a properly aligned location for the next
439    stack.  */
440 # define YYSTACK_RELOCATE(Stack_alloc, Stack)				\
441     do									\
442       {									\
443 	YYSIZE_T yynewbytes;						\
444 	YYCOPY (&yyptr->Stack_alloc, Stack, yysize);			\
445 	Stack = &yyptr->Stack_alloc;					\
446 	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
447 	yyptr += yynewbytes / sizeof (*yyptr);				\
448       }									\
449     while (YYID (0))
450 
451 #endif
452 
453 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
454 /* Copy COUNT objects from SRC to DST.  The source and destination do
455    not overlap.  */
456 # ifndef YYCOPY
457 #  if defined __GNUC__ && 1 < __GNUC__
458 #   define YYCOPY(Dst, Src, Count) \
459       __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
460 #  else
461 #   define YYCOPY(Dst, Src, Count)              \
462       do                                        \
463         {                                       \
464           YYSIZE_T yyi;                         \
465           for (yyi = 0; yyi < (Count); yyi++)   \
466             (Dst)[yyi] = (Src)[yyi];            \
467         }                                       \
468       while (YYID (0))
469 #  endif
470 # endif
471 #endif /* !YYCOPY_NEEDED */
472 
473 /* YYFINAL -- State number of the termination state.  */
474 #define YYFINAL  5
475 /* YYLAST -- Last index in YYTABLE.  */
476 #define YYLAST   84
477 
478 /* YYNTOKENS -- Number of terminals.  */
479 #define YYNTOKENS  33
480 /* YYNNTS -- Number of nonterminals.  */
481 #define YYNNTS  31
482 /* YYNRULES -- Number of rules.  */
483 #define YYNRULES  53
484 /* YYNRULES -- Number of states.  */
485 #define YYNSTATES  106
486 
487 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
488 #define YYUNDEFTOK  2
489 #define YYMAXUTOK   283
490 
491 #define YYTRANSLATE(YYX)						\
492   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
493 
494 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
495 static const yytype_uint8 yytranslate[] =
496 {
497        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
498        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
499        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
500        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
501        2,     2,     2,     2,     2,     2,     2,    32,     2,     2,
502        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
503       29,    30,    31,     2,     2,     2,     2,     2,     2,     2,
504        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
505        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
506        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
507        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
508        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
509        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
510        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
511        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
512        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
513        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
514        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
515        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
516        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
517        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
518        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
519        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
520        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
521        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
522        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
523        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
524       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
525       25,    26,    27,    28
526 };
527 
528 #if YYDEBUG
529 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
530    YYRHS.  */
531 static const yytype_uint8 yyprhs[] =
532 {
533        0,     0,     3,     9,    17,    18,    21,    23,    25,    29,
534       33,    37,    41,    45,    47,    49,    56,    57,    60,    62,
535       64,    66,    70,    74,    78,    79,    82,    87,    89,    92,
536       93,    96,    98,   100,   102,   104,   106,   108,   110,   112,
537      114,   116,   120,   124,   128,   131,   132,   135,   139,   143,
538      147,   151,   155,   159
539 };
540 
541 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
542 static const yytype_int8 yyrhs[] =
543 {
544       34,     0,    -1,    35,    41,    42,    47,    63,    -1,    29,
545        3,     4,    30,    28,    36,    49,    -1,    -1,    36,    37,
546       -1,    38,    -1,    39,    -1,     7,    30,    40,    -1,     8,
547       30,    28,    -1,    15,    30,    28,    -1,     5,    30,    40,
548       -1,     6,    30,    40,    -1,    27,    -1,    28,    -1,    29,
549        9,    11,    30,    28,    31,    -1,    -1,    42,    43,    -1,
550       45,    -1,    46,    -1,    44,    -1,    25,    28,    26,    -1,
551       23,    28,    26,    -1,    24,    28,    26,    -1,    -1,    47,
552       48,    -1,    29,    12,    50,    49,    -1,    31,    -1,    32,
553       31,    -1,    -1,    50,    51,    -1,    52,    -1,    53,    -1,
554       54,    -1,    55,    -1,    57,    -1,    58,    -1,    59,    -1,
555       60,    -1,    61,    -1,    62,    -1,    13,    30,    28,    -1,
556       14,    30,    28,    -1,    16,    30,    28,    -1,    17,    56,
557       -1,    -1,    30,    28,    -1,    15,    30,    28,    -1,    18,
558       30,    28,    -1,    19,    30,    28,    -1,    20,    30,    28,
559       -1,    21,    30,    28,    -1,    22,    30,    28,    -1,    29,
560       10,    31,    -1
561 };
562 
563 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
564 static const yytype_uint16 yyrline[] =
565 {
566        0,    66,    66,    69,    76,    77,    80,    81,    82,    83,
567       84,    87,    93,    99,   103,   110,   117,   118,   121,   122,
568      123,   126,   132,   139,   150,   151,   154,   161,   162,   165,
569      166,   169,   170,   171,   172,   173,   174,   175,   176,   177,
570      178,   181,   199,   259,   270,   275,   276,   282,   289,   296,
571      303,   310,   317,   324
572 };
573 #endif
574 
575 #if YYDEBUG || YYERROR_VERBOSE || 0
576 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
577    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
578 static const char *const yytname[] =
579 {
580   "$end", "error", "$undefined", "IMG", "SRC", "WIDTH", "HEIGHT",
581   "BORDER", "USEMAP", "START_MAP", "END_MAP", "NAME", "AREA", "SHAPE",
582   "COORDS", "ALT", "HREF", "NOHREF", "TARGET", "ONMOUSEOVER", "ONMOUSEOUT",
583   "ONFOCUS", "ONBLUR", "AUTHOR", "DESCRIPTION", "BEGIN_COMMENT",
584   "END_COMMENT", "FLOAT", "STRING", "'<'", "'='", "'>'", "'/'", "$accept",
585   "csim_file", "image", "image_tags", "image_tag", "image_width",
586   "image_height", "integer_value", "start_map", "comment_lines",
587   "comment_line", "real_comment", "author_line", "description_line",
588   "area_list", "area", "xhtml_close", "tag_list", "tag", "shape_tag",
589   "coords_tag", "href_tag", "nohref_tag", "optional_value", "alt_tag",
590   "target_tag", "onmouseover_tag", "onmouseout_tag", "onfocus_tag",
591   "onblur_tag", "end_map", YY_NULL
592 };
593 #endif
594 
595 # ifdef YYPRINT
596 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
597    token YYLEX-NUM.  */
598 static const yytype_uint16 yytoknum[] =
599 {
600        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
601      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
602      275,   276,   277,   278,   279,   280,   281,   282,   283,    60,
603       61,    62,    47
604 };
605 # endif
606 
607 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
608 static const yytype_uint8 yyr1[] =
609 {
610        0,    33,    34,    35,    36,    36,    37,    37,    37,    37,
611       37,    38,    39,    40,    40,    41,    42,    42,    43,    43,
612       43,    44,    45,    46,    47,    47,    48,    49,    49,    50,
613       50,    51,    51,    51,    51,    51,    51,    51,    51,    51,
614       51,    52,    53,    54,    55,    56,    56,    57,    58,    59,
615       60,    61,    62,    63
616 };
617 
618 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
619 static const yytype_uint8 yyr2[] =
620 {
621        0,     2,     5,     7,     0,     2,     1,     1,     3,     3,
622        3,     3,     3,     1,     1,     6,     0,     2,     1,     1,
623        1,     3,     3,     3,     0,     2,     4,     1,     2,     0,
624        2,     1,     1,     1,     1,     1,     1,     1,     1,     1,
625        1,     3,     3,     3,     2,     0,     2,     3,     3,     3,
626        3,     3,     3,     3
627 };
628 
629 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
630    Performed when YYTABLE doesn't specify something else to do.  Zero
631    means the default is an error.  */
632 static const yytype_uint8 yydefact[] =
633 {
634        0,     0,     0,     0,     0,     1,     0,    16,     0,     0,
635       24,     0,     0,     0,     0,     0,    17,    20,    18,    19,
636        0,     4,     0,     0,     0,     0,     0,    25,     2,     0,
637        0,    22,    23,    21,     0,    29,     0,     0,     0,     0,
638        0,    27,     0,     5,     6,     7,     3,    15,    53,     0,
639        0,     0,     0,     0,     0,    28,     0,     0,     0,     0,
640       45,     0,     0,     0,     0,     0,    26,    30,    31,    32,
641       33,    34,    35,    36,    37,    38,    39,    40,    13,    14,
642       11,    12,     8,     9,    10,     0,     0,     0,     0,     0,
643       44,     0,     0,     0,     0,     0,    41,    42,    47,    43,
644       46,    48,    49,    50,    51,    52
645 };
646 
647 /* YYDEFGOTO[NTERM-NUM].  */
648 static const yytype_int8 yydefgoto[] =
649 {
650       -1,     2,     3,    29,    43,    44,    45,    80,     7,    10,
651       16,    17,    18,    19,    20,    27,    46,    49,    67,    68,
652       69,    70,    71,    90,    72,    73,    74,    75,    76,    77,
653       28
654 };
655 
656 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
657    STATE-NUM.  */
658 #define YYPACT_NINF -29
659 static const yytype_int8 yypact[] =
660 {
661      -21,    22,    28,     2,    29,   -29,    23,   -29,     4,    24,
662      -19,     8,     7,    10,    11,    12,   -29,   -29,   -29,   -29,
663       13,   -29,    15,    18,    19,    20,    -3,   -29,   -29,    -5,
664       16,   -29,   -29,   -29,    17,   -29,    21,    25,    26,    27,
665       30,   -29,    31,   -29,   -29,   -29,   -29,   -29,   -29,    -2,
666       -6,    -6,    -6,    33,    35,   -29,    34,    36,    37,    38,
667       39,    40,    41,    42,    43,    44,   -29,   -29,   -29,   -29,
668      -29,   -29,   -29,   -29,   -29,   -29,   -29,   -29,   -29,   -29,
669      -29,   -29,   -29,   -29,   -29,    47,    48,    49,    50,    51,
670      -29,    52,    53,    54,    55,    56,   -29,   -29,   -29,   -29,
671      -29,   -29,   -29,   -29,   -29,   -29
672 };
673 
674 /* YYPGOTO[NTERM-NUM].  */
675 static const yytype_int8 yypgoto[] =
676 {
677      -29,   -29,   -29,   -29,   -29,   -29,   -29,   -28,   -29,   -29,
678      -29,   -29,   -29,   -29,   -29,   -29,    -8,   -29,   -29,   -29,
679      -29,   -29,   -29,   -29,   -29,   -29,   -29,   -29,   -29,   -29,
680      -29
681 };
682 
683 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
684    positive, shift that token.  If negative, reduce the rule which
685    number is the opposite.  If YYTABLE_NINF, syntax error.  */
686 #define YYTABLE_NINF -1
687 static const yytype_uint8 yytable[] =
688 {
689       36,    37,    38,    39,    13,    14,    15,    34,     1,    35,
690       40,    56,    57,    58,    59,    60,    61,    62,    63,    64,
691       65,    78,    79,    81,    82,     4,    41,    42,     5,    41,
692       42,     6,     9,     8,    11,    12,    21,    22,    23,    24,
693       25,    66,    26,    30,    31,    32,    33,    47,    48,     0,
694        0,    50,     0,     0,     0,    51,    52,    53,     0,     0,
695       54,    83,    55,    84,    85,     0,    86,    87,    88,    89,
696       91,    92,    93,    94,    95,    96,    97,    98,    99,   100,
697      101,   102,   103,   104,   105
698 };
699 
700 #define yypact_value_is_default(yystate) \
701   ((yystate) == (-29))
702 
703 #define yytable_value_is_error(yytable_value) \
704   YYID (0)
705 
706 static const yytype_int8 yycheck[] =
707 {
708        5,     6,     7,     8,    23,    24,    25,    10,    29,    12,
709       15,    13,    14,    15,    16,    17,    18,    19,    20,    21,
710       22,    27,    28,    51,    52,     3,    31,    32,     0,    31,
711       32,    29,     9,     4,    30,    11,    28,    30,    28,    28,
712       28,    49,    29,    28,    26,    26,    26,    31,    31,    -1,
713       -1,    30,    -1,    -1,    -1,    30,    30,    30,    -1,    -1,
714       30,    28,    31,    28,    30,    -1,    30,    30,    30,    30,
715       30,    30,    30,    30,    30,    28,    28,    28,    28,    28,
716       28,    28,    28,    28,    28
717 };
718 
719 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
720    symbol of state STATE-NUM.  */
721 static const yytype_uint8 yystos[] =
722 {
723        0,    29,    34,    35,     3,     0,    29,    41,     4,     9,
724       42,    30,    11,    23,    24,    25,    43,    44,    45,    46,
725       47,    28,    30,    28,    28,    28,    29,    48,    63,    36,
726       28,    26,    26,    26,    10,    12,     5,     6,     7,     8,
727       15,    31,    32,    37,    38,    39,    49,    31,    31,    50,
728       30,    30,    30,    30,    30,    31,    13,    14,    15,    16,
729       17,    18,    19,    20,    21,    22,    49,    51,    52,    53,
730       54,    55,    57,    58,    59,    60,    61,    62,    27,    28,
731       40,    40,    40,    28,    28,    30,    30,    30,    30,    30,
732       56,    30,    30,    30,    30,    30,    28,    28,    28,    28,
733       28,    28,    28,    28,    28,    28
734 };
735 
736 #define yyerrok		(yyerrstatus = 0)
737 #define yyclearin	(yychar = YYEMPTY)
738 #define YYEMPTY		(-2)
739 #define YYEOF		0
740 
741 #define YYACCEPT	goto yyacceptlab
742 #define YYABORT		goto yyabortlab
743 #define YYERROR		goto yyerrorlab
744 
745 
746 /* Like YYERROR except do call yyerror.  This remains here temporarily
747    to ease the transition to the new meaning of YYERROR, for GCC.
748    Once GCC version 2 has supplanted version 1, this can go.  However,
749    YYFAIL appears to be in use.  Nevertheless, it is formally deprecated
750    in Bison 2.4.2's NEWS entry, where a plan to phase it out is
751    discussed.  */
752 
753 #define YYFAIL		goto yyerrlab
754 #if defined YYFAIL
755   /* This is here to suppress warnings from the GCC cpp's
756      -Wunused-macros.  Normally we don't worry about that warning, but
757      some users do, and we want to make it easy for users to remove
758      YYFAIL uses, which will produce warnings from Bison 2.5.  */
759 #endif
760 
761 #define YYRECOVERING()  (!!yyerrstatus)
762 
763 #define YYBACKUP(Token, Value)                                  \
764 do                                                              \
765   if (yychar == YYEMPTY)                                        \
766     {                                                           \
767       yychar = (Token);                                         \
768       yylval = (Value);                                         \
769       YYPOPSTACK (yylen);                                       \
770       yystate = *yyssp;                                         \
771       goto yybackup;                                            \
772     }                                                           \
773   else                                                          \
774     {                                                           \
775       yyerror (YY_("syntax error: cannot back up")); \
776       YYERROR;							\
777     }								\
778 while (YYID (0))
779 
780 
781 #define YYTERROR	1
782 #define YYERRCODE	256
783 
784 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
785    If N is 0, then set CURRENT to the empty location which ends
786    the previous symbol: RHS[0] (always defined).  */
787 
788 #ifndef YYLLOC_DEFAULT
789 # define YYLLOC_DEFAULT(Current, Rhs, N)                                \
790     do                                                                  \
791       if (YYID (N))                                                     \
792         {                                                               \
793           (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
794           (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
795           (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
796           (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
797         }                                                               \
798       else                                                              \
799         {                                                               \
800           (Current).first_line   = (Current).last_line   =              \
801             YYRHSLOC (Rhs, 0).last_line;                                \
802           (Current).first_column = (Current).last_column =              \
803             YYRHSLOC (Rhs, 0).last_column;                              \
804         }                                                               \
805     while (YYID (0))
806 #endif
807 
808 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
809 
810 
811 
812 /* This macro is provided for backward compatibility. */
813 
814 #ifndef YY_LOCATION_PRINT
815 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
816 #endif
817 
818 
819 /* YYLEX -- calling `yylex' with the right arguments.  */
820 
821 #ifdef YYLEX_PARAM
822 # define YYLEX yylex (YYLEX_PARAM)
823 #else
824 # define YYLEX yylex ()
825 #endif
826 
827 /* Enable debugging if requested.  */
828 #if YYDEBUG
829 
830 # ifndef YYFPRINTF
831 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
832 #  define YYFPRINTF fprintf
833 # endif
834 
835 # define YYDPRINTF(Args)			\
836 do {						\
837   if (yydebug)					\
838     YYFPRINTF Args;				\
839 } while (YYID (0))
840 
841 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)			  \
842 do {									  \
843   if (yydebug)								  \
844     {									  \
845       YYFPRINTF (stderr, "%s ", Title);					  \
846       yy_symbol_print (stderr,						  \
847 		  Type, Value); \
848       YYFPRINTF (stderr, "\n");						  \
849     }									  \
850 } while (YYID (0))
851 
852 
853 /*--------------------------------.
854 | Print this symbol on YYOUTPUT.  |
855 `--------------------------------*/
856 
857 /*ARGSUSED*/
858 #if (defined __STDC__ || defined __C99__FUNC__ \
859      || defined __cplusplus || defined _MSC_VER)
860 static void
yy_symbol_value_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)861 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
862 #else
863 static void
864 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
865     FILE *yyoutput;
866     int yytype;
867     YYSTYPE const * const yyvaluep;
868 #endif
869 {
870   FILE *yyo = yyoutput;
871   YYUSE (yyo);
872   if (!yyvaluep)
873     return;
874 # ifdef YYPRINT
875   if (yytype < YYNTOKENS)
876     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
877 # else
878   YYUSE (yyoutput);
879 # endif
880   switch (yytype)
881     {
882       default:
883 	break;
884     }
885 }
886 
887 
888 /*--------------------------------.
889 | Print this symbol on YYOUTPUT.  |
890 `--------------------------------*/
891 
892 #if (defined __STDC__ || defined __C99__FUNC__ \
893      || defined __cplusplus || defined _MSC_VER)
894 static void
yy_symbol_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)895 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
896 #else
897 static void
898 yy_symbol_print (yyoutput, yytype, yyvaluep)
899     FILE *yyoutput;
900     int yytype;
901     YYSTYPE const * const yyvaluep;
902 #endif
903 {
904   if (yytype < YYNTOKENS)
905     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
906   else
907     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
908 
909   yy_symbol_value_print (yyoutput, yytype, yyvaluep);
910   YYFPRINTF (yyoutput, ")");
911 }
912 
913 /*------------------------------------------------------------------.
914 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
915 | TOP (included).                                                   |
916 `------------------------------------------------------------------*/
917 
918 #if (defined __STDC__ || defined __C99__FUNC__ \
919      || defined __cplusplus || defined _MSC_VER)
920 static void
yy_stack_print(yytype_int16 * yybottom,yytype_int16 * yytop)921 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
922 #else
923 static void
924 yy_stack_print (yybottom, yytop)
925     yytype_int16 *yybottom;
926     yytype_int16 *yytop;
927 #endif
928 {
929   YYFPRINTF (stderr, "Stack now");
930   for (; yybottom <= yytop; yybottom++)
931     {
932       int yybot = *yybottom;
933       YYFPRINTF (stderr, " %d", yybot);
934     }
935   YYFPRINTF (stderr, "\n");
936 }
937 
938 # define YY_STACK_PRINT(Bottom, Top)				\
939 do {								\
940   if (yydebug)							\
941     yy_stack_print ((Bottom), (Top));				\
942 } while (YYID (0))
943 
944 
945 /*------------------------------------------------.
946 | Report that the YYRULE is going to be reduced.  |
947 `------------------------------------------------*/
948 
949 #if (defined __STDC__ || defined __C99__FUNC__ \
950      || defined __cplusplus || defined _MSC_VER)
951 static void
yy_reduce_print(YYSTYPE * yyvsp,int yyrule)952 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
953 #else
954 static void
955 yy_reduce_print (yyvsp, yyrule)
956     YYSTYPE *yyvsp;
957     int yyrule;
958 #endif
959 {
960   int yynrhs = yyr2[yyrule];
961   int yyi;
962   unsigned long int yylno = yyrline[yyrule];
963   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
964 	     yyrule - 1, yylno);
965   /* The symbols being reduced.  */
966   for (yyi = 0; yyi < yynrhs; yyi++)
967     {
968       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
969       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
970 		       &(yyvsp[(yyi + 1) - (yynrhs)])
971 		       		       );
972       YYFPRINTF (stderr, "\n");
973     }
974 }
975 
976 # define YY_REDUCE_PRINT(Rule)		\
977 do {					\
978   if (yydebug)				\
979     yy_reduce_print (yyvsp, Rule); \
980 } while (YYID (0))
981 
982 /* Nonzero means print parse trace.  It is left uninitialized so that
983    multiple parsers can coexist.  */
984 int yydebug;
985 #else /* !YYDEBUG */
986 # define YYDPRINTF(Args)
987 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
988 # define YY_STACK_PRINT(Bottom, Top)
989 # define YY_REDUCE_PRINT(Rule)
990 #endif /* !YYDEBUG */
991 
992 
993 /* YYINITDEPTH -- initial size of the parser's stacks.  */
994 #ifndef	YYINITDEPTH
995 # define YYINITDEPTH 200
996 #endif
997 
998 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
999    if the built-in stack extension method is used).
1000 
1001    Do not make this value too large; the results are undefined if
1002    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1003    evaluated with infinite-precision integer arithmetic.  */
1004 
1005 #ifndef YYMAXDEPTH
1006 # define YYMAXDEPTH 10000
1007 #endif
1008 
1009 
1010 #if YYERROR_VERBOSE
1011 
1012 # ifndef yystrlen
1013 #  if defined __GLIBC__ && defined _STRING_H
1014 #   define yystrlen strlen
1015 #  else
1016 /* Return the length of YYSTR.  */
1017 #if (defined __STDC__ || defined __C99__FUNC__ \
1018      || defined __cplusplus || defined _MSC_VER)
1019 static YYSIZE_T
yystrlen(const char * yystr)1020 yystrlen (const char *yystr)
1021 #else
1022 static YYSIZE_T
1023 yystrlen (yystr)
1024     const char *yystr;
1025 #endif
1026 {
1027   YYSIZE_T yylen;
1028   for (yylen = 0; yystr[yylen]; yylen++)
1029     continue;
1030   return yylen;
1031 }
1032 #  endif
1033 # endif
1034 
1035 # ifndef yystpcpy
1036 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1037 #   define yystpcpy stpcpy
1038 #  else
1039 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1040    YYDEST.  */
1041 #if (defined __STDC__ || defined __C99__FUNC__ \
1042      || defined __cplusplus || defined _MSC_VER)
1043 static char *
yystpcpy(char * yydest,const char * yysrc)1044 yystpcpy (char *yydest, const char *yysrc)
1045 #else
1046 static char *
1047 yystpcpy (yydest, yysrc)
1048     char *yydest;
1049     const char *yysrc;
1050 #endif
1051 {
1052   char *yyd = yydest;
1053   const char *yys = yysrc;
1054 
1055   while ((*yyd++ = *yys++) != '\0')
1056     continue;
1057 
1058   return yyd - 1;
1059 }
1060 #  endif
1061 # endif
1062 
1063 # ifndef yytnamerr
1064 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1065    quotes and backslashes, so that it's suitable for yyerror.  The
1066    heuristic is that double-quoting is unnecessary unless the string
1067    contains an apostrophe, a comma, or backslash (other than
1068    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1069    null, do not copy; instead, return the length of what the result
1070    would have been.  */
1071 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)1072 yytnamerr (char *yyres, const char *yystr)
1073 {
1074   if (*yystr == '"')
1075     {
1076       YYSIZE_T yyn = 0;
1077       char const *yyp = yystr;
1078 
1079       for (;;)
1080 	switch (*++yyp)
1081 	  {
1082 	  case '\'':
1083 	  case ',':
1084 	    goto do_not_strip_quotes;
1085 
1086 	  case '\\':
1087 	    if (*++yyp != '\\')
1088 	      goto do_not_strip_quotes;
1089 	    /* Fall through.  */
1090 	  default:
1091 	    if (yyres)
1092 	      yyres[yyn] = *yyp;
1093 	    yyn++;
1094 	    break;
1095 
1096 	  case '"':
1097 	    if (yyres)
1098 	      yyres[yyn] = '\0';
1099 	    return yyn;
1100 	  }
1101     do_not_strip_quotes: ;
1102     }
1103 
1104   if (! yyres)
1105     return yystrlen (yystr);
1106 
1107   return yystpcpy (yyres, yystr) - yyres;
1108 }
1109 # endif
1110 
1111 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1112    about the unexpected token YYTOKEN for the state stack whose top is
1113    YYSSP.
1114 
1115    Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
1116    not large enough to hold the message.  In that case, also set
1117    *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
1118    required number of bytes is too large to store.  */
1119 static int
yysyntax_error(YYSIZE_T * yymsg_alloc,char ** yymsg,yytype_int16 * yyssp,int yytoken)1120 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1121                 yytype_int16 *yyssp, int yytoken)
1122 {
1123   YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
1124   YYSIZE_T yysize = yysize0;
1125   YYSIZE_T yysize1;
1126   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1127   /* Internationalized format string. */
1128   const char *yyformat = YY_NULL;
1129   /* Arguments of yyformat. */
1130   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1131   /* Number of reported tokens (one for the "unexpected", one per
1132      "expected"). */
1133   int yycount = 0;
1134 
1135   /* There are many possibilities here to consider:
1136      - Assume YYFAIL is not used.  It's too flawed to consider.  See
1137        <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1138        for details.  YYERROR is fine as it does not invoke this
1139        function.
1140      - If this state is a consistent state with a default action, then
1141        the only way this function was invoked is if the default action
1142        is an error action.  In that case, don't check for expected
1143        tokens because there are none.
1144      - The only way there can be no lookahead present (in yychar) is if
1145        this state is a consistent state with a default action.  Thus,
1146        detecting the absence of a lookahead is sufficient to determine
1147        that there is no unexpected or expected token to report.  In that
1148        case, just report a simple "syntax error".
1149      - Don't assume there isn't a lookahead just because this state is a
1150        consistent state with a default action.  There might have been a
1151        previous inconsistent state, consistent state with a non-default
1152        action, or user semantic action that manipulated yychar.
1153      - Of course, the expected token list depends on states to have
1154        correct lookahead information, and it depends on the parser not
1155        to perform extra reductions after fetching a lookahead from the
1156        scanner and before detecting a syntax error.  Thus, state merging
1157        (from LALR or IELR) and default reductions corrupt the expected
1158        token list.  However, the list is correct for canonical LR with
1159        one exception: it will still contain any token that will not be
1160        accepted due to an error action in a later state.
1161   */
1162   if (yytoken != YYEMPTY)
1163     {
1164       int yyn = yypact[*yyssp];
1165       yyarg[yycount++] = yytname[yytoken];
1166       if (!yypact_value_is_default (yyn))
1167         {
1168           /* Start YYX at -YYN if negative to avoid negative indexes in
1169              YYCHECK.  In other words, skip the first -YYN actions for
1170              this state because they are default actions.  */
1171           int yyxbegin = yyn < 0 ? -yyn : 0;
1172           /* Stay within bounds of both yycheck and yytname.  */
1173           int yychecklim = YYLAST - yyn + 1;
1174           int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1175           int yyx;
1176 
1177           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1178             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1179                 && !yytable_value_is_error (yytable[yyx + yyn]))
1180               {
1181                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1182                   {
1183                     yycount = 1;
1184                     yysize = yysize0;
1185                     break;
1186                   }
1187                 yyarg[yycount++] = yytname[yyx];
1188                 yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1189                 if (! (yysize <= yysize1
1190                        && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1191                   return 2;
1192                 yysize = yysize1;
1193               }
1194         }
1195     }
1196 
1197   switch (yycount)
1198     {
1199 # define YYCASE_(N, S)                      \
1200       case N:                               \
1201         yyformat = S;                       \
1202       break
1203       YYCASE_(0, YY_("syntax error"));
1204       YYCASE_(1, YY_("syntax error, unexpected %s"));
1205       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1206       YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1207       YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1208       YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1209 # undef YYCASE_
1210     }
1211 
1212   yysize1 = yysize + yystrlen (yyformat);
1213   if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1214     return 2;
1215   yysize = yysize1;
1216 
1217   if (*yymsg_alloc < yysize)
1218     {
1219       *yymsg_alloc = 2 * yysize;
1220       if (! (yysize <= *yymsg_alloc
1221              && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1222         *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1223       return 1;
1224     }
1225 
1226   /* Avoid sprintf, as that infringes on the user's name space.
1227      Don't have undefined behavior even if the translation
1228      produced a string with the wrong number of "%s"s.  */
1229   {
1230     char *yyp = *yymsg;
1231     int yyi = 0;
1232     while ((*yyp = *yyformat) != '\0')
1233       if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1234         {
1235           yyp += yytnamerr (yyp, yyarg[yyi++]);
1236           yyformat += 2;
1237         }
1238       else
1239         {
1240           yyp++;
1241           yyformat++;
1242         }
1243   }
1244   return 0;
1245 }
1246 #endif /* YYERROR_VERBOSE */
1247 
1248 /*-----------------------------------------------.
1249 | Release the memory associated to this symbol.  |
1250 `-----------------------------------------------*/
1251 
1252 /*ARGSUSED*/
1253 #if (defined __STDC__ || defined __C99__FUNC__ \
1254      || defined __cplusplus || defined _MSC_VER)
1255 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep)1256 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1257 #else
1258 static void
1259 yydestruct (yymsg, yytype, yyvaluep)
1260     const char *yymsg;
1261     int yytype;
1262     YYSTYPE *yyvaluep;
1263 #endif
1264 {
1265   YYUSE (yyvaluep);
1266 
1267   if (!yymsg)
1268     yymsg = "Deleting";
1269   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1270 
1271   switch (yytype)
1272     {
1273 
1274       default:
1275 	break;
1276     }
1277 }
1278 
1279 
1280 
1281 
1282 /* The lookahead symbol.  */
1283 int yychar;
1284 
1285 /* The semantic value of the lookahead symbol.  */
1286 YYSTYPE yylval;
1287 
1288 /* Number of syntax errors so far.  */
1289 int yynerrs;
1290 
1291 
1292 /*----------.
1293 | yyparse.  |
1294 `----------*/
1295 
1296 #ifdef YYPARSE_PARAM
1297 #if (defined __STDC__ || defined __C99__FUNC__ \
1298      || defined __cplusplus || defined _MSC_VER)
1299 int
yyparse(void * YYPARSE_PARAM)1300 yyparse (void *YYPARSE_PARAM)
1301 #else
1302 int
1303 yyparse (YYPARSE_PARAM)
1304     void *YYPARSE_PARAM;
1305 #endif
1306 #else /* ! YYPARSE_PARAM */
1307 #if (defined __STDC__ || defined __C99__FUNC__ \
1308      || defined __cplusplus || defined _MSC_VER)
1309 int
1310 yyparse (void)
1311 #else
1312 int
1313 yyparse ()
1314 
1315 #endif
1316 #endif
1317 {
1318     int yystate;
1319     /* Number of tokens to shift before error messages enabled.  */
1320     int yyerrstatus;
1321 
1322     /* The stacks and their tools:
1323        `yyss': related to states.
1324        `yyvs': related to semantic values.
1325 
1326        Refer to the stacks through separate pointers, to allow yyoverflow
1327        to reallocate them elsewhere.  */
1328 
1329     /* The state stack.  */
1330     yytype_int16 yyssa[YYINITDEPTH];
1331     yytype_int16 *yyss;
1332     yytype_int16 *yyssp;
1333 
1334     /* The semantic value stack.  */
1335     YYSTYPE yyvsa[YYINITDEPTH];
1336     YYSTYPE *yyvs;
1337     YYSTYPE *yyvsp;
1338 
1339     YYSIZE_T yystacksize;
1340 
1341   int yyn;
1342   int yyresult;
1343   /* Lookahead token as an internal (translated) token number.  */
1344   int yytoken;
1345   /* The variables used to return semantic value and location from the
1346      action routines.  */
1347   YYSTYPE yyval;
1348 
1349 #if YYERROR_VERBOSE
1350   /* Buffer for error messages, and its allocated size.  */
1351   char yymsgbuf[128];
1352   char *yymsg = yymsgbuf;
1353   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1354 #endif
1355 
1356 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1357 
1358   /* The number of symbols on the RHS of the reduced rule.
1359      Keep to zero when no symbol should be popped.  */
1360   int yylen = 0;
1361 
1362   yytoken = 0;
1363   yyss = yyssa;
1364   yyvs = yyvsa;
1365   yystacksize = YYINITDEPTH;
1366 
1367   YYDPRINTF ((stderr, "Starting parse\n"));
1368 
1369   yystate = 0;
1370   yyerrstatus = 0;
1371   yynerrs = 0;
1372   yychar = YYEMPTY; /* Cause a token to be read.  */
1373 
1374   /* Initialize stack pointers.
1375      Waste one element of value and location stack
1376      so that they stay on the same level as the state stack.
1377      The wasted elements are never initialized.  */
1378   yyssp = yyss;
1379   yyvsp = yyvs;
1380   goto yysetstate;
1381 
1382 /*------------------------------------------------------------.
1383 | yynewstate -- Push a new state, which is found in yystate.  |
1384 `------------------------------------------------------------*/
1385  yynewstate:
1386   /* In all cases, when you get here, the value and location stacks
1387      have just been pushed.  So pushing a state here evens the stacks.  */
1388   yyssp++;
1389 
1390  yysetstate:
1391   *yyssp = yystate;
1392 
1393   if (yyss + yystacksize - 1 <= yyssp)
1394     {
1395       /* Get the current used size of the three stacks, in elements.  */
1396       YYSIZE_T yysize = yyssp - yyss + 1;
1397 
1398 #ifdef yyoverflow
1399       {
1400 	/* Give user a chance to reallocate the stack.  Use copies of
1401 	   these so that the &'s don't force the real ones into
1402 	   memory.  */
1403 	YYSTYPE *yyvs1 = yyvs;
1404 	yytype_int16 *yyss1 = yyss;
1405 
1406 	/* Each stack pointer address is followed by the size of the
1407 	   data in use in that stack, in bytes.  This used to be a
1408 	   conditional around just the two extra args, but that might
1409 	   be undefined if yyoverflow is a macro.  */
1410 	yyoverflow (YY_("memory exhausted"),
1411 		    &yyss1, yysize * sizeof (*yyssp),
1412 		    &yyvs1, yysize * sizeof (*yyvsp),
1413 		    &yystacksize);
1414 
1415 	yyss = yyss1;
1416 	yyvs = yyvs1;
1417       }
1418 #else /* no yyoverflow */
1419 # ifndef YYSTACK_RELOCATE
1420       goto yyexhaustedlab;
1421 # else
1422       /* Extend the stack our own way.  */
1423       if (YYMAXDEPTH <= yystacksize)
1424 	goto yyexhaustedlab;
1425       yystacksize *= 2;
1426       if (YYMAXDEPTH < yystacksize)
1427 	yystacksize = YYMAXDEPTH;
1428 
1429       {
1430 	yytype_int16 *yyss1 = yyss;
1431 	union yyalloc *yyptr =
1432 	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1433 	if (! yyptr)
1434 	  goto yyexhaustedlab;
1435 	YYSTACK_RELOCATE (yyss_alloc, yyss);
1436 	YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1437 #  undef YYSTACK_RELOCATE
1438 	if (yyss1 != yyssa)
1439 	  YYSTACK_FREE (yyss1);
1440       }
1441 # endif
1442 #endif /* no yyoverflow */
1443 
1444       yyssp = yyss + yysize - 1;
1445       yyvsp = yyvs + yysize - 1;
1446 
1447       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1448 		  (unsigned long int) yystacksize));
1449 
1450       if (yyss + yystacksize - 1 <= yyssp)
1451 	YYABORT;
1452     }
1453 
1454   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1455 
1456   if (yystate == YYFINAL)
1457     YYACCEPT;
1458 
1459   goto yybackup;
1460 
1461 /*-----------.
1462 | yybackup.  |
1463 `-----------*/
1464 yybackup:
1465 
1466   /* Do appropriate processing given the current state.  Read a
1467      lookahead token if we need one and don't already have one.  */
1468 
1469   /* First try to decide what to do without reference to lookahead token.  */
1470   yyn = yypact[yystate];
1471   if (yypact_value_is_default (yyn))
1472     goto yydefault;
1473 
1474   /* Not known => get a lookahead token if don't already have one.  */
1475 
1476   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1477   if (yychar == YYEMPTY)
1478     {
1479       YYDPRINTF ((stderr, "Reading a token: "));
1480       yychar = YYLEX;
1481     }
1482 
1483   if (yychar <= YYEOF)
1484     {
1485       yychar = yytoken = YYEOF;
1486       YYDPRINTF ((stderr, "Now at end of input.\n"));
1487     }
1488   else
1489     {
1490       yytoken = YYTRANSLATE (yychar);
1491       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1492     }
1493 
1494   /* If the proper action on seeing token YYTOKEN is to reduce or to
1495      detect an error, take that action.  */
1496   yyn += yytoken;
1497   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1498     goto yydefault;
1499   yyn = yytable[yyn];
1500   if (yyn <= 0)
1501     {
1502       if (yytable_value_is_error (yyn))
1503         goto yyerrlab;
1504       yyn = -yyn;
1505       goto yyreduce;
1506     }
1507 
1508   /* Count tokens shifted since error; after three, turn off error
1509      status.  */
1510   if (yyerrstatus)
1511     yyerrstatus--;
1512 
1513   /* Shift the lookahead token.  */
1514   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1515 
1516   /* Discard the shifted token.  */
1517   yychar = YYEMPTY;
1518 
1519   yystate = yyn;
1520   *++yyvsp = yylval;
1521 
1522   goto yynewstate;
1523 
1524 
1525 /*-----------------------------------------------------------.
1526 | yydefault -- do the default action for the current state.  |
1527 `-----------------------------------------------------------*/
1528 yydefault:
1529   yyn = yydefact[yystate];
1530   if (yyn == 0)
1531     goto yyerrlab;
1532   goto yyreduce;
1533 
1534 
1535 /*-----------------------------.
1536 | yyreduce -- Do a reduction.  |
1537 `-----------------------------*/
1538 yyreduce:
1539   /* yyn is the number of a rule to reduce with.  */
1540   yylen = yyr2[yyn];
1541 
1542   /* If YYLEN is nonzero, implement the default value of the action:
1543      `$$ = $1'.
1544 
1545      Otherwise, the following line sets YYVAL to garbage.
1546      This behavior is undocumented and Bison
1547      users should not rely upon it.  Assigning to YYVAL
1548      unconditionally makes the parser a bit smaller, and it avoids a
1549      GCC warning that YYVAL may be used uninitialized.  */
1550   yyval = yyvsp[1-yylen];
1551 
1552 
1553   YY_REDUCE_PRINT (yyn);
1554   switch (yyn)
1555     {
1556         case 3:
1557 /* Line 1787 of yacc.c  */
1558 #line 70 "imap_csim.y"
1559     {
1560 		   g_strreplace(&_map_info->image_name, (yyvsp[(5) - (7)].id));
1561 		   g_free ((yyvsp[(5) - (7)].id));
1562 		}
1563     break;
1564 
1565   case 8:
1566 /* Line 1787 of yacc.c  */
1567 #line 82 "imap_csim.y"
1568     {}
1569     break;
1570 
1571   case 9:
1572 /* Line 1787 of yacc.c  */
1573 #line 83 "imap_csim.y"
1574     { g_free ((yyvsp[(3) - (3)].id)); }
1575     break;
1576 
1577   case 10:
1578 /* Line 1787 of yacc.c  */
1579 #line 84 "imap_csim.y"
1580     { g_free ((yyvsp[(3) - (3)].id)); }
1581     break;
1582 
1583   case 11:
1584 /* Line 1787 of yacc.c  */
1585 #line 88 "imap_csim.y"
1586     {
1587 		   _map_info->old_image_width = (yyvsp[(3) - (3)].val);
1588 		}
1589     break;
1590 
1591   case 12:
1592 /* Line 1787 of yacc.c  */
1593 #line 94 "imap_csim.y"
1594     {
1595 		   _map_info->old_image_height = (yyvsp[(3) - (3)].val);
1596 		}
1597     break;
1598 
1599   case 13:
1600 /* Line 1787 of yacc.c  */
1601 #line 100 "imap_csim.y"
1602     {
1603 		  (yyval.val) = (gint) (yyvsp[(1) - (1)].value);
1604 		}
1605     break;
1606 
1607   case 14:
1608 /* Line 1787 of yacc.c  */
1609 #line 104 "imap_csim.y"
1610     {
1611 		  (yyval.val) = (gint) g_ascii_strtod ((yyvsp[(1) - (1)].id), NULL);
1612 		  g_free ((yyvsp[(1) - (1)].id));
1613 		}
1614     break;
1615 
1616   case 15:
1617 /* Line 1787 of yacc.c  */
1618 #line 111 "imap_csim.y"
1619     {
1620 		   g_strreplace(&_map_info->title, (yyvsp[(5) - (6)].id));
1621 		   g_free ((yyvsp[(5) - (6)].id));
1622 		}
1623     break;
1624 
1625   case 21:
1626 /* Line 1787 of yacc.c  */
1627 #line 127 "imap_csim.y"
1628     {
1629 		  g_free ((yyvsp[(2) - (3)].id));
1630 		}
1631     break;
1632 
1633   case 22:
1634 /* Line 1787 of yacc.c  */
1635 #line 133 "imap_csim.y"
1636     {
1637 		   g_strreplace(&_map_info->author, (yyvsp[(2) - (3)].id));
1638 		   g_free ((yyvsp[(2) - (3)].id));
1639 		}
1640     break;
1641 
1642   case 23:
1643 /* Line 1787 of yacc.c  */
1644 #line 140 "imap_csim.y"
1645     {
1646 		   gchar *description;
1647 
1648 		   description = g_strconcat(_map_info->description, (yyvsp[(2) - (3)].id), "\n",
1649 					     NULL);
1650 		   g_strreplace(&_map_info->description, description);
1651 		   g_free ((yyvsp[(2) - (3)].id));
1652 		}
1653     break;
1654 
1655   case 26:
1656 /* Line 1787 of yacc.c  */
1657 #line 155 "imap_csim.y"
1658     {
1659 		   if (current_type != UNDEFINED)
1660 		      add_shape(current_object);
1661 		}
1662     break;
1663 
1664   case 41:
1665 /* Line 1787 of yacc.c  */
1666 #line 182 "imap_csim.y"
1667     {
1668 		   if (!g_ascii_strcasecmp((yyvsp[(3) - (3)].id), "RECT")) {
1669 		      current_object = create_rectangle(0, 0, 0, 0);
1670 		      current_type = RECTANGLE;
1671 		   } else if (!g_ascii_strcasecmp((yyvsp[(3) - (3)].id), "CIRCLE")) {
1672 		      current_object = create_circle(0, 0, 0);
1673 		      current_type = CIRCLE;
1674 		   } else if (!g_ascii_strcasecmp((yyvsp[(3) - (3)].id), "POLY")) {
1675 		      current_object = create_polygon(NULL);
1676 		      current_type = POLYGON;
1677 		   } else if (!g_ascii_strcasecmp((yyvsp[(3) - (3)].id), "DEFAULT")) {
1678 		      current_type = UNDEFINED;
1679 		   }
1680 		   g_free ((yyvsp[(3) - (3)].id));
1681 		}
1682     break;
1683 
1684   case 42:
1685 /* Line 1787 of yacc.c  */
1686 #line 200 "imap_csim.y"
1687     {
1688 		   char *p;
1689 		   if (current_type == RECTANGLE) {
1690 		      Rectangle_t *rectangle;
1691 
1692 		      rectangle = ObjectToRectangle(current_object);
1693 		      p = strtok((yyvsp[(3) - (3)].id), ",");
1694 		      rectangle->x = atoi(p);
1695 		      p = strtok(NULL, ",");
1696 		      rectangle->y = atoi(p);
1697 		      p = strtok(NULL, ",");
1698 		      rectangle->width = atoi(p) - rectangle->x;
1699 		      p = strtok(NULL, ",");
1700 		      rectangle->height = atoi(p) - rectangle->y;
1701 		   } else if (current_type == CIRCLE) {
1702 		      Circle_t *circle;
1703 
1704 		      circle = ObjectToCircle(current_object);
1705 		      p = strtok((yyvsp[(3) - (3)].id), ",");
1706 		      circle->x = atoi(p);
1707 		      p = strtok(NULL, ",");
1708 		      circle->y = atoi(p);
1709 		      p = strtok(NULL, ",");
1710 		      circle->r = atoi(p);
1711 		   } else if (current_type == POLYGON) {
1712 		      Polygon_t *polygon = ObjectToPolygon(current_object);
1713 		      GList *points;
1714 		      GdkPoint *point, *first;
1715 		      gint x, y;
1716 
1717 		      p = strtok((yyvsp[(3) - (3)].id), ",");
1718 		      x = atoi(p);
1719 		      p = strtok(NULL, ",");
1720 		      y = atoi(p);
1721 		      point = new_point(x, y);
1722 		      points = g_list_append(NULL, (gpointer) point);
1723 
1724 		      while(1) {
1725 			 p = strtok(NULL, ",");
1726 			 if (!p)
1727 			    break;
1728 			 x = atoi(p);
1729 			 p = strtok(NULL, ",");
1730 			 y = atoi(p);
1731 			 point = new_point(x, y);
1732 			 points = g_list_append(points, (gpointer) point);
1733 		      }
1734 		      /* Remove last point if duplicate */
1735 		      first = (GdkPoint*) points->data;
1736 		      polygon->points = points;
1737 		      if (first->x == point->x && first->y == point->y)
1738 			 polygon_remove_last_point(polygon);
1739 		      polygon->points = points;
1740 		   }
1741 
1742 		   g_free ((yyvsp[(3) - (3)].id));
1743 		}
1744     break;
1745 
1746   case 43:
1747 /* Line 1787 of yacc.c  */
1748 #line 260 "imap_csim.y"
1749     {
1750 		   if (current_type == UNDEFINED) {
1751 		      g_strreplace(&_map_info->default_url, (yyvsp[(3) - (3)].id));
1752 		   } else {
1753 		      object_set_url(current_object, unescape_text((yyvsp[(3) - (3)].id)));
1754 		   }
1755 		   g_free ((yyvsp[(3) - (3)].id));
1756 		}
1757     break;
1758 
1759   case 44:
1760 /* Line 1787 of yacc.c  */
1761 #line 271 "imap_csim.y"
1762     {
1763 		}
1764     break;
1765 
1766   case 46:
1767 /* Line 1787 of yacc.c  */
1768 #line 277 "imap_csim.y"
1769     {
1770 		   g_free ((yyvsp[(2) - (2)].id));
1771 		}
1772     break;
1773 
1774   case 47:
1775 /* Line 1787 of yacc.c  */
1776 #line 283 "imap_csim.y"
1777     {
1778 		   object_set_comment(current_object, unescape_text((yyvsp[(3) - (3)].id)));
1779 		   g_free ((yyvsp[(3) - (3)].id));
1780 		}
1781     break;
1782 
1783   case 48:
1784 /* Line 1787 of yacc.c  */
1785 #line 290 "imap_csim.y"
1786     {
1787 		   object_set_target(current_object, unescape_text((yyvsp[(3) - (3)].id)));
1788 		   g_free ((yyvsp[(3) - (3)].id));
1789 		}
1790     break;
1791 
1792   case 49:
1793 /* Line 1787 of yacc.c  */
1794 #line 297 "imap_csim.y"
1795     {
1796 		   object_set_mouse_over(current_object, unescape_text((yyvsp[(3) - (3)].id)));
1797 		   g_free ((yyvsp[(3) - (3)].id));
1798 		}
1799     break;
1800 
1801   case 50:
1802 /* Line 1787 of yacc.c  */
1803 #line 304 "imap_csim.y"
1804     {
1805 		   object_set_mouse_out(current_object, unescape_text((yyvsp[(3) - (3)].id)));
1806 		   g_free ((yyvsp[(3) - (3)].id));
1807 		}
1808     break;
1809 
1810   case 51:
1811 /* Line 1787 of yacc.c  */
1812 #line 311 "imap_csim.y"
1813     {
1814 		   object_set_focus(current_object, unescape_text((yyvsp[(3) - (3)].id)));
1815 		   g_free ((yyvsp[(3) - (3)].id));
1816 		}
1817     break;
1818 
1819   case 52:
1820 /* Line 1787 of yacc.c  */
1821 #line 318 "imap_csim.y"
1822     {
1823 		   object_set_blur(current_object, unescape_text((yyvsp[(3) - (3)].id)));
1824 		   g_free ((yyvsp[(3) - (3)].id));
1825 		}
1826     break;
1827 
1828 
1829 /* Line 1787 of yacc.c  */
1830 #line 1831 "y.tab.c"
1831       default: break;
1832     }
1833   /* User semantic actions sometimes alter yychar, and that requires
1834      that yytoken be updated with the new translation.  We take the
1835      approach of translating immediately before every use of yytoken.
1836      One alternative is translating here after every semantic action,
1837      but that translation would be missed if the semantic action invokes
1838      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1839      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
1840      incorrect destructor might then be invoked immediately.  In the
1841      case of YYERROR or YYBACKUP, subsequent parser actions might lead
1842      to an incorrect destructor call or verbose syntax error message
1843      before the lookahead is translated.  */
1844   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1845 
1846   YYPOPSTACK (yylen);
1847   yylen = 0;
1848   YY_STACK_PRINT (yyss, yyssp);
1849 
1850   *++yyvsp = yyval;
1851 
1852   /* Now `shift' the result of the reduction.  Determine what state
1853      that goes to, based on the state we popped back to and the rule
1854      number reduced by.  */
1855 
1856   yyn = yyr1[yyn];
1857 
1858   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1859   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1860     yystate = yytable[yystate];
1861   else
1862     yystate = yydefgoto[yyn - YYNTOKENS];
1863 
1864   goto yynewstate;
1865 
1866 
1867 /*------------------------------------.
1868 | yyerrlab -- here on detecting error |
1869 `------------------------------------*/
1870 yyerrlab:
1871   /* Make sure we have latest lookahead translation.  See comments at
1872      user semantic actions for why this is necessary.  */
1873   yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1874 
1875   /* If not already recovering from an error, report this error.  */
1876   if (!yyerrstatus)
1877     {
1878       ++yynerrs;
1879 #if ! YYERROR_VERBOSE
1880       yyerror (YY_("syntax error"));
1881 #else
1882 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1883                                         yyssp, yytoken)
1884       {
1885         char const *yymsgp = YY_("syntax error");
1886         int yysyntax_error_status;
1887         yysyntax_error_status = YYSYNTAX_ERROR;
1888         if (yysyntax_error_status == 0)
1889           yymsgp = yymsg;
1890         else if (yysyntax_error_status == 1)
1891           {
1892             if (yymsg != yymsgbuf)
1893               YYSTACK_FREE (yymsg);
1894             yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1895             if (!yymsg)
1896               {
1897                 yymsg = yymsgbuf;
1898                 yymsg_alloc = sizeof yymsgbuf;
1899                 yysyntax_error_status = 2;
1900               }
1901             else
1902               {
1903                 yysyntax_error_status = YYSYNTAX_ERROR;
1904                 yymsgp = yymsg;
1905               }
1906           }
1907         yyerror (yymsgp);
1908         if (yysyntax_error_status == 2)
1909           goto yyexhaustedlab;
1910       }
1911 # undef YYSYNTAX_ERROR
1912 #endif
1913     }
1914 
1915 
1916 
1917   if (yyerrstatus == 3)
1918     {
1919       /* If just tried and failed to reuse lookahead token after an
1920 	 error, discard it.  */
1921 
1922       if (yychar <= YYEOF)
1923 	{
1924 	  /* Return failure if at end of input.  */
1925 	  if (yychar == YYEOF)
1926 	    YYABORT;
1927 	}
1928       else
1929 	{
1930 	  yydestruct ("Error: discarding",
1931 		      yytoken, &yylval);
1932 	  yychar = YYEMPTY;
1933 	}
1934     }
1935 
1936   /* Else will try to reuse lookahead token after shifting the error
1937      token.  */
1938   goto yyerrlab1;
1939 
1940 
1941 /*---------------------------------------------------.
1942 | yyerrorlab -- error raised explicitly by YYERROR.  |
1943 `---------------------------------------------------*/
1944 yyerrorlab:
1945 
1946   /* Pacify compilers like GCC when the user code never invokes
1947      YYERROR and the label yyerrorlab therefore never appears in user
1948      code.  */
1949   if (/*CONSTCOND*/ 0)
1950      goto yyerrorlab;
1951 
1952   /* Do not reclaim the symbols of the rule which action triggered
1953      this YYERROR.  */
1954   YYPOPSTACK (yylen);
1955   yylen = 0;
1956   YY_STACK_PRINT (yyss, yyssp);
1957   yystate = *yyssp;
1958   goto yyerrlab1;
1959 
1960 
1961 /*-------------------------------------------------------------.
1962 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1963 `-------------------------------------------------------------*/
1964 yyerrlab1:
1965   yyerrstatus = 3;	/* Each real token shifted decrements this.  */
1966 
1967   for (;;)
1968     {
1969       yyn = yypact[yystate];
1970       if (!yypact_value_is_default (yyn))
1971 	{
1972 	  yyn += YYTERROR;
1973 	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1974 	    {
1975 	      yyn = yytable[yyn];
1976 	      if (0 < yyn)
1977 		break;
1978 	    }
1979 	}
1980 
1981       /* Pop the current state because it cannot handle the error token.  */
1982       if (yyssp == yyss)
1983 	YYABORT;
1984 
1985 
1986       yydestruct ("Error: popping",
1987 		  yystos[yystate], yyvsp);
1988       YYPOPSTACK (1);
1989       yystate = *yyssp;
1990       YY_STACK_PRINT (yyss, yyssp);
1991     }
1992 
1993   *++yyvsp = yylval;
1994 
1995 
1996   /* Shift the error token.  */
1997   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1998 
1999   yystate = yyn;
2000   goto yynewstate;
2001 
2002 
2003 /*-------------------------------------.
2004 | yyacceptlab -- YYACCEPT comes here.  |
2005 `-------------------------------------*/
2006 yyacceptlab:
2007   yyresult = 0;
2008   goto yyreturn;
2009 
2010 /*-----------------------------------.
2011 | yyabortlab -- YYABORT comes here.  |
2012 `-----------------------------------*/
2013 yyabortlab:
2014   yyresult = 1;
2015   goto yyreturn;
2016 
2017 #if !defined yyoverflow || YYERROR_VERBOSE
2018 /*-------------------------------------------------.
2019 | yyexhaustedlab -- memory exhaustion comes here.  |
2020 `-------------------------------------------------*/
2021 yyexhaustedlab:
2022   yyerror (YY_("memory exhausted"));
2023   yyresult = 2;
2024   /* Fall through.  */
2025 #endif
2026 
2027 yyreturn:
2028   if (yychar != YYEMPTY)
2029     {
2030       /* Make sure we have latest lookahead translation.  See comments at
2031          user semantic actions for why this is necessary.  */
2032       yytoken = YYTRANSLATE (yychar);
2033       yydestruct ("Cleanup: discarding lookahead",
2034                   yytoken, &yylval);
2035     }
2036   /* Do not reclaim the symbols of the rule which action triggered
2037      this YYABORT or YYACCEPT.  */
2038   YYPOPSTACK (yylen);
2039   YY_STACK_PRINT (yyss, yyssp);
2040   while (yyssp != yyss)
2041     {
2042       yydestruct ("Cleanup: popping",
2043 		  yystos[*yyssp], yyvsp);
2044       YYPOPSTACK (1);
2045     }
2046 #ifndef yyoverflow
2047   if (yyss != yyssa)
2048     YYSTACK_FREE (yyss);
2049 #endif
2050 #if YYERROR_VERBOSE
2051   if (yymsg != yymsgbuf)
2052     YYSTACK_FREE (yymsg);
2053 #endif
2054   /* Make sure YYID is used.  */
2055   return YYID (yyresult);
2056 }
2057 
2058 
2059 /* Line 2048 of yacc.c  */
2060 #line 327 "imap_csim.y"
2061 
2062 
2063 static void
csim_error(char * s)2064 csim_error(char* s)
2065 {
2066    extern FILE *csim_in;
2067    csim_restart(csim_in);
2068 }
2069 
2070 gboolean
load_csim(const char * filename)2071 load_csim (const char* filename)
2072 {
2073   gboolean status;
2074   extern FILE *csim_in;
2075   csim_in = g_fopen(filename, "r");
2076   if (csim_in) {
2077     _map_info = get_map_info();
2078     status = !csim_parse();
2079     fclose(csim_in);
2080   } else {
2081     status = FALSE;
2082   }
2083   return status;
2084 }
2085 
2086 static gchar*
unescape_text(gchar * input)2087 unescape_text (gchar *input)
2088 {
2089  /*
2090   * We "unescape" simple things "in place", knowing that unescaped
2091   * strings always are shorter than the original input.
2092   *
2093   * It is a shame there is no g_markup_unescape_text() function, but
2094   * instead you have to create a full GMarkupParser/Context.
2095   */
2096   struct token {
2097     const char *escaped;
2098     const char  unescaped;
2099   };
2100   const struct token tab[] = {
2101     { "&quot;", '"'  },
2102     { "&apos;", '\'' },
2103     { "&amp;",  '&'  },
2104     { "&lt;",   '<'  },
2105     { "&gt;",   '>'  }
2106   };
2107 
2108   size_t i;
2109   for (i = 0; i < (sizeof tab / sizeof tab[0]); i++)
2110     {
2111       const size_t escaped_len = strlen (tab[i].escaped);
2112       char *p;
2113 
2114       /* FIXME: The following code does not perform a UTF-8 substring
2115          search. */
2116       for (p = strstr (input, tab[i].escaped);
2117            p != NULL;
2118            p = strstr (p, tab[i].escaped))
2119         {
2120           size_t copy_len;
2121           *p++ = tab[i].unescaped;
2122           copy_len = strlen (p) - escaped_len + 2;
2123           memmove (p, p + escaped_len - 1, copy_len);
2124           if (*p == 0)
2125             break;
2126         }
2127     }
2128 
2129   return input;
2130 }
2131 
2132