Graphviz  2.41.20171026.1811
grammar.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 aag 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 aagerror(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 */
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 */
98 } list_t;
99 
100 typedef struct gstack_s {
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 aagdebug;
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. */
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 aagstype YYSTYPE /* obsolescent; will be withdrawn */
214 # define YYSTYPE_IS_DECLARED 1
215 #endif
216 
217 extern YYSTYPE aaglval;
218 
219 #ifdef YYPARSE_PARAM
220 #if defined __STDC__ || defined __cplusplus
221 int aagparse (void *YYPARSE_PARAM);
222 #else
223 int aagparse ();
224 #endif
225 #else /* ! YYPARSE_PARAM */
226 #if defined __STDC__ || defined __cplusplus
227 int aagparse (void);
228 #else
229 int aagparse ();
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 aagtype_uint8;
246 #else
247 typedef unsigned char aagtype_uint8;
248 #endif
249 
250 #ifdef YYTYPE_INT8
251 typedef YYTYPE_INT8 aagtype_int8;
252 #elif (defined __STDC__ || defined __C99__FUNC__ \
253  || defined __cplusplus || defined _MSC_VER)
254 typedef signed char aagtype_int8;
255 #else
256 typedef short int aagtype_int8;
257 #endif
258 
259 #ifdef YYTYPE_UINT16
260 typedef YYTYPE_UINT16 aagtype_uint16;
261 #else
262 typedef unsigned short int aagtype_uint16;
263 #endif
264 
265 #ifdef YYTYPE_INT16
266 typedef YYTYPE_INT16 aagtype_int16;
267 #else
268 typedef short int aagtype_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 aagi)
314 #else
315 static int
316 YYID (aagi)
317  int aagi;
318 #endif
319 {
320  return aagi;
321 }
322 #endif
323 
324 #if ! defined aagoverflow || 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 aagoverflow || YYERROR_VERBOSE */
393 
394 
395 #if (! defined aagoverflow \
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 aagalloc
401 {
404 };
405 
406 /* The size of the maximum gap between one aligned stack and the next. */
407 # define YYSTACK_GAP_MAXIMUM (sizeof (union aagalloc) - 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 (aagtype_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 aagnewbytes; \
426  YYCOPY (&aagptr->Stack_alloc, Stack, aagsize); \
427  Stack = &aagptr->Stack_alloc; \
428  aagnewbytes = aagstacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
429  aagptr += aagnewbytes / sizeof (*aagptr); \
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 aagi; \
447  for (aagi = 0; aagi < (Count); aagi++) \
448  (Dst)[aagi] = (Src)[aagi]; \
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 ? aagtranslate[YYX] : YYUNDEFTOK)
475 
476 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
477 static const aagtype_uint8 aagtranslate[] =
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 aagtype_uint8 aagprhs[] =
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 aagtype_int8 aagrhs[] =
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 aagtype_uint8 aagrline[] =
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 aagtname[] =
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 aagtype_uint16 aagtoknum[] =
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 aagtype_uint8 aagr1[] =
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 aagtype_uint8 aagr2[] =
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 aagtype_uint8 aagdefact[] =
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 aagtype_int8 aagdefgoto[] =
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 aagtype_int8 aagpact[] =
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 aagtype_int8 aagpgoto[] =
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 aagtype_int8 aagtable[] =
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 aagpact_value_is_default(Yystate) \
671  (!!((Yystate) == (-18)))
672 
673 #define aagtable_value_is_error(Yytable_value) \
674  YYID (0)
675 
676 static const aagtype_uint8 aagcheck[] =
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 aagtype_uint8 aagstos[] =
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 aagerrok (aagerrstatus = 0)
701 #define aagclearin (aagchar = YYEMPTY)
702 #define YYEMPTY (-2)
703 #define YYEOF 0
704 
705 #define YYACCEPT goto aagacceptlab
706 #define YYABORT goto aagabortlab
707 #define YYERROR goto aagerrorlab
708 
709 
710 /* Like YYERROR except do call aagerror. 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 aagerrlab
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() (!!aagerrstatus)
726 
727 #define YYBACKUP(Token, Value) \
728 do \
729  if (aagchar == YYEMPTY) \
730  { \
731  aagchar = (Token); \
732  aaglval = (Value); \
733  YYPOPSTACK (aaglen); \
734  aagstate = *aagssp; \
735  goto aagbackup; \
736  } \
737  else \
738  { \
739  aagerror (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 `aaglex' with the right arguments. */
756 #ifdef YYLEX_PARAM
757 # define YYLEX aaglex (YYLEX_PARAM)
758 #else
759 # define YYLEX aaglex ()
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 (aagdebug) \
773  YYFPRINTF Args; \
774 } while (YYID (0))
775 
776 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
777 do { \
778  if (aagdebug) \
779  { \
780  YYFPRINTF (stderr, "%s ", Title); \
781  aag_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 aag_symbol_value_print (FILE *aagoutput, int aagtype, YYSTYPE const * const aagvaluep)
797 #else
798 static void
799 aag_symbol_value_print (aagoutput, aagtype, aagvaluep)
800  FILE *aagoutput;
801  int aagtype;
802  YYSTYPE const * const aagvaluep;
803 #endif
804 {
805  FILE *aago = aagoutput;
806  YYUSE (aago);
807  if (!aagvaluep)
808  return;
809 # ifdef YYPRINT
810  if (aagtype < YYNTOKENS)
811  YYPRINT (aagoutput, aagtoknum[aagtype], *aagvaluep);
812 # else
813  YYUSE (aagoutput);
814 # endif
815  switch (aagtype)
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 aag_symbol_print (FILE *aagoutput, int aagtype, YYSTYPE const * const aagvaluep)
831 #else
832 static void
833 aag_symbol_print (aagoutput, aagtype, aagvaluep)
834  FILE *aagoutput;
835  int aagtype;
836  YYSTYPE const * const aagvaluep;
837 #endif
838 {
839  if (aagtype < YYNTOKENS)
840  YYFPRINTF (aagoutput, "token %s (", aagtname[aagtype]);
841  else
842  YYFPRINTF (aagoutput, "nterm %s (", aagtname[aagtype]);
843 
844  aag_symbol_value_print (aagoutput, aagtype, aagvaluep);
845  YYFPRINTF (aagoutput, ")");
846 }
847 
848 /*------------------------------------------------------------------.
849 | aag_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 aag_stack_print (aagtype_int16 *aagbottom, aagtype_int16 *aagtop)
857 #else
858 static void
859 aag_stack_print (aagbottom, aagtop)
860  aagtype_int16 *aagbottom;
861  aagtype_int16 *aagtop;
862 #endif
863 {
864  YYFPRINTF (stderr, "Stack now");
865  for (; aagbottom <= aagtop; aagbottom++)
866  {
867  int aagbot = *aagbottom;
868  YYFPRINTF (stderr, " %d", aagbot);
869  }
870  YYFPRINTF (stderr, "\n");
871 }
872 
873 # define YY_STACK_PRINT(Bottom, Top) \
874 do { \
875  if (aagdebug) \
876  aag_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 aag_reduce_print (YYSTYPE *aagvsp, int aagrule)
888 #else
889 static void
890 aag_reduce_print (aagvsp, aagrule)
891  YYSTYPE *aagvsp;
892  int aagrule;
893 #endif
894 {
895  int aagnrhs = aagr2[aagrule];
896  int aagi;
897  uint64_t aaglno = aagrline[aagrule];
898  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
899  aagrule - 1, aaglno);
900  /* The symbols being reduced. */
901  for (aagi = 0; aagi < aagnrhs; aagi++)
902  {
903  YYFPRINTF (stderr, " $%d = ", aagi + 1);
904  aag_symbol_print (stderr, aagrhs[aagprhs[aagrule] + aagi],
905  &(aagvsp[(aagi + 1) - (aagnrhs)])
906  );
907  YYFPRINTF (stderr, "\n");
908  }
909 }
910 
911 # define YY_REDUCE_PRINT(Rule) \
912 do { \
913  if (aagdebug) \
914  aag_reduce_print (aagvsp, 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 aagdebug;
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 aagstrlen
948 # if defined __GLIBC__ && defined _STRING_H
949 # define aagstrlen 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 aagstrlen (const char *aagstr)
956 #else
957 static YYSIZE_T
958 aagstrlen (aagstr)
959  const char *aagstr;
960 #endif
961 {
963  for (aaglen = 0; aagstr[aaglen]; aaglen++)
964  continue;
965  return aaglen;
966 }
967 # endif
968 # endif
969 
970 # ifndef aagstpcpy
971 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
972 # define aagstpcpy 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 aagstpcpy (char *aagdest, const char *aagsrc)
980 #else
981 static char *
982 aagstpcpy (aagdest, aagsrc)
983  char *aagdest;
984  const char *aagsrc;
985 #endif
986 {
987  char *aagd = aagdest;
988  const char *aags = aagsrc;
989 
990  while ((*aagd++ = *aags++) != '\0')
991  continue;
992 
993  return aagd - 1;
994 }
995 # endif
996 # endif
997 
998 # ifndef aagtnamerr
999 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1000  quotes and backslashes, so that it's suitable for aagerror. 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 aagtname. 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 aagtnamerr (char *aagres, const char *aagstr)
1008 {
1009  if (*aagstr == '"')
1010  {
1011  YYSIZE_T aagn = 0;
1012  char const *aagp = aagstr;
1013 
1014  for (;;)
1015  switch (*++aagp)
1016  {
1017  case '\'':
1018  case ',':
1019  goto do_not_strip_quotes;
1020 
1021  case '\\':
1022  if (*++aagp != '\\')
1023  goto do_not_strip_quotes;
1024  /* Fall through. */
1025  default:
1026  if (aagres)
1027  aagres[aagn] = *aagp;
1028  aagn++;
1029  break;
1030 
1031  case '"':
1032  if (aagres)
1033  aagres[aagn] = '\0';
1034  return aagn;
1035  }
1036  do_not_strip_quotes: ;
1037  }
1038 
1039  if (! aagres)
1040  return aagstrlen (aagstr);
1041 
1042  return aagstpcpy (aagres, aagstr) - aagres;
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 aagsyntax_error (YYSIZE_T *aagmsg_alloc, char **aagmsg,
1057 {
1058  YYSIZE_T aagsize0 = aagtnamerr (YY_NULL, aagtname[aagtoken]);
1059  YYSIZE_T aagsize = aagsize0;
1060  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1061  /* Internationalized format string. */
1062  const char *aagformat = YY_NULL;
1063  /* Arguments of aagformat. */
1064  char const *aagarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1065  /* Number of reported tokens (one for the "unexpected", one per
1066  "expected"). */
1067  int aagcount = 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 aagchar) 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 aagchar.
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 (aagtoken != YYEMPTY)
1097  {
1098  int aagn = aagpact[*aagssp];
1099  aagarg[aagcount++] = aagtname[aagtoken];
1100  if (!aagpact_value_is_default (aagn))
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 aagxbegin = aagn < 0 ? -aagn : 0;
1106  /* Stay within bounds of both aagcheck and aagtname. */
1107  int aagchecklim = YYLAST - aagn + 1;
1108  int aagxend = aagchecklim < YYNTOKENS ? aagchecklim : YYNTOKENS;
1109  int aagx;
1110 
1111  for (aagx = aagxbegin; aagx < aagxend; ++aagx)
1112  if (aagcheck[aagx + aagn] == aagx && aagx != YYTERROR
1113  && !aagtable_value_is_error (aagtable[aagx + aagn]))
1114  {
1115  if (aagcount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1116  {
1117  aagcount = 1;
1118  aagsize = aagsize0;
1119  break;
1120  }
1121  aagarg[aagcount++] = aagtname[aagx];
1122  {
1123  YYSIZE_T aagsize1 = aagsize + aagtnamerr (YY_NULL, aagtname[aagx]);
1124  if (! (aagsize <= aagsize1
1125  && aagsize1 <= YYSTACK_ALLOC_MAXIMUM))
1126  return 2;
1127  aagsize = aagsize1;
1128  }
1129  }
1130  }
1131  }
1132 
1133  switch (aagcount)
1134  {
1135 # define YYCASE_(N, S) \
1136  case N: \
1137  aagformat = 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 aagsize1 = aagsize + aagstrlen (aagformat);
1150  if (! (aagsize <= aagsize1 && aagsize1 <= YYSTACK_ALLOC_MAXIMUM))
1151  return 2;
1152  aagsize = aagsize1;
1153  }
1154 
1155  if (*aagmsg_alloc < aagsize)
1156  {
1157  *aagmsg_alloc = 2 * aagsize;
1158  if (! (aagsize <= *aagmsg_alloc
1159  && *aagmsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1160  *aagmsg_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 *aagp = *aagmsg;
1169  int aagi = 0;
1170  while ((*aagp = *aagformat) != '\0')
1171  if (*aagp == '%' && aagformat[1] == 's' && aagi < aagcount)
1172  {
1173  aagp += aagtnamerr (aagp, aagarg[aagi++]);
1174  aagformat += 2;
1175  }
1176  else
1177  {
1178  aagp++;
1179  aagformat++;
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 aagdestruct (const char *aagmsg, int aagtype, YYSTYPE *aagvaluep)
1195 #else
1196 static void
1197 aagdestruct (aagmsg, aagtype, aagvaluep)
1198  const char *aagmsg;
1199  int aagtype;
1200  YYSTYPE *aagvaluep;
1201 #endif
1202 {
1203  YYUSE (aagvaluep);
1204 
1205  if (!aagmsg)
1206  aagmsg = "Deleting";
1207  YY_SYMBOL_PRINT (aagmsg, aagtype, aagvaluep, aaglocationp);
1208 
1209  switch (aagtype)
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 aaglval YY_INITIAL_VALUE(aagval_default);
1234 
1235 /* Number of syntax errors so far. */
1237 
1238 
1239 /*----------.
1240 | aagparse. |
1241 `----------*/
1242 
1243 #ifdef YYPARSE_PARAM
1244 #if (defined __STDC__ || defined __C99__FUNC__ \
1245  || defined __cplusplus || defined _MSC_VER)
1246 int
1247 aagparse (void *YYPARSE_PARAM)
1248 #else
1249 int
1250 aagparse (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 aagparse (void)
1258 #else
1259 int
1260 aagparse ()
1261 
1262 #endif
1263 #endif
1265  int aagstate;
1266  /* Number of tokens to shift before error messages enabled. */
1268 
1269  /* The stacks and their tools:
1270  `aagss': related to states.
1271  `aagvs': related to semantic values.
1272 
1273  Refer to the stacks through separate pointers, to allow aagoverflow
1274  to reallocate them elsewhere. */
1275 
1276  /* The state stack. */
1280 
1281  /* The semantic value stack. */
1285 
1287 
1288  int aagn;
1290  /* Lookahead token as an internal (translated) token number. */
1291  int aagtoken = 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 aagmsgbuf[128];
1299  char *aagmsg = aagmsgbuf;
1300  YYSIZE_T aagmsg_alloc = sizeof aagmsgbuf;
1301 #endif
1302 
1303 #define YYPOPSTACK(N) (aagvsp -= (N), aagssp -= (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 aaglen = 0;
1308 
1309  aagssp = aagss = aagssa;
1310  aagvsp = aagvs = aagvsa;
1311  aagstacksize = YYINITDEPTH;
1312 
1313  YYDPRINTF ((stderr, "Starting parse\n"));
1314 
1315  aagstate = 0;
1316  aagerrstatus = 0;
1317  aagnerrs = 0;
1318  aagchar = YYEMPTY; /* Cause a token to be read. */
1320 
1321 /*------------------------------------------------------------.
1322 | aagnewstate -- Push a new state, which is found in aagstate. |
1323 `------------------------------------------------------------*/
1324  aagnewstate:
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  aagssp++;
1328 
1329  aagsetstate:
1330  *aagssp = aagstate;
1331 
1332  if (aagss + aagstacksize - 1 <= aagssp)
1333  {
1334  /* Get the current used size of the three stacks, in elements. */
1335  YYSIZE_T aagsize = aagssp - aagss + 1;
1336 
1337 #ifdef aagoverflow
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 *aagvs1 = aagvs;
1343  aagtype_int16 *aagss1 = aagss;
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 aagoverflow is a macro. */
1349  aagoverflow (YY_("memory exhausted"),
1350  &aagss1, aagsize * sizeof (*aagssp),
1351  &aagvs1, aagsize * sizeof (*aagvsp),
1352  &aagstacksize);
1353 
1354  aagss = aagss1;
1355  aagvs = aagvs1;
1356  }
1357 #else /* no aagoverflow */
1358 # ifndef YYSTACK_RELOCATE
1359  goto aagexhaustedlab;
1360 # else
1361  /* Extend the stack our own way. */
1362  if (YYMAXDEPTH <= aagstacksize)
1363  goto aagexhaustedlab;
1364  aagstacksize *= 2;
1365  if (YYMAXDEPTH < aagstacksize)
1366  aagstacksize = YYMAXDEPTH;
1367 
1368  {
1369  aagtype_int16 *aagss1 = aagss;
1370  union aagalloc *aagptr =
1371  (union aagalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (aagstacksize));
1372  if (! aagptr)
1373  goto aagexhaustedlab;
1374  YYSTACK_RELOCATE (aagss_alloc, aagss);
1375  YYSTACK_RELOCATE (aagvs_alloc, aagvs);
1376 # undef YYSTACK_RELOCATE
1377  if (aagss1 != aagssa)
1378  YYSTACK_FREE (aagss1);
1379  }
1380 # endif
1381 #endif /* no aagoverflow */
1382 
1383  aagssp = aagss + aagsize - 1;
1384  aagvsp = aagvs + aagsize - 1;
1385 
1386  YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1387  (uint64_t) aagstacksize));
1388 
1389  if (aagss + aagstacksize - 1 <= aagssp)
1390  YYABORT;
1391  }
1392 
1393  YYDPRINTF ((stderr, "Entering state %d\n", aagstate));
1394 
1395  if (aagstate == YYFINAL)
1397 
1399 
1400 /*-----------.
1401 | aagbackup. |
1402 `-----------*/
1403 aagbackup:
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  aagn = aagpact[aagstate];
1410  if (aagpact_value_is_default (aagn))
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 (aagchar == YYEMPTY)
1417  {
1418  YYDPRINTF ((stderr, "Reading a token: "));
1419  aagchar = YYLEX;
1420  }
1421 
1422  if (aagchar <= YYEOF)
1423  {
1424  aagchar = aagtoken = YYEOF;
1425  YYDPRINTF ((stderr, "Now at end of input.\n"));
1426  }
1427  else
1428  {
1429  aagtoken = YYTRANSLATE (aagchar);
1430  YY_SYMBOL_PRINT ("Next token is", aagtoken, &aaglval, &aaglloc);
1431  }
1432 
1433  /* If the proper action on seeing token YYTOKEN is to reduce or to
1434  detect an error, take that action. */
1435  aagn += aagtoken;
1436  if (aagn < 0 || YYLAST < aagn || aagcheck[aagn] != aagtoken)
1437  goto aagdefault;
1438  aagn = aagtable[aagn];
1439  if (aagn <= 0)
1440  {
1441  if (aagtable_value_is_error (aagn))
1442  goto aagerrlab;
1443  aagn = -aagn;
1444  goto aagreduce;
1445  }
1446 
1447  /* Count tokens shifted since error; after three, turn off error
1448  status. */
1449  if (aagerrstatus)
1450  aagerrstatus--;
1451 
1452  /* Shift the lookahead token. */
1453  YY_SYMBOL_PRINT ("Shifting", aagtoken, &aaglval, &aaglloc);
1454 
1455  /* Discard the shifted token. */
1456  aagchar = YYEMPTY;
1457 
1458  aagstate = aagn;
1460  *++aagvsp = aaglval;
1462 
1464 
1465 
1466 /*-----------------------------------------------------------.
1467 | aagdefault -- do the default action for the current state. |
1468 `-----------------------------------------------------------*/
1469 aagdefault:
1470  aagn = aagdefact[aagstate];
1471  if (aagn == 0)
1474 
1475 
1476 /*-----------------------------.
1477 | aagreduce -- Do a reduction. |
1478 `-----------------------------*/
1479 aagreduce:
1480  /* aagn is the number of a rule to reduce with. */
1481  aaglen = aagr2[aagn];
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  aagval = aagvsp[1-aaglen];
1492 
1493 
1494  YY_REDUCE_PRINT (aagn);
1495  switch (aagn)
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((aagvsp[(3) - (3)].str),(aagvsp[(2) - (3)].i),(aagvsp[(1) - (3)].i));}
1513  break;
1514 
1515  case 7:
1516 /* Line 1792 of yacc.c */
1517 #line 108 "../../lib/cgraph/grammar.y"
1518  {(aagval.str)=(aagvsp[(1) - (1)].str);}
1519  break;
1520 
1521  case 8:
1522 /* Line 1792 of yacc.c */
1523 #line 108 "../../lib/cgraph/grammar.y"
1524  {(aagval.str)=0;}
1525  break;
1526 
1527  case 9:
1528 /* Line 1792 of yacc.c */
1529 #line 110 "../../lib/cgraph/grammar.y"
1530  {(aagval.i)=1;}
1531  break;
1532 
1533  case 10:
1534 /* Line 1792 of yacc.c */
1535 #line 110 "../../lib/cgraph/grammar.y"
1536  {(aagval.i)=0;}
1537  break;
1538 
1539  case 11:
1540 /* Line 1792 of yacc.c */
1541 #line 112 "../../lib/cgraph/grammar.y"
1542  {(aagval.i) = 0;}
1543  break;
1544 
1545  case 12:
1546 /* Line 1792 of yacc.c */
1547 #line 112 "../../lib/cgraph/grammar.y"
1548  {(aagval.i) = 1;}
1549  break;
1550 
1551  case 21:
1552 /* Line 1792 of yacc.c */
1553 #line 125 "../../lib/cgraph/grammar.y"
1554  {if ((aagvsp[(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  {(aagval.i) = 1;}
1573  break;
1574 
1575  case 27:
1576 /* Line 1792 of yacc.c */
1577 #line 131 "../../lib/cgraph/grammar.y"
1578  {(aagval.i) = 0;}
1579  break;
1580 
1581  case 30:
1582 /* Line 1792 of yacc.c */
1583 #line 137 "../../lib/cgraph/grammar.y"
1584  {appendnode((aagvsp[(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((aagvsp[(1) - (3)].str),(aagvsp[(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((aagvsp[(1) - (5)].str),(aagvsp[(3) - (5)].str),(aagvsp[(5) - (5)].str));}
1597  break;
1598 
1599  case 33:
1600 /* Line 1792 of yacc.c */
1601 #line 142 "../../lib/cgraph/grammar.y"
1602  {attrstmt((aagvsp[(1) - (3)].i),(aagvsp[(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  {(aagval.i) = T_graph;}
1615  break;
1616 
1617  case 36:
1618 /* Line 1792 of yacc.c */
1619 #line 147 "../../lib/cgraph/grammar.y"
1620  {(aagval.i) = T_node;}
1621  break;
1622 
1623  case 37:
1624 /* Line 1792 of yacc.c */
1625 #line 148 "../../lib/cgraph/grammar.y"
1626  {(aagval.i) = T_edge;}
1627  break;
1628 
1629  case 38:
1630 /* Line 1792 of yacc.c */
1631 #line 151 "../../lib/cgraph/grammar.y"
1632  {(aagval.str) = (aagvsp[(1) - (2)].str);}
1633  break;
1634 
1635  case 39:
1636 /* Line 1792 of yacc.c */
1637 #line 152 "../../lib/cgraph/grammar.y"
1638  {(aagval.str) = NIL(char*); }
1639  break;
1640 
1641  case 48:
1642 /* Line 1792 of yacc.c */
1643 #line 167 "../../lib/cgraph/grammar.y"
1644  {appendattr((aagvsp[(1) - (3)].str),(aagvsp[(3) - (3)].str));}
1645  break;
1646 
1647  case 49:
1648 /* Line 1792 of yacc.c */
1649 #line 170 "../../lib/cgraph/grammar.y"
1650  {appendattr((aagvsp[(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((aagvsp[(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  {(aagval.str)=(aagvsp[(2) - (2)].str);}
1669  break;
1670 
1671  case 54:
1672 /* Line 1792 of yacc.c */
1673 #line 180 "../../lib/cgraph/grammar.y"
1674  {(aagval.str)=NIL(char*);}
1675  break;
1676 
1677  case 55:
1678 /* Line 1792 of yacc.c */
1679 #line 181 "../../lib/cgraph/grammar.y"
1680  {(aagval.str)=NIL(char*);}
1681  break;
1682 
1683  case 59:
1684 /* Line 1792 of yacc.c */
1685 #line 186 "../../lib/cgraph/grammar.y"
1686  {(aagval.str) = (aagvsp[(1) - (1)].str);}
1687  break;
1688 
1689  case 60:
1690 /* Line 1792 of yacc.c */
1691 #line 187 "../../lib/cgraph/grammar.y"
1692  {(aagval.str) = (aagvsp[(1) - (1)].str);}
1693  break;
1694 
1695  case 61:
1696 /* Line 1792 of yacc.c */
1697 #line 190 "../../lib/cgraph/grammar.y"
1698  {(aagval.str) = (aagvsp[(1) - (1)].str);}
1699  break;
1700 
1701  case 62:
1702 /* Line 1792 of yacc.c */
1703 #line 191 "../../lib/cgraph/grammar.y"
1704  {(aagval.str) = concat((aagvsp[(1) - (3)].str),(aagvsp[(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 aagchar, and that requires
1713  that aagtoken be updated with the new translation. We take the
1714  approach of translating immediately before every use of aagtoken.
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 aagchar 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 ("-> $$ =", aagr1[aagn], &aagval, &aagloc);
1724 
1725  YYPOPSTACK (aaglen);
1726  aaglen = 0;
1727  YY_STACK_PRINT (aagss, aagssp);
1728 
1729  *++aagvsp = aagval;
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  aagn = aagr1[aagn];
1736 
1737  aagstate = aagpgoto[aagn - YYNTOKENS] + *aagssp;
1738  if (0 <= aagstate && aagstate <= YYLAST && aagcheck[aagstate] == *aagssp)
1739  aagstate = aagtable[aagstate];
1740  else
1741  aagstate = aagdefgoto[aagn - YYNTOKENS];
1742 
1743  goto aagnewstate;
1744 
1745 
1746 /*------------------------------------.
1747 | aagerrlab -- here on detecting error |
1748 `------------------------------------*/
1749 aagerrlab:
1750  /* Make sure we have latest lookahead translation. See comments at
1751  user semantic actions for why this is necessary. */
1752  aagtoken = aagchar == YYEMPTY ? YYEMPTY : YYTRANSLATE (aagchar);
1753 
1754  /* If not already recovering from an error, report this error. */
1755  if (!aagerrstatus)
1756  {
1757  ++aagnerrs;
1758 #if ! YYERROR_VERBOSE
1759  aagerror (YY_("syntax error"));
1760 #else
1761 # define YYSYNTAX_ERROR aagsyntax_error (&aagmsg_alloc, &aagmsg, \
1762  aagssp, aagtoken)
1763  {
1764  char const *aagmsgp = YY_("syntax error");
1765  int aagsyntax_error_status;
1766  aagsyntax_error_status = YYSYNTAX_ERROR;
1767  if (aagsyntax_error_status == 0)
1768  aagmsgp = aagmsg;
1769  else if (aagsyntax_error_status == 1)
1770  {
1771  if (aagmsg != aagmsgbuf)
1772  YYSTACK_FREE (aagmsg);
1773  aagmsg = (char *) YYSTACK_ALLOC (aagmsg_alloc);
1774  if (!aagmsg)
1775  {
1776  aagmsg = aagmsgbuf;
1777  aagmsg_alloc = sizeof aagmsgbuf;
1778  aagsyntax_error_status = 2;
1779  }
1780  else
1781  {
1782  aagsyntax_error_status = YYSYNTAX_ERROR;
1783  aagmsgp = aagmsg;
1784  }
1785  }
1786  aagerror (aagmsgp);
1787  if (aagsyntax_error_status == 2)
1788  goto aagexhaustedlab;
1789  }
1790 # undef YYSYNTAX_ERROR
1791 #endif
1792  }
1793 
1794 
1795 
1796  if (aagerrstatus == 3)
1797  {
1798  /* If just tried and failed to reuse lookahead token after an
1799  error, discard it. */
1800 
1801  if (aagchar <= YYEOF)
1802  {
1803  /* Return failure if at end of input. */
1804  if (aagchar == YYEOF)
1805  YYABORT;
1806  }
1807  else
1808  {
1809  aagdestruct ("Error: discarding",
1810  aagtoken, &aaglval);
1811  aagchar = YYEMPTY;
1812  }
1813  }
1814 
1815  /* Else will try to reuse lookahead token after shifting the error
1816  token. */
1818 
1819 
1820 /*---------------------------------------------------.
1821 | aagerrorlab -- error raised explicitly by YYERROR. |
1822 `---------------------------------------------------*/
1823 aagerrorlab:
1824 
1825  /* Pacify compilers like GCC when the user code never invokes
1826  YYERROR and the label aagerrorlab therefore never appears in user
1827  code. */
1828  if (/*CONSTCOND*/ 0)
1829  goto aagerrorlab;
1830 
1831  /* Do not reclaim the symbols of the rule which action triggered
1832  this YYERROR. */
1833  YYPOPSTACK (aaglen);
1834  aaglen = 0;
1835  YY_STACK_PRINT (aagss, aagssp);
1836  aagstate = *aagssp;
1837  goto aagerrlab1;
1838 
1839 
1840 /*-------------------------------------------------------------.
1841 | aagerrlab1 -- common code for both syntax error and YYERROR. |
1842 `-------------------------------------------------------------*/
1843 aagerrlab1:
1844  aagerrstatus = 3; /* Each real token shifted decrements this. */
1845 
1846  for (;;)
1847  {
1848  aagn = aagpact[aagstate];
1849  if (!aagpact_value_is_default (aagn))
1850  {
1851  aagn += YYTERROR;
1852  if (0 <= aagn && aagn <= YYLAST && aagcheck[aagn] == YYTERROR)
1853  {
1854  aagn = aagtable[aagn];
1855  if (0 < aagn)
1856  break;
1857  }
1858  }
1859 
1860  /* Pop the current state because it cannot handle the error token. */
1861  if (aagssp == aagss)
1862  YYABORT;
1863 
1864 
1865  aagdestruct ("Error: popping",
1866  aagstos[aagstate], aagvsp);
1867  YYPOPSTACK (1);
1868  aagstate = *aagssp;
1869  YY_STACK_PRINT (aagss, aagssp);
1870  }
1871 
1873  *++aagvsp = aaglval;
1875 
1876 
1877  /* Shift the error token. */
1878  YY_SYMBOL_PRINT ("Shifting", aagstos[aagn], aagvsp, aaglsp);
1879 
1880  aagstate = aagn;
1881  goto aagnewstate;
1882 
1883 
1884 /*-------------------------------------.
1885 | aagacceptlab -- YYACCEPT comes here. |
1886 `-------------------------------------*/
1887 aagacceptlab:
1888  aagresult = 0;
1890 
1891 /*-----------------------------------.
1892 | aagabortlab -- YYABORT comes here. |
1893 `-----------------------------------*/
1894 aagabortlab:
1895  aagresult = 1;
1896  goto aagreturn;
1897 
1898 #if !defined aagoverflow || YYERROR_VERBOSE
1899 /*-------------------------------------------------.
1900 | aagexhaustedlab -- memory exhaustion comes here. |
1901 `-------------------------------------------------*/
1902 aagexhaustedlab:
1903  aagerror (YY_("memory exhausted"));
1904  aagresult = 2;
1905  /* Fall through. */
1906 #endif
1907 
1908 aagreturn:
1909  if (aagchar != YYEMPTY)
1910  {
1911  /* Make sure we have latest lookahead translation. See comments at
1912  user semantic actions for why this is necessary. */
1913  aagtoken = YYTRANSLATE (aagchar);
1914  aagdestruct ("Cleanup: discarding lookahead",
1915  aagtoken, &aaglval);
1916  }
1917  /* Do not reclaim the symbols of the rule which action triggered
1918  this YYABORT or YYACCEPT. */
1919  YYPOPSTACK (aaglen);
1920  YY_STACK_PRINT (aagss, aagssp);
1921  while (aagssp != aagss)
1922  {
1923  aagdestruct ("Cleanup: popping",
1924  aagstos[*aagssp], aagvsp);
1925  YYPOPSTACK (1);
1926  }
1927 #ifndef aagoverflow
1928  if (aagss != aagssa)
1929  YYSTACK_FREE (aagss);
1930 #endif
1931 #if YYERROR_VERBOSE
1932  if (aagmsg != aagmsgbuf)
1933  YYSTACK_FREE (aagmsg);
1934 #endif
1935  /* Make sure YYID is used. */
1936  return YYID (aagresult);
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 *aagin;
2337 Agraph_t *agconcat(Agraph_t *g, void *chan, Agdisc_t *disc)
2338 {
2339  aagin = chan;
2340  G = g;
2342  Disc = (disc? disc : &AgDefaultDisc);
2343  aglexinit(Disc, chan);
2344  aagparse();
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
Agedge_t * e
Definition: grammar.c:82
CGRAPH_API Agnode_t * agnode(Agraph_t *g, char *name, int createflag)
Definition: node.c:142
unsigned short int aagtype_uint16
Definition: grammar.c:262
Definition: types.h:67
CGRAPH_API Agraph_t * agopen(char *name, Agdesc_t desc, Agdisc_t *disc)
Definition: graph.c:44
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
YYSTYPE * aagvaluep
Definition: grammar.c:1200
aagtype_int16 * aagssp
Definition: grammar.c:1279
struct gstack_s gstack_t
#define T_edge
Definition: grammar.c:186
#define NILitem
Definition: grammar.c:1944
aagdestruct("Cleanup: discarding lookahead", aagtoken,&aaglval)
#define head
Definition: dthdr.h:19
int aagerrstatus
Definition: grammar.c:1267
YYSTYPE aagval
Definition: grammar.c:1294
struct Agnode_s * n
Definition: grammar.c:206
#define YYLAST
Definition: grammar.c:458
YYSTYPE * aagvsp
Definition: grammar.c:1284
goto aagerrlab
Definition: grammar.c:1472
#define YYSTACK_ALLOC_MAXIMUM
Definition: grammar.c:367
int agxset(void *obj, Agsym_t *sym, char *value)
Definition: attr.c:468
Definition: utils.c:981
#define YYSTACK_RELOCATE(Stack_alloc, Stack)
Definition: grammar.c:422
item * last
Definition: grammar.c:97
#define T_subgraph
Definition: grammar.c:188
goto aagsetstate
Definition: grammar.c:1319
Agnode_t * n
Definition: grammar.c:80
#define assert(x)
Definition: cghdr.h:47
#define aagpact_value_is_default(Yystate)
Definition: grammar.c:670
#define YYSTACK_BYTES(N)
Definition: grammar.c:411
void aglexinit(Agdisc_t *disc, void *ifile)
Definition: scan.c:579
#define YYUSE(E)
Definition: grammar.c:301
union YYSTYPE YYSTYPE
CGRAPH_API Agraph_t * agread(void *chan, Agdisc_t *disc)
Definition: grammar.c:2349
YYSTYPE aagvs_alloc
Definition: grammar.c:403
YY_IGNORE_MAYBE_UNINITIALIZED_END goto aagnewstate
Definition: grammar.c:1463
CGRAPH_API Agraph_t * agconcat(Agraph_t *g, void *chan, Agdisc_t *disc)
Definition: grammar.c:2337
int aagparse(void)
#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
goto aagerrlab1
Definition: grammar.c:1817
int i
Definition: grammar.c:204
#define YYDPRINTF(Args)
Definition: grammar.c:921
#define YYFINAL
Definition: grammar.c:456
short int aagtype_int16
Definition: grammar.c:268
int aagtoken
Definition: grammar.c:1291
#define NILsym
Definition: cghdr.h:59
int aaglen
Definition: grammar.c:1307
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
#define T_node
Definition: grammar.c:185
CGRAPH_API Agnode_t * agtail(Agedge_t *e)
Definition: edge.c:525
#define T_attr
Definition: grammar.c:192
#define YYTRANSLATE(YYX)
Definition: grammar.c:473
#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
#define YYABORT
Definition: grammar.c:706
CGRAPH_API Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Definition: node.c:45
#define NIL(t)
Definition: dthdr.h:13
int aagn
Definition: grammar.c:1288
int aagchar
Definition: grammar.c:1221
int
Definition: grammar.c:1264
#define YYEOF
Definition: grammar.c:703
struct item_s * next
Definition: grammar.c:92
CGRAPH_API Agnode_t * aghead(Agedge_t *e)
Definition: edge.c:533
goto aagreduce
Definition: grammar.c:1473
#define NILgraph
Definition: cghdr.h:56
#define YYLEX
Definition: grammar.c:759
#define T_graph
Definition: grammar.c:184
CGRAPH_API int agclose(Agraph_t *g)
Definition: graph.c:93
#define YY_(Msgid)
Definition: grammar.c:295
aagtype_int16 aagss_alloc
Definition: grammar.c:402
YYSIZE_T aagstacksize
Definition: grammar.c:1286
#define YYSIZE_T
Definition: grammar.c:281
#define T_digraph
Definition: grammar.c:187
#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
#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
unsigned char aagtype_uint8
Definition: grammar.c:247
int aagresult
Definition: grammar.c:1289
#define YY_NULL
Definition: grammar.c:140
union s val_t
CGRAPH_API Agnode_t * agfstnode(Agraph_t *g)
Definition: node.c:38
Definition: grammar.c:79
Agraph_t * g
Definition: grammar.c:101
#define YYMAXDEPTH
Definition: grammar.c:941
#define AGNODE
Definition: cgraph.h:101
item * first
Definition: grammar.c:96
int tag
Definition: grammar.c:89
#define push(s, x)
Definition: closest.c:63
#define YYNTOKENS
Definition: grammar.c:461
YYSTYPE aaglval
void aagerror(char *)
Definition: scan.c:2176
#define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
Definition: grammar.c:1225
#define aagtable_value_is_error(Yytable_value)
Definition: grammar.c:673
#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 YYEMPTY
Definition: grammar.c:702
aagtype_int16 aagssa[YYINITDEPTH]
Definition: grammar.c:1277
void aglexbad(void)
Definition: scan.c:2231
CGRAPH_API void * agalloc(Agraph_t *g, size_t size)
Definition: mem.c:62
YYSTYPE aagvsa[YYINITDEPTH]
Definition: grammar.c:1282
struct gstack_s * down
Definition: grammar.c:104
int aagnerrs
Definition: grammar.c:1236
struct item_s item
#define TAILPORT_ID
Definition: cgraph.h:415
YYSTYPE * aagvs
Definition: grammar.c:1283
#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
int aagtype
Definition: grammar.c:1199
CGRAPH_API Agedge_t * agedge(Agraph_t *g, Agnode_t *t, Agnode_t *h, char *name, int createflag)
Definition: edge.c:281
short int aagtype_int8
Definition: grammar.c:256
unsigned strict
Definition: cgraph.h:152
#define YYSTACK_ALLOC
Definition: grammar.c:364
goto aagreturn
Definition: grammar.c:1889
Definition: grammar.c:95
FILE * aagin
Definition: scan.c:337
agxbuf * str
Definition: htmlparse.c:85
CGRAPH_API Agdisc_t AgDefaultDisc
Definition: cgraph.h:201
#define YYINITDEPTH
Definition: grammar.c:930
goto aagbackup
Definition: grammar.c:1398
#define YYACCEPT
Definition: grammar.c:705
Definition: grammar.c:88
aagtype_int16 * aagss
Definition: grammar.c:1278
unsigned directed
Definition: cgraph.h:151
struct item_s * list
Definition: grammar.c:85
#define AGEDGE
Definition: cgraph.h:104
goto aagdefault
Definition: grammar.c:1411
#define YYTERROR
Definition: grammar.c:745
#define pop(s, x)
Definition: closest.c:71
aagtokentype
Definition: grammar.c:169
#define YY_STACK_PRINT(Bottom, Top)
Definition: grammar.c:923
#define YY_IGNORE_MAYBE_UNINITIALIZED_END
Definition: grammar.c:1226
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
list_t edgelist
Definition: grammar.c:103
#define T_list
Definition: grammar.c:191
aagstate
Definition: grammar.c:1315
#define AGRAPH
Definition: cgraph.h:100
#define TRUE
Definition: cgraph.h:38