Graphviz  2.41.20171026.1811
y.tab.c
Go to the documentation of this file.
1 /* A Bison parser, made by GNU Bison 2.7. */
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 <http://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.7"
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 
63 
64 /* Copy the first part of user declarations. */
65 /* Line 371 of yacc.c */
66 #line 14 "../../lib/cgraph/grammar.y"
67 
68 
69 #include <stdio.h> /* SAFE */
70 #include <cghdr.h> /* SAFE */
71 extern void yyerror(char *); /* gets mapped to aagerror, see below */
72 
73 #ifdef _WIN32
74 #define gettxt(a,b) (b)
75 #endif
76 
77 static char Key[] = "key";
78 
79 typedef union s { /* possible items in generic list */
80  Agnode_t *n;
81  Agraph_t *subg;
82  Agedge_t *e;
83  Agsym_t *asym; /* bound attribute */
84  char *name; /* unbound attribute */
85  struct item_s *list; /* list-of-lists (for edgestmt) */
86 } val_t;
87 
88 typedef struct item_s { /* generic list */
89  int tag; /* T_node, T_subgraph, T_edge, T_attr */
90  val_t u; /* primary element */
91  char *str; /* secondary value - port or attr value */
92  struct item_s *next;
93 } item;
94 
95 typedef struct list_s { /* maintain head and tail ptrs for fast append */
96  item *first;
97  item *last;
98 } list_t;
99 
100 typedef struct gstack_s {
101  Agraph_t *g;
102  Agraph_t *subg;
104  struct gstack_s *down;
105 } gstack_t;
106 
107 /* functions */
108 static void appendnode(char *name, char *port, char *sport);
109 static void attrstmt(int tkind, char *macroname);
110 static void startgraph(char *name, int directed, int strict);
111 static void getedgeitems(int x);
112 static void newedge(Agnode_t *t, char *tport, Agnode_t *h, char *hport, char *key);
113 static void edgerhs(Agnode_t *n, char *tport, item *hlist, char *key);
114 static void appendattr(char *name, char *value);
115 static void bindattrs(int kind);
116 static void applyattrs(void *obj);
117 static void endgraph(void);
118 static void endnode(void);
119 static void endedge(void);
120 static void freestack(void);
121 static char* concat(char*, char*);
122 static char* concatPort(char*, char*);
123 
124 static void opensubg(char *name);
125 static void closesubg(void);
126 
127 /* global */
128 static Agraph_t *G; /* top level graph */
129 static Agdisc_t *Disc; /* discipline passed to agread or agconcat */
130 static gstack_t *S;
131 
132 
133 /* Line 371 of yacc.c */
134 #line 135 "y.tab.c"
135 
136 # ifndef YY_NULL
137 # if defined __cplusplus && 201103L <= __cplusplus
138 # define YY_NULL nullptr
139 # else
140 # define YY_NULL 0
141 # endif
142 # endif
143 
144 /* Enabling verbose error messages. */
145 #ifdef YYERROR_VERBOSE
146 # undef YYERROR_VERBOSE
147 # define YYERROR_VERBOSE 1
148 #else
149 # define YYERROR_VERBOSE 0
150 #endif
151 
152 /* In a future release of Bison, this section will be replaced
153  by #include "y.tab.h". */
154 #ifndef YY_YY_Y_TAB_H_INCLUDED
155 # define YY_YY_Y_TAB_H_INCLUDED
156 /* Enabling traces. */
157 #ifndef YYDEBUG
158 # define YYDEBUG 0
159 #endif
160 #if YYDEBUG
161 extern int yydebug;
162 #endif
163 
164 /* Tokens. */
165 #ifndef YYTOKENTYPE
166 # define YYTOKENTYPE
167  /* Put the tokens into the symbol table, so that GDB and other debuggers
168  know about them. */
169  enum yytokentype {
170  T_graph = 258,
171  T_node = 259,
172  T_edge = 260,
173  T_digraph = 261,
174  T_subgraph = 262,
175  T_strict = 263,
176  T_edgeop = 264,
177  T_list = 265,
178  T_attr = 266,
179  T_atom = 267,
180  T_qatom = 268
181  };
182 #endif
183 /* Tokens. */
184 #define T_graph 258
185 #define T_node 259
186 #define T_edge 260
187 #define T_digraph 261
188 #define T_subgraph 262
189 #define T_strict 263
190 #define T_edgeop 264
191 #define T_list 265
192 #define T_attr 266
193 #define T_atom 267
194 #define T_qatom 268
195 
196 
197 
198 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
199 typedef union YYSTYPE
200 {
201 /* Line 387 of yacc.c */
202 #line 81 "../../lib/cgraph/grammar.y"
203 
204  int i;
205  char *str;
206  struct Agnode_s *n;
207 
208 
209 /* Line 387 of yacc.c */
210 #line 211 "y.tab.c"
211 } YYSTYPE;
212 # define YYSTYPE_IS_TRIVIAL 1
213 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
214 # define YYSTYPE_IS_DECLARED 1
215 #endif
216 
217 extern YYSTYPE yylval;
218 
219 #ifdef YYPARSE_PARAM
220 #if defined __STDC__ || defined __cplusplus
221 int yyparse (void *YYPARSE_PARAM);
222 #else
223 int yyparse ();
224 #endif
225 #else /* ! YYPARSE_PARAM */
226 #if defined __STDC__ || defined __cplusplus
227 int yyparse (void);
228 #else
229 int yyparse ();
230 #endif
231 #endif /* ! YYPARSE_PARAM */
232 
233 #endif /* !YY_YY_Y_TAB_H_INCLUDED */
234 
235 /* Copy the second part of user declarations. */
236 
237 /* Line 390 of yacc.c */
238 #line 239 "y.tab.c"
239 
240 #ifdef short
241 # undef short
242 #endif
243 
244 #ifdef YYTYPE_UINT8
245 typedef YYTYPE_UINT8 yytype_uint8;
246 #else
247 typedef unsigned char yytype_uint8;
248 #endif
249 
250 #ifdef YYTYPE_INT8
251 typedef YYTYPE_INT8 yytype_int8;
252 #elif (defined __STDC__ || defined __C99__FUNC__ \
253  || defined __cplusplus || defined _MSC_VER)
254 typedef signed char yytype_int8;
255 #else
256 typedef short int yytype_int8;
257 #endif
258 
259 #ifdef YYTYPE_UINT16
260 typedef YYTYPE_UINT16 yytype_uint16;
261 #else
262 typedef unsigned short int yytype_uint16;
263 #endif
264 
265 #ifdef YYTYPE_INT16
266 typedef YYTYPE_INT16 yytype_int16;
267 #else
268 typedef short int yytype_int16;
269 #endif
270 
271 #ifndef YYSIZE_T
272 # ifdef __SIZE_TYPE__
273 # define YYSIZE_T __SIZE_TYPE__
274 # elif defined size_t
275 # define YYSIZE_T size_t
276 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
277  || defined __cplusplus || defined _MSC_VER)
278 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
279 # define YYSIZE_T size_t
280 # else
281 # define YYSIZE_T unsigned int
282 # endif
283 #endif
284 
285 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
286 
287 #ifndef YY_
288 # if defined YYENABLE_NLS && YYENABLE_NLS
289 # if ENABLE_NLS
290 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
291 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
292 # endif
293 # endif
294 # ifndef YY_
295 # define YY_(Msgid) Msgid
296 # endif
297 #endif
298 
299 /* Suppress unused-variable warnings by "using" E. */
300 #if ! defined lint || defined __GNUC__
301 # define YYUSE(E) ((void) (E))
302 #else
303 # define YYUSE(E) /* empty */
304 #endif
305 
306 /* Identity function, used to suppress warnings about constant conditions. */
307 #ifndef lint
308 # define YYID(N) (N)
309 #else
310 #if (defined __STDC__ || defined __C99__FUNC__ \
311  || defined __cplusplus || defined _MSC_VER)
312 static int
313 YYID (int yyi)
314 #else
315 static int
316 YYID (yyi)
317  int yyi;
318 #endif
319 {
320  return yyi;
321 }
322 #endif
323 
324 #if ! defined yyoverflow || YYERROR_VERBOSE
325 
326 /* The parser invokes alloca or malloc; define the necessary symbols. */
327 
328 # ifdef YYSTACK_USE_ALLOCA
329 # if YYSTACK_USE_ALLOCA
330 # ifdef __GNUC__
331 # define YYSTACK_ALLOC __builtin_alloca
332 # elif defined __BUILTIN_VA_ARG_INCR
333 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
334 # elif defined _AIX
335 # define YYSTACK_ALLOC __alloca
336 # elif defined _MSC_VER
337 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
338 # define alloca _alloca
339 # else
340 # define YYSTACK_ALLOC alloca
341 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
342  || defined __cplusplus || defined _MSC_VER)
343 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
344  /* Use EXIT_SUCCESS as a witness for stdlib.h. */
345 # ifndef EXIT_SUCCESS
346 # define EXIT_SUCCESS 0
347 # endif
348 # endif
349 # endif
350 # endif
351 # endif
352 
353 # ifdef YYSTACK_ALLOC
354  /* Pacify GCC's `empty if-body' warning. */
355 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
356 # ifndef YYSTACK_ALLOC_MAXIMUM
357  /* The OS might guarantee only one guard page at the bottom of the stack,
358  and a page size can be as small as 4096 bytes. So we cannot safely
359  invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
360  to allow for a few compiler-allocated temporary stack slots. */
361 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
362 # endif
363 # else
364 # define YYSTACK_ALLOC YYMALLOC
365 # define YYSTACK_FREE YYFREE
366 # ifndef YYSTACK_ALLOC_MAXIMUM
367 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
368 # endif
369 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
370  && ! ((defined YYMALLOC || defined malloc) \
371  && (defined YYFREE || defined free)))
372 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
373 # ifndef EXIT_SUCCESS
374 # define EXIT_SUCCESS 0
375 # endif
376 # endif
377 # ifndef YYMALLOC
378 # define YYMALLOC malloc
379 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
380  || defined __cplusplus || defined _MSC_VER)
381 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
382 # endif
383 # endif
384 # ifndef YYFREE
385 # define YYFREE free
386 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
387  || defined __cplusplus || defined _MSC_VER)
388 void free (void *); /* INFRINGES ON USER NAME SPACE */
389 # endif
390 # endif
391 # endif
392 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
393 
394 
395 #if (! defined yyoverflow \
396  && (! defined __cplusplus \
397  || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
398 
399 /* A type that is properly aligned for any stack member. */
400 union yyalloc
401 {
404 };
405 
406 /* The size of the maximum gap between one aligned stack and the next. */
407 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
408 
409 /* The size of an array large to enough to hold all stacks, each with
410  N elements. */
411 # define YYSTACK_BYTES(N) \
412  ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
413  + YYSTACK_GAP_MAXIMUM)
414 
415 # define YYCOPY_NEEDED 1
416 
417 /* Relocate STACK from its old location to the new one. The
418  local variables YYSIZE and YYSTACKSIZE give the old and new number of
419  elements in the stack, and YYPTR gives the new location of the
420  stack. Advance YYPTR to a properly aligned location for the next
421  stack. */
422 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
423  do \
424  { \
425  YYSIZE_T yynewbytes; \
426  YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
427  Stack = &yyptr->Stack_alloc; \
428  yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
429  yyptr += yynewbytes / sizeof (*yyptr); \
430  } \
431  while (YYID (0))
432 
433 #endif
434 
435 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
436 /* Copy COUNT objects from SRC to DST. The source and destination do
437  not overlap. */
438 # ifndef YYCOPY
439 # if defined __GNUC__ && 1 < __GNUC__
440 # define YYCOPY(Dst, Src, Count) \
441  __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
442 # else
443 # define YYCOPY(Dst, Src, Count) \
444  do \
445  { \
446  YYSIZE_T yyi; \
447  for (yyi = 0; yyi < (Count); yyi++) \
448  (Dst)[yyi] = (Src)[yyi]; \
449  } \
450  while (YYID (0))
451 # endif
452 # endif
453 #endif /* !YYCOPY_NEEDED */
454 
455 /* YYFINAL -- State number of the termination state. */
456 #define YYFINAL 6
457 /* YYLAST -- Last index in YYTABLE. */
458 #define YYLAST 59
459 
460 /* YYNTOKENS -- Number of terminals. */
461 #define YYNTOKENS 24
462 /* YYNNTS -- Number of nonterminals. */
463 #define YYNNTS 35
464 /* YYNRULES -- Number of rules. */
465 #define YYNRULES 62
466 /* YYNRULES -- Number of states. */
467 #define YYNSTATES 80
468 
469 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
470 #define YYUNDEFTOK 2
471 #define YYMAXUTOK 268
472 
473 #define YYTRANSLATE(YYX) \
474  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
475 
476 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
477 static const yytype_uint8 yytranslate[] =
478 {
479  0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
480  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
481  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
482  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
483  2, 2, 2, 23, 17, 2, 2, 2, 2, 2,
484  2, 2, 2, 2, 2, 2, 2, 2, 18, 16,
485  2, 19, 2, 2, 22, 2, 2, 2, 2, 2,
486  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
487  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
488  2, 20, 2, 21, 2, 2, 2, 2, 2, 2,
489  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
490  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
491  2, 2, 2, 14, 2, 15, 2, 2, 2, 2,
492  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
493  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
494  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
495  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
496  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
497  2, 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, 2, 2, 2,
502  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
503  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
504  2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
505  5, 6, 7, 8, 9, 10, 11, 12, 13
506 };
507 
508 #if YYDEBUG
509 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
510  YYRHS. */
511 static const yytype_uint8 yyprhs[] =
512 {
513  0, 0, 3, 6, 8, 9, 13, 17, 19, 20,
514  22, 23, 25, 27, 29, 30, 33, 35, 37, 38,
515  41, 44, 48, 50, 52, 53, 54, 60, 61, 63,
516  67, 69, 73, 79, 83, 85, 87, 89, 91, 94,
517  95, 97, 98, 103, 106, 107, 110, 112, 114, 118,
518  121, 123, 124, 128, 131, 133, 134, 136, 138, 139,
519  141, 143, 145
520 };
521 
522 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
523 static const yytype_int8 yyrhs[] =
524 {
525  25, 0, -1, 27, 26, -1, 1, -1, -1, 14,
526  31, 15, -1, 29, 30, 28, -1, 57, -1, -1,
527  8, -1, -1, 3, -1, 6, -1, 32, -1, -1,
528  32, 34, -1, 34, -1, 16, -1, -1, 42, 33,
529  -1, 35, 33, -1, 36, 37, 45, -1, 40, -1,
530  53, -1, -1, -1, 9, 38, 36, 39, 37, -1,
531  -1, 41, -1, 40, 17, 41, -1, 57, -1, 57,
532  18, 57, -1, 57, 18, 57, 18, 57, -1, 43,
533  44, 46, -1, 52, -1, 3, -1, 4, -1, 5,
534  -1, 57, 19, -1, -1, 46, -1, -1, 45, 20,
535  47, 21, -1, 47, 48, -1, -1, 49, 56, -1,
536  50, -1, 51, -1, 57, 19, 57, -1, 22, 57,
537  -1, 50, -1, -1, 55, 54, 26, -1, 7, 57,
538  -1, 7, -1, -1, 16, -1, 17, -1, -1, 12,
539  -1, 58, -1, 13, -1, 58, 23, 13, -1
540 };
541 
542 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
543 static const yytype_uint8 yyrline[] =
544 {
545  0, 98, 98, 99, 100, 103, 105, 108, 108, 110,
546  110, 112, 112, 114, 114, 116, 116, 118, 118, 120,
547  121, 124, 128, 128, 130, 130, 130, 131, 135, 135,
548  137, 138, 139, 142, 143, 146, 147, 148, 151, 152,
549  155, 155, 157, 159, 160, 162, 165, 165, 167, 170,
550  173, 176, 176, 179, 180, 181, 184, 184, 184, 186,
551  187, 190, 191
552 };
553 #endif
554 
555 #if YYDEBUG || YYERROR_VERBOSE || 0
556 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
557  First, the terminals, then, starting at YYNTOKENS, nonterminals. */
558 static const char *const yytname[] =
559 {
560  "$end", "error", "$undefined", "T_graph", "T_node", "T_edge",
561  "T_digraph", "T_subgraph", "T_strict", "T_edgeop", "T_list", "T_attr",
562  "T_atom", "T_qatom", "'{'", "'}'", "';'", "','", "':'", "'='", "'['",
563  "']'", "'@'", "'+'", "$accept", "graph", "body", "hdr", "optgraphname",
564  "optstrict", "graphtype", "optstmtlist", "stmtlist", "optsemi", "stmt",
565  "compound", "simple", "rcompound", "$@1", "$@2", "nodelist", "node",
566  "attrstmt", "attrtype", "optmacroname", "optattr", "attrlist",
567  "optattrdefs", "attrdefs", "attritem", "attrassignment", "attrmacro",
568  "graphattrdefs", "subgraph", "$@3", "optsubghdr", "optseparator", "atom",
569  "qatom", YY_NULL
570 };
571 #endif
572 
573 # ifdef YYPRINT
574 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
575  token YYLEX-NUM. */
576 static const yytype_uint16 yytoknum[] =
577 {
578  0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
579  265, 266, 267, 268, 123, 125, 59, 44, 58, 61,
580  91, 93, 64, 43
581 };
582 # endif
583 
584 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
585 static const yytype_uint8 yyr1[] =
586 {
587  0, 24, 25, 25, 25, 26, 27, 28, 28, 29,
588  29, 30, 30, 31, 31, 32, 32, 33, 33, 34,
589  34, 35, 36, 36, 38, 39, 37, 37, 40, 40,
590  41, 41, 41, 42, 42, 43, 43, 43, 44, 44,
591  45, 45, 46, 47, 47, 48, 49, 49, 50, 51,
592  52, 54, 53, 55, 55, 55, 56, 56, 56, 57,
593  57, 58, 58
594 };
595 
596 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
597 static const yytype_uint8 yyr2[] =
598 {
599  0, 2, 2, 1, 0, 3, 3, 1, 0, 1,
600  0, 1, 1, 1, 0, 2, 1, 1, 0, 2,
601  2, 3, 1, 1, 0, 0, 5, 0, 1, 3,
602  1, 3, 5, 3, 1, 1, 1, 1, 2, 0,
603  1, 0, 4, 2, 0, 2, 1, 1, 3, 2,
604  1, 0, 3, 2, 1, 0, 1, 1, 0, 1,
605  1, 1, 3
606 };
607 
608 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
609  Performed when YYTABLE doesn't specify something else to do. Zero
610  means the default is an error. */
611 static const yytype_uint8 yydefact[] =
612 {
613  0, 3, 9, 0, 0, 0, 1, 14, 2, 11,
614  12, 8, 35, 36, 37, 54, 59, 61, 0, 13,
615  16, 18, 27, 22, 28, 18, 39, 50, 34, 23,
616  51, 30, 60, 6, 7, 53, 5, 15, 17, 20,
617  24, 41, 0, 19, 41, 0, 0, 0, 0, 0,
618  55, 21, 40, 29, 30, 0, 33, 38, 52, 31,
619  48, 62, 25, 44, 0, 27, 0, 32, 26, 42,
620  0, 43, 58, 46, 47, 0, 49, 56, 57, 45
621 };
622 
623 /* YYDEFGOTO[NTERM-NUM]. */
624 static const yytype_int8 yydefgoto[] =
625 {
626  -1, 3, 8, 4, 33, 5, 11, 18, 19, 39,
627  20, 21, 22, 41, 50, 65, 23, 24, 25, 26,
628  44, 51, 52, 66, 71, 72, 27, 74, 28, 29,
629  46, 30, 79, 31, 32
630 };
631 
632 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
633  STATE-NUM. */
634 #define YYPACT_NINF -18
635 static const yytype_int8 yypact[] =
636 {
637  18, -18, -18, 20, 9, 3, -18, -2, -18, -18,
638  -18, 1, -18, -18, -18, 1, -18, -18, 10, -2,
639  -18, 19, 25, 21, -18, 19, 1, -18, -18, -18,
640  -18, 11, 17, -18, -18, -18, -18, -18, -18, -18,
641  -18, -18, 1, -18, -18, 22, 9, 1, 1, 29,
642  15, 23, -18, -18, 26, 23, 27, -18, -18, 28,
643  -18, -18, -18, -18, 1, 25, -5, -18, -18, -18,
644  1, -18, 16, -18, -18, 30, -18, -18, -18, -18
645 };
646 
647 /* YYPGOTO[NTERM-NUM]. */
648 static const yytype_int8 yypgoto[] =
649 {
650  -18, -18, -1, -18, -18, -18, -18, -18, -18, 31,
651  32, -18, 0, -17, -18, -18, -18, 12, -18, -18,
652  -18, 8, 13, -18, -18, -18, -8, -18, -18, -18,
653  -18, -18, -18, -11, -18
654 };
655 
656 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
657  positive, shift that token. If negative, reduce the rule which
658  number is the opposite. If YYTABLE_NINF, syntax error. */
659 #define YYTABLE_NINF -56
660 static const yytype_int8 yytable[] =
661 {
662  34, 12, 13, 14, 35, 15, 9, 16, 17, 10,
663  16, 17, -55, 16, 17, 45, 69, 70, -4, 1,
664  6, -10, 15, 7, -10, 36, 2, 16, 17, 47,
665  48, 54, 77, 78, 40, 38, 59, 60, 42, 54,
666  49, 57, 61, 63, 47, 58, 64, -40, 68, 48,
667  62, 37, 55, 67, 53, 75, 43, 56, 73, 76
668 };
669 
670 #define yypact_value_is_default(Yystate) \
671  (!!((Yystate) == (-18)))
672 
673 #define yytable_value_is_error(Yytable_value) \
674  YYID (0)
675 
676 static const yytype_uint8 yycheck[] =
677 {
678  11, 3, 4, 5, 15, 7, 3, 12, 13, 6,
679  12, 13, 14, 12, 13, 26, 21, 22, 0, 1,
680  0, 3, 7, 14, 6, 15, 8, 12, 13, 18,
681  19, 42, 16, 17, 9, 16, 47, 48, 17, 50,
682  23, 19, 13, 20, 18, 46, 18, 20, 65, 19,
683  50, 19, 44, 64, 42, 66, 25, 44, 66, 70
684 };
685 
686 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
687  symbol of state STATE-NUM. */
688 static const yytype_uint8 yystos[] =
689 {
690  0, 1, 8, 25, 27, 29, 0, 14, 26, 3,
691  6, 30, 3, 4, 5, 7, 12, 13, 31, 32,
692  34, 35, 36, 40, 41, 42, 43, 50, 52, 53,
693  55, 57, 58, 28, 57, 57, 15, 34, 16, 33,
694  9, 37, 17, 33, 44, 57, 54, 18, 19, 23,
695  38, 45, 46, 41, 57, 45, 46, 19, 26, 57,
696  57, 13, 36, 20, 18, 39, 47, 57, 37, 21,
697  22, 48, 49, 50, 51, 57, 57, 16, 17, 56
698 };
699 
700 #define yyerrok (yyerrstatus = 0)
701 #define yyclearin (yychar = YYEMPTY)
702 #define YYEMPTY (-2)
703 #define YYEOF 0
704 
705 #define YYACCEPT goto yyacceptlab
706 #define YYABORT goto yyabortlab
707 #define YYERROR goto yyerrorlab
708 
709 
710 /* Like YYERROR except do call yyerror. This remains here temporarily
711  to ease the transition to the new meaning of YYERROR, for GCC.
712  Once GCC version 2 has supplanted version 1, this can go. However,
713  YYFAIL appears to be in use. Nevertheless, it is formally deprecated
714  in Bison 2.4.2's NEWS entry, where a plan to phase it out is
715  discussed. */
716 
717 #define YYFAIL goto yyerrlab
718 #if defined YYFAIL
719  /* This is here to suppress warnings from the GCC cpp's
720  -Wunused-macros. Normally we don't worry about that warning, but
721  some users do, and we want to make it easy for users to remove
722  YYFAIL uses, which will produce warnings from Bison 2.5. */
723 #endif
724 
725 #define YYRECOVERING() (!!yyerrstatus)
726 
727 #define YYBACKUP(Token, Value) \
728 do \
729  if (yychar == YYEMPTY) \
730  { \
731  yychar = (Token); \
732  yylval = (Value); \
733  YYPOPSTACK (yylen); \
734  yystate = *yyssp; \
735  goto yybackup; \
736  } \
737  else \
738  { \
739  yyerror (YY_("syntax error: cannot back up")); \
740  YYERROR; \
741  } \
742 while (YYID (0))
743 
744 /* Error token number */
745 #define YYTERROR 1
746 #define YYERRCODE 256
747 
748 
749 /* This macro is provided for backward compatibility. */
750 #ifndef YY_LOCATION_PRINT
751 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
752 #endif
753 
754 
755 /* YYLEX -- calling `yylex' with the right arguments. */
756 #ifdef YYLEX_PARAM
757 # define YYLEX yylex (YYLEX_PARAM)
758 #else
759 # define YYLEX yylex ()
760 #endif
761 
762 /* Enable debugging if requested. */
763 #if YYDEBUG
764 
765 # ifndef YYFPRINTF
766 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
767 # define YYFPRINTF fprintf
768 # endif
769 
770 # define YYDPRINTF(Args) \
771 do { \
772  if (yydebug) \
773  YYFPRINTF Args; \
774 } while (YYID (0))
775 
776 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
777 do { \
778  if (yydebug) \
779  { \
780  YYFPRINTF (stderr, "%s ", Title); \
781  yy_symbol_print (stderr, \
782  Type, Value); \
783  YYFPRINTF (stderr, "\n"); \
784  } \
785 } while (YYID (0))
786 
787 
788 /*--------------------------------.
789 | Print this symbol on YYOUTPUT. |
790 `--------------------------------*/
791 
792 /*ARGSUSED*/
793 #if (defined __STDC__ || defined __C99__FUNC__ \
794  || defined __cplusplus || defined _MSC_VER)
795 static void
796 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
797 #else
798 static void
799 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
800  FILE *yyoutput;
801  int yytype;
802  YYSTYPE const * const yyvaluep;
803 #endif
804 {
805  FILE *yyo = yyoutput;
806  YYUSE (yyo);
807  if (!yyvaluep)
808  return;
809 # ifdef YYPRINT
810  if (yytype < YYNTOKENS)
811  YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
812 # else
813  YYUSE (yyoutput);
814 # endif
815  switch (yytype)
816  {
817  default:
818  break;
819  }
820 }
821 
822 
823 /*--------------------------------.
824 | Print this symbol on YYOUTPUT. |
825 `--------------------------------*/
826 
827 #if (defined __STDC__ || defined __C99__FUNC__ \
828  || defined __cplusplus || defined _MSC_VER)
829 static void
830 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
831 #else
832 static void
833 yy_symbol_print (yyoutput, yytype, yyvaluep)
834  FILE *yyoutput;
835  int yytype;
836  YYSTYPE const * const yyvaluep;
837 #endif
838 {
839  if (yytype < YYNTOKENS)
840  YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
841  else
842  YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
843 
844  yy_symbol_value_print (yyoutput, yytype, yyvaluep);
845  YYFPRINTF (yyoutput, ")");
846 }
847 
848 /*------------------------------------------------------------------.
849 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
850 | TOP (included). |
851 `------------------------------------------------------------------*/
852 
853 #if (defined __STDC__ || defined __C99__FUNC__ \
854  || defined __cplusplus || defined _MSC_VER)
855 static void
856 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
857 #else
858 static void
859 yy_stack_print (yybottom, yytop)
860  yytype_int16 *yybottom;
861  yytype_int16 *yytop;
862 #endif
863 {
864  YYFPRINTF (stderr, "Stack now");
865  for (; yybottom <= yytop; yybottom++)
866  {
867  int yybot = *yybottom;
868  YYFPRINTF (stderr, " %d", yybot);
869  }
870  YYFPRINTF (stderr, "\n");
871 }
872 
873 # define YY_STACK_PRINT(Bottom, Top) \
874 do { \
875  if (yydebug) \
876  yy_stack_print ((Bottom), (Top)); \
877 } while (YYID (0))
878 
879 
880 /*------------------------------------------------.
881 | Report that the YYRULE is going to be reduced. |
882 `------------------------------------------------*/
883 
884 #if (defined __STDC__ || defined __C99__FUNC__ \
885  || defined __cplusplus || defined _MSC_VER)
886 static void
887 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
888 #else
889 static void
890 yy_reduce_print (yyvsp, yyrule)
891  YYSTYPE *yyvsp;
892  int yyrule;
893 #endif
894 {
895  int yynrhs = yyr2[yyrule];
896  int yyi;
897  unsigned long int yylno = yyrline[yyrule];
898  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
899  yyrule - 1, yylno);
900  /* The symbols being reduced. */
901  for (yyi = 0; yyi < yynrhs; yyi++)
902  {
903  YYFPRINTF (stderr, " $%d = ", yyi + 1);
904  yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
905  &(yyvsp[(yyi + 1) - (yynrhs)])
906  );
907  YYFPRINTF (stderr, "\n");
908  }
909 }
910 
911 # define YY_REDUCE_PRINT(Rule) \
912 do { \
913  if (yydebug) \
914  yy_reduce_print (yyvsp, Rule); \
915 } while (YYID (0))
916 
917 /* Nonzero means print parse trace. It is left uninitialized so that
918  multiple parsers can coexist. */
919 int yydebug;
920 #else /* !YYDEBUG */
921 # define YYDPRINTF(Args)
922 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
923 # define YY_STACK_PRINT(Bottom, Top)
924 # define YY_REDUCE_PRINT(Rule)
925 #endif /* !YYDEBUG */
926 
927 
928 /* YYINITDEPTH -- initial size of the parser's stacks. */
929 #ifndef YYINITDEPTH
930 # define YYINITDEPTH 200
931 #endif
932 
933 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
934  if the built-in stack extension method is used).
935 
936  Do not make this value too large; the results are undefined if
937  YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
938  evaluated with infinite-precision integer arithmetic. */
939 
940 #ifndef YYMAXDEPTH
941 # define YYMAXDEPTH 10000
942 #endif
943 
944 
945 #if YYERROR_VERBOSE
946 
947 # ifndef yystrlen
948 # if defined __GLIBC__ && defined _STRING_H
949 # define yystrlen strlen
950 # else
951 /* Return the length of YYSTR. */
952 #if (defined __STDC__ || defined __C99__FUNC__ \
953  || defined __cplusplus || defined _MSC_VER)
954 static YYSIZE_T
955 yystrlen (const char *yystr)
956 #else
957 static YYSIZE_T
958 yystrlen (yystr)
959  const char *yystr;
960 #endif
961 {
962  YYSIZE_T yylen;
963  for (yylen = 0; yystr[yylen]; yylen++)
964  continue;
965  return yylen;
966 }
967 # endif
968 # endif
969 
970 # ifndef yystpcpy
971 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
972 # define yystpcpy stpcpy
973 # else
974 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
975  YYDEST. */
976 #if (defined __STDC__ || defined __C99__FUNC__ \
977  || defined __cplusplus || defined _MSC_VER)
978 static char *
979 yystpcpy (char *yydest, const char *yysrc)
980 #else
981 static char *
982 yystpcpy (yydest, yysrc)
983  char *yydest;
984  const char *yysrc;
985 #endif
986 {
987  char *yyd = yydest;
988  const char *yys = yysrc;
989 
990  while ((*yyd++ = *yys++) != '\0')
991  continue;
992 
993  return yyd - 1;
994 }
995 # endif
996 # endif
997 
998 # ifndef yytnamerr
999 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1000  quotes and backslashes, so that it's suitable for yyerror. The
1001  heuristic is that double-quoting is unnecessary unless the string
1002  contains an apostrophe, a comma, or backslash (other than
1003  backslash-backslash). YYSTR is taken from yytname. If YYRES is
1004  null, do not copy; instead, return the length of what the result
1005  would have been. */
1006 static YYSIZE_T
1007 yytnamerr (char *yyres, const char *yystr)
1008 {
1009  if (*yystr == '"')
1010  {
1011  YYSIZE_T yyn = 0;
1012  char const *yyp = yystr;
1013 
1014  for (;;)
1015  switch (*++yyp)
1016  {
1017  case '\'':
1018  case ',':
1019  goto do_not_strip_quotes;
1020 
1021  case '\\':
1022  if (*++yyp != '\\')
1023  goto do_not_strip_quotes;
1024  /* Fall through. */
1025  default:
1026  if (yyres)
1027  yyres[yyn] = *yyp;
1028  yyn++;
1029  break;
1030 
1031  case '"':
1032  if (yyres)
1033  yyres[yyn] = '\0';
1034  return yyn;
1035  }
1036  do_not_strip_quotes: ;
1037  }
1038 
1039  if (! yyres)
1040  return yystrlen (yystr);
1041 
1042  return yystpcpy (yyres, yystr) - yyres;
1043 }
1044 # endif
1045 
1046 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1047  about the unexpected token YYTOKEN for the state stack whose top is
1048  YYSSP.
1049 
1050  Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1051  not large enough to hold the message. In that case, also set
1052  *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1053  required number of bytes is too large to store. */
1054 static int
1055 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1056  yytype_int16 *yyssp, int yytoken)
1057 {
1058  YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
1059  YYSIZE_T yysize = yysize0;
1060  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1061  /* Internationalized format string. */
1062  const char *yyformat = YY_NULL;
1063  /* Arguments of yyformat. */
1064  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1065  /* Number of reported tokens (one for the "unexpected", one per
1066  "expected"). */
1067  int yycount = 0;
1068 
1069  /* There are many possibilities here to consider:
1070  - Assume YYFAIL is not used. It's too flawed to consider. See
1071  <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1072  for details. YYERROR is fine as it does not invoke this
1073  function.
1074  - If this state is a consistent state with a default action, then
1075  the only way this function was invoked is if the default action
1076  is an error action. In that case, don't check for expected
1077  tokens because there are none.
1078  - The only way there can be no lookahead present (in yychar) is if
1079  this state is a consistent state with a default action. Thus,
1080  detecting the absence of a lookahead is sufficient to determine
1081  that there is no unexpected or expected token to report. In that
1082  case, just report a simple "syntax error".
1083  - Don't assume there isn't a lookahead just because this state is a
1084  consistent state with a default action. There might have been a
1085  previous inconsistent state, consistent state with a non-default
1086  action, or user semantic action that manipulated yychar.
1087  - Of course, the expected token list depends on states to have
1088  correct lookahead information, and it depends on the parser not
1089  to perform extra reductions after fetching a lookahead from the
1090  scanner and before detecting a syntax error. Thus, state merging
1091  (from LALR or IELR) and default reductions corrupt the expected
1092  token list. However, the list is correct for canonical LR with
1093  one exception: it will still contain any token that will not be
1094  accepted due to an error action in a later state.
1095  */
1096  if (yytoken != YYEMPTY)
1097  {
1098  int yyn = yypact[*yyssp];
1099  yyarg[yycount++] = yytname[yytoken];
1100  if (!yypact_value_is_default (yyn))
1101  {
1102  /* Start YYX at -YYN if negative to avoid negative indexes in
1103  YYCHECK. In other words, skip the first -YYN actions for
1104  this state because they are default actions. */
1105  int yyxbegin = yyn < 0 ? -yyn : 0;
1106  /* Stay within bounds of both yycheck and yytname. */
1107  int yychecklim = YYLAST - yyn + 1;
1108  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1109  int yyx;
1110 
1111  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1112  if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1113  && !yytable_value_is_error (yytable[yyx + yyn]))
1114  {
1115  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1116  {
1117  yycount = 1;
1118  yysize = yysize0;
1119  break;
1120  }
1121  yyarg[yycount++] = yytname[yyx];
1122  {
1123  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1124  if (! (yysize <= yysize1
1125  && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1126  return 2;
1127  yysize = yysize1;
1128  }
1129  }
1130  }
1131  }
1132 
1133  switch (yycount)
1134  {
1135 # define YYCASE_(N, S) \
1136  case N: \
1137  yyformat = S; \
1138  break
1139  YYCASE_(0, YY_("syntax error"));
1140  YYCASE_(1, YY_("syntax error, unexpected %s"));
1141  YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1142  YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1143  YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1144  YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1145 # undef YYCASE_
1146  }
1147 
1148  {
1149  YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1150  if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1151  return 2;
1152  yysize = yysize1;
1153  }
1154 
1155  if (*yymsg_alloc < yysize)
1156  {
1157  *yymsg_alloc = 2 * yysize;
1158  if (! (yysize <= *yymsg_alloc
1159  && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1160  *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1161  return 1;
1162  }
1163 
1164  /* Avoid sprintf, as that infringes on the user's name space.
1165  Don't have undefined behavior even if the translation
1166  produced a string with the wrong number of "%s"s. */
1167  {
1168  char *yyp = *yymsg;
1169  int yyi = 0;
1170  while ((*yyp = *yyformat) != '\0')
1171  if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1172  {
1173  yyp += yytnamerr (yyp, yyarg[yyi++]);
1174  yyformat += 2;
1175  }
1176  else
1177  {
1178  yyp++;
1179  yyformat++;
1180  }
1181  }
1182  return 0;
1183 }
1184 #endif /* YYERROR_VERBOSE */
1185 
1186 /*-----------------------------------------------.
1187 | Release the memory associated to this symbol. |
1188 `-----------------------------------------------*/
1189 
1190 /*ARGSUSED*/
1191 #if (defined __STDC__ || defined __C99__FUNC__ \
1192  || defined __cplusplus || defined _MSC_VER)
1193 static void
1194 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1195 #else
1196 static void
1197 yydestruct (yymsg, yytype, yyvaluep)
1198  const char *yymsg;
1199  int yytype;
1200  YYSTYPE *yyvaluep;
1201 #endif
1202 {
1203  YYUSE (yyvaluep);
1204 
1205  if (!yymsg)
1206  yymsg = "Deleting";
1207  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1208 
1209  switch (yytype)
1210  {
1211 
1212  default:
1213  break;
1214  }
1215 }
1216 
1217 
1218 
1219 
1220 /* The lookahead symbol. */
1222 
1223 
1224 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1225 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1226 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
1227 #endif
1228 #ifndef YY_INITIAL_VALUE
1229 # define YY_INITIAL_VALUE(Value) /* Nothing. */
1230 #endif
1231 
1232 /* The semantic value of the lookahead symbol. */
1233 YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
1234 
1235 /* Number of syntax errors so far. */
1237 
1238 
1239 /*----------.
1240 | yyparse. |
1241 `----------*/
1242 
1243 #ifdef YYPARSE_PARAM
1244 #if (defined __STDC__ || defined __C99__FUNC__ \
1245  || defined __cplusplus || defined _MSC_VER)
1246 int
1247 yyparse (void *YYPARSE_PARAM)
1248 #else
1249 int
1250 yyparse (YYPARSE_PARAM)
1251  void *YYPARSE_PARAM;
1252 #endif
1253 #else /* ! YYPARSE_PARAM */
1254 #if (defined __STDC__ || defined __C99__FUNC__ \
1255  || defined __cplusplus || defined _MSC_VER)
1256 int
1257 yyparse (void)
1258 #else
1259 int
1260 yyparse ()
1261 
1262 #endif
1263 #endif
1265  int yystate;
1266  /* Number of tokens to shift before error messages enabled. */
1268 
1269  /* The stacks and their tools:
1270  `yyss': related to states.
1271  `yyvs': related to semantic values.
1272 
1273  Refer to the stacks through separate pointers, to allow yyoverflow
1274  to reallocate them elsewhere. */
1275 
1276  /* The state stack. */
1280 
1281  /* The semantic value stack. */
1285 
1287 
1288  int yyn;
1290  /* Lookahead token as an internal (translated) token number. */
1291  int yytoken = 0;
1292  /* The variables used to return semantic value and location from the
1293  action routines. */
1295 
1296 #if YYERROR_VERBOSE
1297  /* Buffer for error messages, and its allocated size. */
1298  char yymsgbuf[128];
1299  char *yymsg = yymsgbuf;
1300  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1301 #endif
1302 
1303 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1304 
1305  /* The number of symbols on the RHS of the reduced rule.
1306  Keep to zero when no symbol should be popped. */
1307  int yylen = 0;
1308 
1309  yyssp = yyss = yyssa;
1310  yyvsp = yyvs = yyvsa;
1311  yystacksize = YYINITDEPTH;
1312 
1313  YYDPRINTF ((stderr, "Starting parse\n"));
1314 
1315  yystate = 0;
1316  yyerrstatus = 0;
1317  yynerrs = 0;
1318  yychar = YYEMPTY; /* Cause a token to be read. */
1320 
1321 /*------------------------------------------------------------.
1322 | yynewstate -- Push a new state, which is found in yystate. |
1323 `------------------------------------------------------------*/
1324  yynewstate:
1325  /* In all cases, when you get here, the value and location stacks
1326  have just been pushed. So pushing a state here evens the stacks. */
1327  yyssp++;
1328 
1329  yysetstate:
1330  *yyssp = yystate;
1331 
1332  if (yyss + yystacksize - 1 <= yyssp)
1333  {
1334  /* Get the current used size of the three stacks, in elements. */
1335  YYSIZE_T yysize = yyssp - yyss + 1;
1336 
1337 #ifdef yyoverflow
1338  {
1339  /* Give user a chance to reallocate the stack. Use copies of
1340  these so that the &'s don't force the real ones into
1341  memory. */
1342  YYSTYPE *yyvs1 = yyvs;
1343  yytype_int16 *yyss1 = yyss;
1344 
1345  /* Each stack pointer address is followed by the size of the
1346  data in use in that stack, in bytes. This used to be a
1347  conditional around just the two extra args, but that might
1348  be undefined if yyoverflow is a macro. */
1349  yyoverflow (YY_("memory exhausted"),
1350  &yyss1, yysize * sizeof (*yyssp),
1351  &yyvs1, yysize * sizeof (*yyvsp),
1352  &yystacksize);
1353 
1354  yyss = yyss1;
1355  yyvs = yyvs1;
1356  }
1357 #else /* no yyoverflow */
1358 # ifndef YYSTACK_RELOCATE
1359  goto yyexhaustedlab;
1360 # else
1361  /* Extend the stack our own way. */
1362  if (YYMAXDEPTH <= yystacksize)
1363  goto yyexhaustedlab;
1364  yystacksize *= 2;
1365  if (YYMAXDEPTH < yystacksize)
1366  yystacksize = YYMAXDEPTH;
1367 
1368  {
1369  yytype_int16 *yyss1 = yyss;
1370  union yyalloc *yyptr =
1371  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1372  if (! yyptr)
1373  goto yyexhaustedlab;
1374  YYSTACK_RELOCATE (yyss_alloc, yyss);
1375  YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1376 # undef YYSTACK_RELOCATE
1377  if (yyss1 != yyssa)
1378  YYSTACK_FREE (yyss1);
1379  }
1380 # endif
1381 #endif /* no yyoverflow */
1382 
1383  yyssp = yyss + yysize - 1;
1384  yyvsp = yyvs + yysize - 1;
1385 
1386  YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1387  (unsigned long int) yystacksize));
1388 
1389  if (yyss + yystacksize - 1 <= yyssp)
1390  YYABORT;
1391  }
1392 
1393  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1394 
1395  if (yystate == YYFINAL)
1397 
1398  goto yybackup;
1399 
1400 /*-----------.
1401 | yybackup. |
1402 `-----------*/
1403 yybackup:
1404 
1405  /* Do appropriate processing given the current state. Read a
1406  lookahead token if we need one and don't already have one. */
1407 
1408  /* First try to decide what to do without reference to lookahead token. */
1409  yyn = yypact[yystate];
1410  if (yypact_value_is_default (yyn))
1412 
1413  /* Not known => get a lookahead token if don't already have one. */
1414 
1415  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1416  if (yychar == YYEMPTY)
1417  {
1418  YYDPRINTF ((stderr, "Reading a token: "));
1419  yychar = YYLEX;
1420  }
1421 
1422  if (yychar <= YYEOF)
1423  {
1424  yychar = yytoken = YYEOF;
1425  YYDPRINTF ((stderr, "Now at end of input.\n"));
1426  }
1427  else
1428  {
1429  yytoken = YYTRANSLATE (yychar);
1430  YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1431  }
1432 
1433  /* If the proper action on seeing token YYTOKEN is to reduce or to
1434  detect an error, take that action. */
1435  yyn += yytoken;
1436  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1437  goto yydefault;
1438  yyn = yytable[yyn];
1439  if (yyn <= 0)
1440  {
1441  if (yytable_value_is_error (yyn))
1442  goto yyerrlab;
1443  yyn = -yyn;
1444  goto yyreduce;
1445  }
1446 
1447  /* Count tokens shifted since error; after three, turn off error
1448  status. */
1449  if (yyerrstatus)
1450  yyerrstatus--;
1451 
1452  /* Shift the lookahead token. */
1453  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1454 
1455  /* Discard the shifted token. */
1456  yychar = YYEMPTY;
1457 
1458  yystate = yyn;
1460  *++yyvsp = yylval;
1462 
1464 
1465 
1466 /*-----------------------------------------------------------.
1467 | yydefault -- do the default action for the current state. |
1468 `-----------------------------------------------------------*/
1469 yydefault:
1470  yyn = yydefact[yystate];
1471  if (yyn == 0)
1472  goto yyerrlab;
1473  goto yyreduce;
1474 
1475 
1476 /*-----------------------------.
1477 | yyreduce -- Do a reduction. |
1478 `-----------------------------*/
1479 yyreduce:
1480  /* yyn is the number of a rule to reduce with. */
1481  yylen = yyr2[yyn];
1482 
1483  /* If YYLEN is nonzero, implement the default value of the action:
1484  `$$ = $1'.
1485 
1486  Otherwise, the following line sets YYVAL to garbage.
1487  This behavior is undocumented and Bison
1488  users should not rely upon it. Assigning to YYVAL
1489  unconditionally makes the parser a bit smaller, and it avoids a
1490  GCC warning that YYVAL may be used uninitialized. */
1491  yyval = yyvsp[1-yylen];
1492 
1493 
1494  YY_REDUCE_PRINT (yyn);
1495  switch (yyn)
1496  {
1497  case 2:
1498 /* Line 1792 of yacc.c */
1499 #line 98 "../../lib/cgraph/grammar.y"
1500  {freestack(); endgraph();}
1501  break;
1502 
1503  case 3:
1504 /* Line 1792 of yacc.c */
1505 #line 99 "../../lib/cgraph/grammar.y"
1506  {if (G) {freestack(); endgraph(); agclose(G); G = Ag_G_global = NIL(Agraph_t*);}}
1507  break;
1508 
1509  case 6:
1510 /* Line 1792 of yacc.c */
1511 #line 105 "../../lib/cgraph/grammar.y"
1512  {startgraph((yyvsp[(3) - (3)].str),(yyvsp[(2) - (3)].i),(yyvsp[(1) - (3)].i));}
1513  break;
1514 
1515  case 7:
1516 /* Line 1792 of yacc.c */
1517 #line 108 "../../lib/cgraph/grammar.y"
1518  {(yyval.str)=(yyvsp[(1) - (1)].str);}
1519  break;
1520 
1521  case 8:
1522 /* Line 1792 of yacc.c */
1523 #line 108 "../../lib/cgraph/grammar.y"
1524  {(yyval.str)=0;}
1525  break;
1526 
1527  case 9:
1528 /* Line 1792 of yacc.c */
1529 #line 110 "../../lib/cgraph/grammar.y"
1530  {(yyval.i)=1;}
1531  break;
1532 
1533  case 10:
1534 /* Line 1792 of yacc.c */
1535 #line 110 "../../lib/cgraph/grammar.y"
1536  {(yyval.i)=0;}
1537  break;
1538 
1539  case 11:
1540 /* Line 1792 of yacc.c */
1541 #line 112 "../../lib/cgraph/grammar.y"
1542  {(yyval.i) = 0;}
1543  break;
1544 
1545  case 12:
1546 /* Line 1792 of yacc.c */
1547 #line 112 "../../lib/cgraph/grammar.y"
1548  {(yyval.i) = 1;}
1549  break;
1550 
1551  case 21:
1552 /* Line 1792 of yacc.c */
1553 #line 125 "../../lib/cgraph/grammar.y"
1554  {if ((yyvsp[(2) - (3)].i)) endedge(); else endnode();}
1555  break;
1556 
1557  case 24:
1558 /* Line 1792 of yacc.c */
1559 #line 130 "../../lib/cgraph/grammar.y"
1560  {getedgeitems(1);}
1561  break;
1562 
1563  case 25:
1564 /* Line 1792 of yacc.c */
1565 #line 130 "../../lib/cgraph/grammar.y"
1566  {getedgeitems(2);}
1567  break;
1568 
1569  case 26:
1570 /* Line 1792 of yacc.c */
1571 #line 130 "../../lib/cgraph/grammar.y"
1572  {(yyval.i) = 1;}
1573  break;
1574 
1575  case 27:
1576 /* Line 1792 of yacc.c */
1577 #line 131 "../../lib/cgraph/grammar.y"
1578  {(yyval.i) = 0;}
1579  break;
1580 
1581  case 30:
1582 /* Line 1792 of yacc.c */
1583 #line 137 "../../lib/cgraph/grammar.y"
1584  {appendnode((yyvsp[(1) - (1)].str),NIL(char*),NIL(char*));}
1585  break;
1586 
1587  case 31:
1588 /* Line 1792 of yacc.c */
1589 #line 138 "../../lib/cgraph/grammar.y"
1590  {appendnode((yyvsp[(1) - (3)].str),(yyvsp[(3) - (3)].str),NIL(char*));}
1591  break;
1592 
1593  case 32:
1594 /* Line 1792 of yacc.c */
1595 #line 139 "../../lib/cgraph/grammar.y"
1596  {appendnode((yyvsp[(1) - (5)].str),(yyvsp[(3) - (5)].str),(yyvsp[(5) - (5)].str));}
1597  break;
1598 
1599  case 33:
1600 /* Line 1792 of yacc.c */
1601 #line 142 "../../lib/cgraph/grammar.y"
1602  {attrstmt((yyvsp[(1) - (3)].i),(yyvsp[(2) - (3)].str));}
1603  break;
1604 
1605  case 34:
1606 /* Line 1792 of yacc.c */
1607 #line 143 "../../lib/cgraph/grammar.y"
1608  {attrstmt(T_graph,NIL(char*));}
1609  break;
1610 
1611  case 35:
1612 /* Line 1792 of yacc.c */
1613 #line 146 "../../lib/cgraph/grammar.y"
1614  {(yyval.i) = T_graph;}
1615  break;
1616 
1617  case 36:
1618 /* Line 1792 of yacc.c */
1619 #line 147 "../../lib/cgraph/grammar.y"
1620  {(yyval.i) = T_node;}
1621  break;
1622 
1623  case 37:
1624 /* Line 1792 of yacc.c */
1625 #line 148 "../../lib/cgraph/grammar.y"
1626  {(yyval.i) = T_edge;}
1627  break;
1628 
1629  case 38:
1630 /* Line 1792 of yacc.c */
1631 #line 151 "../../lib/cgraph/grammar.y"
1632  {(yyval.str) = (yyvsp[(1) - (2)].str);}
1633  break;
1634 
1635  case 39:
1636 /* Line 1792 of yacc.c */
1637 #line 152 "../../lib/cgraph/grammar.y"
1638  {(yyval.str) = NIL(char*); }
1639  break;
1640 
1641  case 48:
1642 /* Line 1792 of yacc.c */
1643 #line 167 "../../lib/cgraph/grammar.y"
1644  {appendattr((yyvsp[(1) - (3)].str),(yyvsp[(3) - (3)].str));}
1645  break;
1646 
1647  case 49:
1648 /* Line 1792 of yacc.c */
1649 #line 170 "../../lib/cgraph/grammar.y"
1650  {appendattr((yyvsp[(2) - (2)].str),NIL(char*));}
1651  break;
1652 
1653  case 51:
1654 /* Line 1792 of yacc.c */
1655 #line 176 "../../lib/cgraph/grammar.y"
1656  {opensubg((yyvsp[(1) - (1)].str));}
1657  break;
1658 
1659  case 52:
1660 /* Line 1792 of yacc.c */
1661 #line 176 "../../lib/cgraph/grammar.y"
1662  {closesubg();}
1663  break;
1664 
1665  case 53:
1666 /* Line 1792 of yacc.c */
1667 #line 179 "../../lib/cgraph/grammar.y"
1668  {(yyval.str)=(yyvsp[(2) - (2)].str);}
1669  break;
1670 
1671  case 54:
1672 /* Line 1792 of yacc.c */
1673 #line 180 "../../lib/cgraph/grammar.y"
1674  {(yyval.str)=NIL(char*);}
1675  break;
1676 
1677  case 55:
1678 /* Line 1792 of yacc.c */
1679 #line 181 "../../lib/cgraph/grammar.y"
1680  {(yyval.str)=NIL(char*);}
1681  break;
1682 
1683  case 59:
1684 /* Line 1792 of yacc.c */
1685 #line 186 "../../lib/cgraph/grammar.y"
1686  {(yyval.str) = (yyvsp[(1) - (1)].str);}
1687  break;
1688 
1689  case 60:
1690 /* Line 1792 of yacc.c */
1691 #line 187 "../../lib/cgraph/grammar.y"
1692  {(yyval.str) = (yyvsp[(1) - (1)].str);}
1693  break;
1694 
1695  case 61:
1696 /* Line 1792 of yacc.c */
1697 #line 190 "../../lib/cgraph/grammar.y"
1698  {(yyval.str) = (yyvsp[(1) - (1)].str);}
1699  break;
1700 
1701  case 62:
1702 /* Line 1792 of yacc.c */
1703 #line 191 "../../lib/cgraph/grammar.y"
1704  {(yyval.str) = concat((yyvsp[(1) - (3)].str),(yyvsp[(3) - (3)].str));}
1705  break;
1706 
1707 
1708 /* Line 1792 of yacc.c */
1709 #line 1710 "y.tab.c"
1710  default: break;
1711  }
1712  /* User semantic actions sometimes alter yychar, and that requires
1713  that yytoken be updated with the new translation. We take the
1714  approach of translating immediately before every use of yytoken.
1715  One alternative is translating here after every semantic action,
1716  but that translation would be missed if the semantic action invokes
1717  YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1718  if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1719  incorrect destructor might then be invoked immediately. In the
1720  case of YYERROR or YYBACKUP, subsequent parser actions might lead
1721  to an incorrect destructor call or verbose syntax error message
1722  before the lookahead is translated. */
1723  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1724 
1725  YYPOPSTACK (yylen);
1726  yylen = 0;
1727  YY_STACK_PRINT (yyss, yyssp);
1728 
1729  *++yyvsp = yyval;
1730 
1731  /* Now `shift' the result of the reduction. Determine what state
1732  that goes to, based on the state we popped back to and the rule
1733  number reduced by. */
1734 
1735  yyn = yyr1[yyn];
1736 
1737  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1738  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1739  yystate = yytable[yystate];
1740  else
1741  yystate = yydefgoto[yyn - YYNTOKENS];
1742 
1743  goto yynewstate;
1744 
1745 
1746 /*------------------------------------.
1747 | yyerrlab -- here on detecting error |
1748 `------------------------------------*/
1749 yyerrlab:
1750  /* Make sure we have latest lookahead translation. See comments at
1751  user semantic actions for why this is necessary. */
1752  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1753 
1754  /* If not already recovering from an error, report this error. */
1755  if (!yyerrstatus)
1756  {
1757  ++yynerrs;
1758 #if ! YYERROR_VERBOSE
1759  yyerror (YY_("syntax error"));
1760 #else
1761 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1762  yyssp, yytoken)
1763  {
1764  char const *yymsgp = YY_("syntax error");
1765  int yysyntax_error_status;
1766  yysyntax_error_status = YYSYNTAX_ERROR;
1767  if (yysyntax_error_status == 0)
1768  yymsgp = yymsg;
1769  else if (yysyntax_error_status == 1)
1770  {
1771  if (yymsg != yymsgbuf)
1772  YYSTACK_FREE (yymsg);
1773  yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1774  if (!yymsg)
1775  {
1776  yymsg = yymsgbuf;
1777  yymsg_alloc = sizeof yymsgbuf;
1778  yysyntax_error_status = 2;
1779  }
1780  else
1781  {
1782  yysyntax_error_status = YYSYNTAX_ERROR;
1783  yymsgp = yymsg;
1784  }
1785  }
1786  yyerror (yymsgp);
1787  if (yysyntax_error_status == 2)
1788  goto yyexhaustedlab;
1789  }
1790 # undef YYSYNTAX_ERROR
1791 #endif
1792  }
1793 
1794 
1795 
1796  if (yyerrstatus == 3)
1797  {
1798  /* If just tried and failed to reuse lookahead token after an
1799  error, discard it. */
1800 
1801  if (yychar <= YYEOF)
1802  {
1803  /* Return failure if at end of input. */
1804  if (yychar == YYEOF)
1805  YYABORT;
1806  }
1807  else
1808  {
1809  yydestruct ("Error: discarding",
1810  yytoken, &yylval);
1811  yychar = YYEMPTY;
1812  }
1813  }
1814 
1815  /* Else will try to reuse lookahead token after shifting the error
1816  token. */
1818 
1819 
1820 /*---------------------------------------------------.
1821 | yyerrorlab -- error raised explicitly by YYERROR. |
1822 `---------------------------------------------------*/
1823 yyerrorlab:
1824 
1825  /* Pacify compilers like GCC when the user code never invokes
1826  YYERROR and the label yyerrorlab therefore never appears in user
1827  code. */
1828  if (/*CONSTCOND*/ 0)
1829  goto yyerrorlab;
1830 
1831  /* Do not reclaim the symbols of the rule which action triggered
1832  this YYERROR. */
1833  YYPOPSTACK (yylen);
1834  yylen = 0;
1835  YY_STACK_PRINT (yyss, yyssp);
1836  yystate = *yyssp;
1837  goto yyerrlab1;
1838 
1839 
1840 /*-------------------------------------------------------------.
1841 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1842 `-------------------------------------------------------------*/
1843 yyerrlab1:
1844  yyerrstatus = 3; /* Each real token shifted decrements this. */
1845 
1846  for (;;)
1847  {
1848  yyn = yypact[yystate];
1849  if (!yypact_value_is_default (yyn))
1850  {
1851  yyn += YYTERROR;
1852  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1853  {
1854  yyn = yytable[yyn];
1855  if (0 < yyn)
1856  break;
1857  }
1858  }
1859 
1860  /* Pop the current state because it cannot handle the error token. */
1861  if (yyssp == yyss)
1862  YYABORT;
1863 
1864 
1865  yydestruct ("Error: popping",
1866  yystos[yystate], yyvsp);
1867  YYPOPSTACK (1);
1868  yystate = *yyssp;
1869  YY_STACK_PRINT (yyss, yyssp);
1870  }
1871 
1873  *++yyvsp = yylval;
1875 
1876 
1877  /* Shift the error token. */
1878  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1879 
1880  yystate = yyn;
1881  goto yynewstate;
1882 
1883 
1884 /*-------------------------------------.
1885 | yyacceptlab -- YYACCEPT comes here. |
1886 `-------------------------------------*/
1887 yyacceptlab:
1888  yyresult = 0;
1889  goto yyreturn;
1890 
1891 /*-----------------------------------.
1892 | yyabortlab -- YYABORT comes here. |
1893 `-----------------------------------*/
1894 yyabortlab:
1895  yyresult = 1;
1896  goto yyreturn;
1897 
1898 #if !defined yyoverflow || YYERROR_VERBOSE
1899 /*-------------------------------------------------.
1900 | yyexhaustedlab -- memory exhaustion comes here. |
1901 `-------------------------------------------------*/
1902 yyexhaustedlab:
1903  yyerror (YY_("memory exhausted"));
1904  yyresult = 2;
1905  /* Fall through. */
1906 #endif
1907 
1908 yyreturn:
1909  if (yychar != YYEMPTY)
1910  {
1911  /* Make sure we have latest lookahead translation. See comments at
1912  user semantic actions for why this is necessary. */
1913  yytoken = YYTRANSLATE (yychar);
1914  yydestruct ("Cleanup: discarding lookahead",
1915  yytoken, &yylval);
1916  }
1917  /* Do not reclaim the symbols of the rule which action triggered
1918  this YYABORT or YYACCEPT. */
1919  YYPOPSTACK (yylen);
1920  YY_STACK_PRINT (yyss, yyssp);
1921  while (yyssp != yyss)
1922  {
1923  yydestruct ("Cleanup: popping",
1924  yystos[*yyssp], yyvsp);
1925  YYPOPSTACK (1);
1926  }
1927 #ifndef yyoverflow
1928  if (yyss != yyssa)
1929  YYSTACK_FREE (yyss);
1930 #endif
1931 #if YYERROR_VERBOSE
1932  if (yymsg != yymsgbuf)
1933  YYSTACK_FREE (yymsg);
1934 #endif
1935  /* Make sure YYID is used. */
1936  return YYID (yyresult);
1937 }
1938 
1939 
1940 /* Line 2055 of yacc.c */
1941 #line 193 "../../lib/cgraph/grammar.y"
1942 
1943 
1944 #define NILitem NIL(item*)
1945 
1946 
1947 static item *newitem(int tag, void *p0, char *p1)
1948 {
1949  item *rv = agalloc(G,sizeof(item));
1950  rv->tag = tag; rv->u.name = (char*)p0; rv->str = p1;
1951  return rv;
1952 }
1953 
1954 static item *cons_node(Agnode_t *n, char *port)
1955  { return newitem(T_node,n,port); }
1956 
1957 static item *cons_attr(char *name, char *value)
1958  { return newitem(T_atom,name,value); }
1959 
1960 static item *cons_list(item *list)
1961  { return newitem(T_list,list,NIL(char*)); }
1962 
1963 static item *cons_subg(Agraph_t *subg)
1964  { return newitem(T_subgraph,subg,NIL(char*)); }
1965 
1966 static gstack_t *push(gstack_t *s, Agraph_t *subg) {
1967  gstack_t *rv;
1968  rv = agalloc(G,sizeof(gstack_t));
1969  rv->down = s;
1970  rv->g = subg;
1971  return rv;
1972 }
1973 
1974 static gstack_t *pop(gstack_t *s)
1975 {
1976  gstack_t *rv;
1977  rv = S->down;
1978  agfree(G,s);
1979  return rv;
1980 }
1981 
1982 #ifdef NOTDEF
1983 static item *cons_edge(Agedge_t *e)
1984  { return newitem(T_edge,e,NIL(char*)); }
1985 #endif
1986 
1987 static void delete_items(item *ilist)
1988 {
1989  item *p,*pn;
1990 
1991  for (p = ilist; p; p = pn) {
1992  pn = p->next;
1993  switch(p->tag) {
1994  case T_list: delete_items(p->u.list); break;
1995  case T_atom: case T_attr: agstrfree(G,p->str); break;
1996  }
1997  agfree(G,p);
1998  }
1999 }
2000 
2001 #ifdef NOTDEF
2002 static void initlist(list_t *list)
2003 {
2004  list->first = list->last = NILitem;
2005 }
2006 #endif
2007 
2008 static void deletelist(list_t *list)
2009 {
2010  delete_items(list->first);
2011  list->first = list->last = NILitem;
2012 }
2013 
2014 #ifdef NOTDEF
2015 static void listins(list_t *list, item *v)
2016 {
2017  v->next = list->first;
2018  list->first = v;
2019  if (list->last == NILitem) list->last = v;
2020 }
2021 #endif
2022 
2023 static void listapp(list_t *list, item *v)
2024 {
2025  if (list->last) list->last->next = v;
2026  list->last = v;
2027  if (list->first == NILitem) list->first = v;
2028 }
2029 
2030 
2031 /* attrs */
2032 static void appendattr(char *name, char *value)
2033 {
2034  item *v;
2035 
2036  assert(value != NIL(char*));
2037  v = cons_attr(name,value);
2038  listapp(&(S->attrlist),v);
2039 }
2040 
2041 static void bindattrs(int kind)
2042 {
2043  item *aptr;
2044  char *name;
2045 
2046  for (aptr = S->attrlist.first; aptr; aptr = aptr->next) {
2047  assert(aptr->tag == T_atom); /* signifies unbound attr */
2048  name = aptr->u.name;
2049  if ((kind == AGEDGE) && streq(name,Key)) continue;
2050  if ((aptr->u.asym = agattr(S->g,kind,name,NIL(char*))) == NILsym)
2051  aptr->u.asym = agattr(S->g,kind,name,"");
2052  aptr->tag = T_attr; /* signifies bound attr */
2053  agstrfree(G,name);
2054  }
2055 }
2056 
2057 /* attach node/edge specific attributes */
2058 static void applyattrs(void *obj)
2059 {
2060  item *aptr;
2061 
2062  for (aptr = S->attrlist.first; aptr; aptr = aptr->next) {
2063  if (aptr->tag == T_attr) {
2064  if (aptr->u.asym) {
2065  agxset(obj,aptr->u.asym,aptr->str);
2066  }
2067  }
2068  else {
2069  assert(AGTYPE(obj) == AGEDGE);
2070  assert(aptr->tag == T_atom);
2071  assert(streq(aptr->u.name,Key));
2072  }
2073  }
2074 }
2075 
2076 static void nomacros(void)
2077 {
2078  agerr(AGWARN,"attribute macros not implemented");
2079 }
2080 
2081 /* attrstmt:
2082  * First argument is always attrtype, so switch covers all cases.
2083  * This function is used to handle default attribute value assignment.
2084  */
2085 static void attrstmt(int tkind, char *macroname)
2086 {
2087  item *aptr;
2088  int kind = 0;
2089  Agsym_t* sym;
2090 
2091  /* creating a macro def */
2092  if (macroname) nomacros();
2093  /* invoking a macro def */
2094  for (aptr = S->attrlist.first; aptr; aptr = aptr->next)
2095  if (aptr->str == NIL(char*)) nomacros();
2096 
2097  switch(tkind) {
2098  case T_graph: kind = AGRAPH; break;
2099  case T_node: kind = AGNODE; break;
2100  case T_edge: kind = AGEDGE; break;
2101  }
2102  bindattrs(kind); /* set up defaults for new attributes */
2103  for (aptr = S->attrlist.first; aptr; aptr = aptr->next) {
2104  /* If the tag is still T_atom, aptr->u.asym has not been set */
2105  if (aptr->tag == T_atom) continue;
2106  if (!(aptr->u.asym->fixed) || (S->g != G))
2107  sym = agattr(S->g,kind,aptr->u.asym->name,aptr->str);
2108  else
2109  sym = aptr->u.asym;
2110  if (S->g == G)
2111  sym->print = TRUE;
2112  }
2113  deletelist(&(S->attrlist));
2114 }
2115 
2116 /* nodes */
2117 
2118 static void appendnode(char *name, char *port, char *sport)
2119 {
2120  item *elt;
2121 
2122  if (sport) {
2123  port = concatPort (port, sport);
2124  }
2125  elt = cons_node(agnode(S->g,name,TRUE),port);
2126  listapp(&(S->nodelist),elt);
2127  agstrfree(G,name);
2128 }
2129 
2130 /* apply current optional attrs to nodelist and clean up lists */
2131 /* what's bad is that this could also be endsubg. also, you can't
2132 clean up S->subg in closesubg() because S->subg might be needed
2133 to construct edges. these are the sort of notes you write to yourself
2134 in the future. */
2135 static void endnode()
2136 {
2137  item *ptr;
2138 
2139  bindattrs(AGNODE);
2140  for (ptr = S->nodelist.first; ptr; ptr = ptr->next)
2141  applyattrs(ptr->u.n);
2142  deletelist(&(S->nodelist));
2143  deletelist(&(S->attrlist));
2144  deletelist(&(S->edgelist));
2145  S->subg = 0; /* notice a pattern here? :-( */
2146 }
2147 
2148 /* edges - store up node/subg lists until optional edge key can be seen */
2149 
2150 static void getedgeitems(int x)
2151 {
2152  item *v = 0;
2153 
2154  if (S->nodelist.first) {
2155  v = cons_list(S->nodelist.first);
2156  S->nodelist.first = S->nodelist.last = NILitem;
2157  }
2158  else {if (S->subg) v = cons_subg(S->subg); S->subg = 0;}
2159  /* else nil append */
2160  if (v) listapp(&(S->edgelist),v);
2161 }
2162 
2163 static void endedge(void)
2164 {
2165  char *key;
2166  item *aptr,*tptr,*p;
2167 
2168  Agnode_t *t;
2169  Agraph_t *subg;
2170 
2171  bindattrs(AGEDGE);
2172 
2173  /* look for "key" pseudo-attribute */
2174  key = NIL(char*);
2175  for (aptr = S->attrlist.first; aptr; aptr = aptr->next) {
2176  if ((aptr->tag == T_atom) && streq(aptr->u.name,Key))
2177  key = aptr->str;
2178  }
2179 
2180  /* can make edges with node lists or subgraphs */
2181  for (p = S->edgelist.first; p->next; p = p->next) {
2182  if (p->tag == T_subgraph) {
2183  subg = p->u.subg;
2184  for (t = agfstnode(subg); t; t = agnxtnode(subg,t))
2185  edgerhs(agsubnode(S->g,t,FALSE),NIL(char*),p->next,key);
2186  }
2187  else {
2188  for (tptr = p->u.list; tptr; tptr = tptr->next)
2189  edgerhs(tptr->u.n,tptr->str,p->next,key);
2190  }
2191  }
2192  deletelist(&(S->nodelist));
2193  deletelist(&(S->edgelist));
2194  deletelist(&(S->attrlist));
2195  S->subg = 0;
2196 }
2197 
2198 /* concat:
2199  */
2200 static char*
2201 concat (char* s1, char* s2)
2202 {
2203  char* s;
2204  char buf[BUFSIZ];
2205  char* sym;
2206  size_t len = strlen(s1) + strlen(s2) + 1;
2207 
2208  if (len <= BUFSIZ) sym = buf;
2209  else sym = (char*)malloc(len);
2210  strcpy(sym,s1);
2211  strcat(sym,s2);
2212  s = agstrdup (G,sym);
2213  agstrfree (G,s1);
2214  agstrfree (G,s2);
2215  if (sym != buf) free (sym);
2216  return s;
2217 }
2218 
2219 /* concatPort:
2220  */
2221 static char*
2222 concatPort (char* s1, char* s2)
2223 {
2224  char* s;
2225  char buf[BUFSIZ];
2226  char* sym;
2227  size_t len = strlen(s1) + strlen(s2) + 2; /* one more for ':' */
2228 
2229  if (len <= BUFSIZ) sym = buf;
2230  else sym = (char*)malloc(len);
2231  sprintf (sym, "%s:%s", s1, s2);
2232  s = agstrdup (G,sym);
2233  agstrfree (G,s1);
2234  agstrfree (G,s2);
2235  if (sym != buf) free (sym);
2236  return s;
2237 }
2238 
2239 
2240 static void edgerhs(Agnode_t *tail, char *tport, item *hlist, char *key)
2241 {
2242  Agnode_t *head;
2243  Agraph_t *subg;
2244  item *hptr;
2245 
2246  if (hlist->tag == T_subgraph) {
2247  subg = hlist->u.subg;
2248  for (head = agfstnode(subg); head; head = agnxtnode(subg,head))
2249  newedge(tail,tport,agsubnode(S->g,head,FALSE),NIL(char*),key);
2250  }
2251  else {
2252  for (hptr = hlist->u.list; hptr; hptr = hptr->next)
2253  newedge(tail,tport,agsubnode(S->g,hptr->u.n,FALSE),hptr->str,key);
2254  }
2255 }
2256 
2257 static void mkport(Agedge_t *e, char *name, char *val)
2258 {
2259  Agsym_t *attr;
2260  if (val) {
2261  if ((attr = agattr(S->g,AGEDGE,name,NIL(char*))) == NILsym)
2262  attr = agattr(S->g,AGEDGE,name,"");
2263  agxset(e,attr,val);
2264  }
2265 }
2266 
2267 static void newedge(Agnode_t *t, char *tport, Agnode_t *h, char *hport, char *key)
2268 {
2269  Agedge_t *e;
2270 
2271  e = agedge(S->g,t,h,key,TRUE);
2272  if (e) { /* can fail if graph is strict and t==h */
2273  char *tp = tport;
2274  char *hp = hport;
2275  if ((agtail(e) != aghead(e)) && (aghead(e) == t)) {
2276  /* could happen with an undirected edge */
2277  char *temp;
2278  temp = tp; tp = hp; hp = temp;
2279  }
2280  mkport(e,TAILPORT_ID,tp);
2281  mkport(e,HEADPORT_ID,hp);
2282  applyattrs(e);
2283  }
2284 }
2285 
2286 /* graphs and subgraphs */
2287 
2288 
2289 static void startgraph(char *name, int directed, int strict)
2290 {
2291  static Agdesc_t req; /* get rid of warnings */
2292 
2293  if (G == NILgraph) {
2294  req.directed = directed;
2295  req.strict = strict;
2296  req.maingraph = TRUE;
2297  Ag_G_global = G = agopen(name,req,Disc);
2298  }
2299  else {
2300  Ag_G_global = G;
2301  }
2302  S = push(S,G);
2303  agstrfree(NIL(Agraph_t*),name);
2304 }
2305 
2306 static void endgraph()
2307 {
2308  aglexeof();
2310 }
2311 
2312 static void opensubg(char *name)
2313 {
2314  S = push(S,agsubg(S->g,name,TRUE));
2315  agstrfree(G,name);
2316 }
2317 
2318 static void closesubg()
2319 {
2320  Agraph_t *subg = S->g;
2321  S = pop(S);
2322  S->subg = subg;
2323  assert(subg);
2324 }
2325 
2326 static void freestack()
2327 {
2328  while (S) {
2329  deletelist(&(S->nodelist));
2330  deletelist(&(S->attrlist));
2331  deletelist(&(S->edgelist));
2332  S = pop(S);
2333  }
2334 }
2335 
2336 extern FILE *yyin;
2337 Agraph_t *agconcat(Agraph_t *g, void *chan, Agdisc_t *disc)
2338 {
2339  yyin = chan;
2340  G = g;
2342  Disc = (disc? disc : &AgDefaultDisc);
2343  aglexinit(Disc, chan);
2344  yyparse();
2345  if (Ag_G_global == NILgraph) aglexbad();
2346  return Ag_G_global;
2347 }
2348 
2349 Agraph_t *agread(void *fp, Agdisc_t *disc) {return agconcat(NILgraph,fp,disc); }
2350 
void s1(graph_t *, node_t *)
Definition: stuff.c:686
int yyresult
Definition: y.tab.c:1289
Agedge_t * e
Definition: grammar.c:82
YYSTYPE * yyvaluep
Definition: y.tab.c:1200
CGRAPH_API Agnode_t * agnode(Agraph_t *g, char *name, int createflag)
Definition: node.c:142
Definition: types.h:67
CGRAPH_API Agraph_t * agopen(char *name, Agdesc_t desc, Agdisc_t *disc)
Definition: graph.c:44
int yyparse()
Agraph_t * subg
Definition: grammar.c:102
#define T_strict
Definition: grammar.c:189
Agsym_t * agattr(Agraph_t *g, int kind, char *name, char *value)
Definition: attr.c:324
struct gstack_s gstack_t
#define T_edge
Definition: grammar.c:186
#define head
Definition: dthdr.h:19
struct Agnode_s * n
Definition: grammar.c:206
#define YY_NULL
Definition: y.tab.c:140
#define YYINITDEPTH
Definition: y.tab.c:930
yytype_int16 * yyssp
Definition: y.tab.c:1279
int yylen
Definition: y.tab.c:1307
int agxset(void *obj, Agsym_t *sym, char *value)
Definition: attr.c:468
Definition: utils.c:981
YYSTYPE yylval
item * last
Definition: grammar.c:97
#define YYSTACK_BYTES(N)
Definition: y.tab.c:411
#define T_subgraph
Definition: grammar.c:188
Agnode_t * n
Definition: grammar.c:80
int yychar
Definition: y.tab.c:1221
#define assert(x)
Definition: cghdr.h:47
#define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
Definition: y.tab.c:1225
int yyn
Definition: y.tab.c:1288
goto yysetstate
Definition: y.tab.c:1319
void aglexinit(Agdisc_t *disc, void *ifile)
Definition: scan.c:579
union YYSTYPE YYSTYPE
yydestruct("Cleanup: discarding lookahead", yytoken,&yylval)
CGRAPH_API Agraph_t * agread(void *chan, Agdisc_t *disc)
Definition: grammar.c:2349
#define yytable_value_is_error(Yytable_value)
Definition: y.tab.c:673
CGRAPH_API Agraph_t * agconcat(Agraph_t *g, void *chan, Agdisc_t *disc)
Definition: grammar.c:2337
#define YYID(N)
Definition: grammar.c:308
list_t nodelist
Definition: grammar.c:103
int agerr(agerrlevel_t level, const char *fmt,...)
Definition: agerror.c:141
Agraph_t * subg
Definition: grammar.c:81
int i
Definition: grammar.c:204
#define YYDPRINTF(Args)
Definition: grammar.c:921
int yytoken
Definition: y.tab.c:1291
#define NILsym
Definition: cghdr.h:59
#define YYUSE(E)
Definition: y.tab.c:301
char * str
Definition: grammar.c:205
char * name
Definition: grammar.c:84
CGRAPH_API void agfree(Agraph_t *g, void *ptr)
Definition: mem.c:89
struct list_s list_t
#define AGTYPE(obj)
Definition: cgraph.h:113
val_t u
Definition: grammar.c:90
Definition: cgraph.h:388
yytype_int16 * yyss
Definition: y.tab.c:1278
#define T_node
Definition: grammar.c:185
CGRAPH_API Agnode_t * agtail(Agedge_t *e)
Definition: edge.c:525
#define YYMAXDEPTH
Definition: y.tab.c:941
#define T_attr
Definition: grammar.c:192
#define YY_SYMBOL_PRINT(Title, Type, Value, Location)
Definition: grammar.c:922
CGRAPH_API Agraph_t * agsubg(Agraph_t *g, char *name, int cflag)
Definition: subg.c:52
CGRAPH_API Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Definition: node.c:45
#define NIL(t)
Definition: dthdr.h:13
int
Definition: grammar.c:1264
struct item_s * next
Definition: grammar.c:92
CGRAPH_API Agnode_t * aghead(Agedge_t *e)
Definition: edge.c:533
#define NILgraph
Definition: cghdr.h:56
yytype_int16 yyssa[YYINITDEPTH]
Definition: y.tab.c:1277
#define YYFINAL
Definition: y.tab.c:456
#define YYLEX
Definition: y.tab.c:759
yytype_int16 yyss_alloc
Definition: y.tab.c:402
#define T_graph
Definition: grammar.c:184
CGRAPH_API int agclose(Agraph_t *g)
Definition: graph.c:93
unsigned short int yytype_uint16
Definition: y.tab.c:262
#define YY_(Msgid)
Definition: y.tab.c:295
#define T_digraph
Definition: grammar.c:187
goto yydefault
Definition: y.tab.c:1411
YYSTYPE yyvs_alloc
Definition: y.tab.c:403
#define YYSTACK_RELOCATE(Stack_alloc, Stack)
Definition: y.tab.c:422
#define YY_INITIAL_VALUE(Value)
Definition: grammar.c:1229
#define YYSTACK_FREE
Definition: grammar.c:365
#define YY_REDUCE_PRINT(Rule)
Definition: grammar.c:924
CGRAPH_API int agstrfree(Agraph_t *, char *)
Definition: refstr.c:149
goto yybackup
Definition: y.tab.c:1398
#define YYPOPSTACK(N)
Definition: grammar.c:1303
CGRAPH_API char * agstrdup(Agraph_t *, char *)
Definition: refstr.c:97
EXTERN Agraph_t * Ag_G_global
Definition: cghdr.h:78
FILE * yyin
union s val_t
#define YYSIZE_T
Definition: y.tab.c:281
#define YY_IGNORE_MAYBE_UNINITIALIZED_END
Definition: y.tab.c:1226
CGRAPH_API Agnode_t * agfstnode(Agraph_t *g)
Definition: node.c:38
yystate
Definition: y.tab.c:1315
Definition: grammar.c:79
Agraph_t * g
Definition: grammar.c:101
#define YYEOF
Definition: y.tab.c:703
YYSTYPE * yyvs
Definition: y.tab.c:1283
#define AGNODE
Definition: cgraph.h:101
item * first
Definition: grammar.c:96
short int yytype_int16
Definition: y.tab.c:268
int tag
Definition: grammar.c:89
#define yypact_value_is_default(Yystate)
Definition: y.tab.c:670
#define push(s, x)
Definition: closest.c:63
#define YYABORT
Definition: y.tab.c:706
Definition: y.tab.c:400
yytokentype
Definition: y.tab.c:169
#define YYLAST
Definition: y.tab.c:458
#define T_qatom
Definition: grammar.c:194
list_t attrlist
Definition: grammar.c:103
unsigned maingraph
Definition: cgraph.h:154
#define streq(s, t)
Definition: cghdr.h:52
Agsym_t * asym
Definition: grammar.c:83
unsigned char print
Definition: cgraph.h:331
CGRAPH_API void aginternalmapclearlocalnames(Agraph_t *g)
Definition: imap.c:181
#define YYSTACK_ALLOC_MAXIMUM
Definition: y.tab.c:367
void aglexbad(void)
Definition: scan.c:2231
CGRAPH_API void * agalloc(Agraph_t *g, size_t size)
Definition: mem.c:62
struct gstack_s * down
Definition: grammar.c:104
struct item_s item
YYSIZE_T yystacksize
Definition: y.tab.c:1286
#define TAILPORT_ID
Definition: cgraph.h:415
#define T_atom
Definition: grammar.c:193
#define HEADPORT_ID
Definition: cgraph.h:416
#define T_edgeop
Definition: grammar.c:190
void aglexeof(void)
Definition: scan.c:2229
CGRAPH_API Agedge_t * agedge(Agraph_t *g, Agnode_t *t, Agnode_t *h, char *name, int createflag)
Definition: edge.c:281
goto yyerrlab1
Definition: y.tab.c:1817
unsigned strict
Definition: cgraph.h:152
short int yytype_int8
Definition: y.tab.c:256
int yytype
Definition: y.tab.c:1199
goto yyreturn
Definition: y.tab.c:1889
Definition: grammar.c:95
#define YYNTOKENS
Definition: y.tab.c:461
#define NILitem
Definition: y.tab.c:1944
YY_IGNORE_MAYBE_UNINITIALIZED_END goto yynewstate
Definition: y.tab.c:1463
int yyerrstatus
Definition: y.tab.c:1267
YYSTYPE yyval
Definition: y.tab.c:1294
agxbuf * str
Definition: htmlparse.c:85
CGRAPH_API Agdisc_t AgDefaultDisc
Definition: cgraph.h:201
unsigned char yytype_uint8
Definition: y.tab.c:247
goto yyreduce
Definition: y.tab.c:1473
#define YYEMPTY
Definition: y.tab.c:702
#define YYACCEPT
Definition: grammar.c:705
Definition: grammar.c:88
unsigned directed
Definition: cgraph.h:151
struct item_s * list
Definition: grammar.c:85
#define AGEDGE
Definition: cgraph.h:104
#define YYTERROR
Definition: y.tab.c:745
YYSTYPE * yyvsp
Definition: y.tab.c:1284
#define pop(s, x)
Definition: closest.c:71
int yynerrs
Definition: y.tab.c:1236
#define YY_STACK_PRINT(Bottom, Top)
Definition: grammar.c:923
void yyerror(char *)
char * str
Definition: grammar.c:91
#define FALSE
Definition: cgraph.h:35
CGRAPH_API Agnode_t * agsubnode(Agraph_t *g, Agnode_t *n, int createflag)
Definition: node.c:254
YYSTYPE yyvsa[YYINITDEPTH]
Definition: y.tab.c:1282
#define YYTRANSLATE(YYX)
Definition: y.tab.c:473
list_t edgelist
Definition: grammar.c:103
#define YYSTACK_ALLOC
Definition: y.tab.c:364
#define T_list
Definition: grammar.c:191
goto yyerrlab
Definition: y.tab.c:1472
#define AGRAPH
Definition: cgraph.h:100
#define TRUE
Definition: cgraph.h:38