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