| 1 | /* A Bison parser, made by GNU Bison 3.0.4. */ |
| 2 | |
| 3 | /* Bison implementation for Yacc-like parsers in C |
| 4 | |
| 5 | Copyright (C) 1984, 1989-1990, 2000-2015 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 gml 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 "3.0.4" |
| 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 14 "gmlparse.y" /* yacc.c:339 */ |
| 66 | |
| 67 | #include <stdlib.h> |
| 68 | #include <stddef.h> |
| 69 | #include <string.h> |
| 70 | #include <arith.h> |
| 71 | #include <gml2gv.h> |
| 72 | #include <agxbuf.h> |
| 73 | #include <assert.h> |
| 74 | |
| 75 | #define NEW(t) (t*)malloc(sizeof(t)) |
| 76 | #define N_NEW(n,t) (t*)malloc((n)*sizeof(t)) |
| 77 | #define RALLOC(size,ptr,type) ((type*)realloc(ptr,(size)*sizeof(type))) |
| 78 | |
| 79 | typedef unsigned short ushort; |
| 80 | |
| 81 | static gmlgraph* G; |
| 82 | static gmlnode* N; |
| 83 | static gmledge* E; |
| 84 | static Dt_t* L; |
| 85 | static Dt_t** liststk; |
| 86 | static int liststk_sz; |
| 87 | static int liststk_cnt; |
| 88 | |
| 89 | static void free_attr (Dt_t*d, gmlattr* p, Dtdisc_t* ds); /* forward decl */ |
| 90 | static char* sortToStr (int sort); /* forward decl */ |
| 91 | |
| 92 | static void |
| 93 | free_node (Dt_t*d, gmlnode* p, Dtdisc_t* ds) |
| 94 | { |
| 95 | if (!p) return; |
| 96 | if (p->attrlist) dtclose (p->attrlist); |
| 97 | free (p); |
| 98 | } |
| 99 | |
| 100 | static void |
| 101 | free_edge (Dt_t*d, gmledge* p, Dtdisc_t* ds) |
| 102 | { |
| 103 | if (!p) return; |
| 104 | if (p->attrlist) dtclose (p->attrlist); |
| 105 | free (p); |
| 106 | } |
| 107 | |
| 108 | static void |
| 109 | free_graph (Dt_t*d, gmlgraph* p, Dtdisc_t* ds) |
| 110 | { |
| 111 | if (!p) return; |
| 112 | if (p->nodelist) |
| 113 | dtclose (p->nodelist); |
| 114 | if (p->edgelist) |
| 115 | dtclose (p->edgelist); |
| 116 | if (p->attrlist) |
| 117 | dtclose (p->attrlist); |
| 118 | if (p->graphlist) |
| 119 | dtclose (p->graphlist); |
| 120 | free (p); |
| 121 | } |
| 122 | |
| 123 | static Dtdisc_t nodeDisc = { |
| 124 | offsetof(gmlnode,attrlist), |
| 125 | sizeof(Dt_t*), |
| 126 | offsetof(gmlnode,link), |
| 127 | NIL(Dtmake_f), |
| 128 | (Dtfree_f)free_node, |
| 129 | NIL(Dtcompar_f), |
| 130 | NIL(Dthash_f), |
| 131 | NIL(Dtmemory_f), |
| 132 | NIL(Dtevent_f) |
| 133 | }; |
| 134 | |
| 135 | static Dtdisc_t edgeDisc = { |
| 136 | offsetof(gmledge,attrlist), |
| 137 | sizeof(Dt_t*), |
| 138 | offsetof(gmledge,link), |
| 139 | NIL(Dtmake_f), |
| 140 | (Dtfree_f)free_edge, |
| 141 | NIL(Dtcompar_f), |
| 142 | NIL(Dthash_f), |
| 143 | NIL(Dtmemory_f), |
| 144 | NIL(Dtevent_f) |
| 145 | }; |
| 146 | |
| 147 | static Dtdisc_t attrDisc = { |
| 148 | offsetof(gmlattr,name), |
| 149 | sizeof(char*), |
| 150 | offsetof(gmlattr,link), |
| 151 | NIL(Dtmake_f), |
| 152 | (Dtfree_f)free_attr, |
| 153 | NIL(Dtcompar_f), |
| 154 | NIL(Dthash_f), |
| 155 | NIL(Dtmemory_f), |
| 156 | NIL(Dtevent_f) |
| 157 | }; |
| 158 | |
| 159 | static Dtdisc_t graphDisc = { |
| 160 | offsetof(gmlgraph,nodelist), |
| 161 | sizeof(Dt_t*), |
| 162 | offsetof(gmlgraph,link), |
| 163 | NIL(Dtmake_f), |
| 164 | (Dtfree_f)free_graph, |
| 165 | NIL(Dtcompar_f), |
| 166 | NIL(Dthash_f), |
| 167 | NIL(Dtmemory_f), |
| 168 | NIL(Dtevent_f) |
| 169 | }; |
| 170 | |
| 171 | static void |
| 172 | initstk (void) |
| 173 | { |
| 174 | liststk_sz = 10; |
| 175 | liststk_cnt = 0; |
| 176 | liststk = N_NEW(liststk_sz, Dt_t*); |
| 177 | } |
| 178 | |
| 179 | static void |
| 180 | cleanup (void) |
| 181 | { |
| 182 | int i; |
| 183 | |
| 184 | if (liststk) { |
| 185 | for (i = 0; i < liststk_cnt; i++) |
| 186 | dtclose (liststk[i]); |
| 187 | free (liststk); |
| 188 | liststk = NULL; |
| 189 | } |
| 190 | if (L) { |
| 191 | dtclose (L); |
| 192 | L = NULL; |
| 193 | } |
| 194 | if (N) { |
| 195 | free_node (0, N, 0); |
| 196 | N = NULL; |
| 197 | } |
| 198 | if (E) { |
| 199 | free_edge (0, E, 0); |
| 200 | E = NULL; |
| 201 | } |
| 202 | if (G) { |
| 203 | free_graph (0, G, 0); |
| 204 | G = NULL; |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | static void |
| 209 | pushAlist (void) |
| 210 | { |
| 211 | Dt_t* lp = dtopen (&attrDisc, Dtqueue); |
| 212 | |
| 213 | if (L) { |
| 214 | if (liststk_cnt == liststk_sz) { |
| 215 | liststk_sz *= 2; |
| 216 | liststk = RALLOC(liststk_sz, liststk, Dt_t*); |
| 217 | } |
| 218 | liststk[liststk_cnt++] = L; |
| 219 | } |
| 220 | L = lp; |
| 221 | } |
| 222 | |
| 223 | static Dt_t* |
| 224 | popAlist (void) |
| 225 | { |
| 226 | Dt_t* lp = L; |
| 227 | |
| 228 | if (liststk_cnt) |
| 229 | L = liststk[--liststk_cnt]; |
| 230 | else |
| 231 | L = NULL; |
| 232 | |
| 233 | return lp; |
| 234 | } |
| 235 | |
| 236 | static void |
| 237 | popG (void) |
| 238 | { |
| 239 | G = G->parent; |
| 240 | } |
| 241 | |
| 242 | static void |
| 243 | pushG (void) |
| 244 | { |
| 245 | gmlgraph* g = NEW(gmlgraph); |
| 246 | |
| 247 | g->attrlist = dtopen(&attrDisc, Dtqueue); |
| 248 | g->nodelist = dtopen(&nodeDisc, Dtqueue); |
| 249 | g->edgelist = dtopen(&edgeDisc, Dtqueue); |
| 250 | g->graphlist = dtopen(&graphDisc, Dtqueue); |
| 251 | g->parent = G; |
| 252 | g->directed = -1; |
| 253 | |
| 254 | if (G) |
| 255 | dtinsert (G->graphlist, g); |
| 256 | |
| 257 | G = g; |
| 258 | } |
| 259 | |
| 260 | static gmlnode* |
| 261 | mkNode (void) |
| 262 | { |
| 263 | gmlnode* np = NEW(gmlnode); |
| 264 | np->attrlist = dtopen (&attrDisc, Dtqueue); |
| 265 | np->id = NULL; |
| 266 | return np; |
| 267 | } |
| 268 | |
| 269 | static gmledge* |
| 270 | mkEdge (void) |
| 271 | { |
| 272 | gmledge* ep = NEW(gmledge); |
| 273 | ep->attrlist = dtopen (&attrDisc, Dtqueue); |
| 274 | ep->source = NULL; |
| 275 | ep->target = NULL; |
| 276 | return ep; |
| 277 | } |
| 278 | |
| 279 | static gmlattr* |
| 280 | mkAttr (char* name, int sort, int kind, char* str, Dt_t* list) |
| 281 | { |
| 282 | gmlattr* gp = NEW(gmlattr); |
| 283 | |
| 284 | assert (name || sort); |
| 285 | if (!name) |
| 286 | name = strdup (sortToStr (sort)); |
| 287 | gp->sort = sort; |
| 288 | gp->kind = kind; |
| 289 | gp->name = name; |
| 290 | if (str) |
| 291 | gp->u.value = str; |
| 292 | else { |
| 293 | if (dtsize (list) == 0) { |
| 294 | dtclose (list); |
| 295 | list = 0; |
| 296 | } |
| 297 | gp->u.lp = list; |
| 298 | } |
| 299 | /* fprintf (stderr, "[%x] %d %d \"%s\" \"%s\" \n", gp, sort, kind, (name?name:""), (str?str:"")); */ |
| 300 | return gp; |
| 301 | } |
| 302 | |
| 303 | static int |
| 304 | setDir (char* d) |
| 305 | { |
| 306 | gmlgraph* g; |
| 307 | int dir = atoi (d); |
| 308 | |
| 309 | free (d); |
| 310 | if (dir < 0) dir = -1; |
| 311 | else if (dir > 0) dir = 1; |
| 312 | else dir = 0; |
| 313 | G->directed = dir; |
| 314 | |
| 315 | if (dir >= 0) { |
| 316 | for (g = G->parent; g; g = g->parent) { |
| 317 | if (g->directed < 0) |
| 318 | g->directed = dir; |
| 319 | else if (g->directed != dir) |
| 320 | return 1; |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | return 0; |
| 325 | } |
| 326 | |
| 327 | |
| 328 | #line 329 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:339 */ |
| 329 | |
| 330 | # ifndef YY_NULLPTR |
| 331 | # if defined __cplusplus && 201103L <= __cplusplus |
| 332 | # define YY_NULLPTR nullptr |
| 333 | # else |
| 334 | # define YY_NULLPTR 0 |
| 335 | # endif |
| 336 | # endif |
| 337 | |
| 338 | /* Enabling verbose error messages. */ |
| 339 | #ifdef YYERROR_VERBOSE |
| 340 | # undef YYERROR_VERBOSE |
| 341 | # define YYERROR_VERBOSE 1 |
| 342 | #else |
| 343 | # define YYERROR_VERBOSE 0 |
| 344 | #endif |
| 345 | |
| 346 | /* In a future release of Bison, this section will be replaced |
| 347 | by #include "gmlparse.h". */ |
| 348 | #ifndef YY_YY_WORKSPACE_GRAPHVIZ_BUILD_CMD_TOOLS_GMLPARSE_H_INCLUDED |
| 349 | # define YY_YY_WORKSPACE_GRAPHVIZ_BUILD_CMD_TOOLS_GMLPARSE_H_INCLUDED |
| 350 | /* Debug traces. */ |
| 351 | #ifndef YYDEBUG |
| 352 | # define YYDEBUG 0 |
| 353 | #endif |
| 354 | #if YYDEBUG |
| 355 | extern int gmldebug; |
| 356 | #endif |
| 357 | |
| 358 | /* Token type. */ |
| 359 | #ifndef YYTOKENTYPE |
| 360 | # define YYTOKENTYPE |
| 361 | enum gmltokentype |
| 362 | { |
| 363 | GRAPH = 258, |
| 364 | NODE = 259, |
| 365 | EDGE = 260, |
| 366 | DIRECTED = 261, |
| 367 | SOURCE = 262, |
| 368 | TARGET = 263, |
| 369 | XVAL = 264, |
| 370 | YVAL = 265, |
| 371 | WVAL = 266, |
| 372 | HVAL = 267, |
| 373 | LABEL = 268, |
| 374 | GRAPHICS = 269, |
| 375 | LABELGRAPHICS = 270, |
| 376 | TYPE = 271, |
| 377 | FILL = 272, |
| 378 | OUTLINE = 273, |
| 379 | OUTLINESTYLE = 274, |
| 380 | OUTLINEWIDTH = 275, |
| 381 | WIDTH = 276, |
| 382 | STYLE = 277, |
| 383 | LINE = 278, |
| 384 | POINT = 279, |
| 385 | TEXT = 280, |
| 386 | FONTSIZE = 281, |
| 387 | FONTNAME = 282, |
| 388 | COLOR = 283, |
| 389 | INTEGER = 284, |
| 390 | REAL = 285, |
| 391 | STRING = 286, |
| 392 | ID = 287, |
| 393 | NAME = 288, |
| 394 | LIST = 289 |
| 395 | }; |
| 396 | #endif |
| 397 | |
| 398 | /* Value type. */ |
| 399 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED |
| 400 | |
| 401 | union YYSTYPE |
| 402 | { |
| 403 | #line 276 "gmlparse.y" /* yacc.c:355 */ |
| 404 | |
| 405 | int i; |
| 406 | char *str; |
| 407 | gmlnode* np; |
| 408 | gmledge* ep; |
| 409 | gmlattr* ap; |
| 410 | Dt_t* list; |
| 411 | |
| 412 | #line 413 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:355 */ |
| 413 | }; |
| 414 | |
| 415 | typedef union YYSTYPE YYSTYPE; |
| 416 | # define YYSTYPE_IS_TRIVIAL 1 |
| 417 | # define YYSTYPE_IS_DECLARED 1 |
| 418 | #endif |
| 419 | |
| 420 | |
| 421 | extern YYSTYPE gmllval; |
| 422 | |
| 423 | int gmlparse (void); |
| 424 | |
| 425 | #endif /* !YY_YY_WORKSPACE_GRAPHVIZ_BUILD_CMD_TOOLS_GMLPARSE_H_INCLUDED */ |
| 426 | |
| 427 | /* Copy the second part of user declarations. */ |
| 428 | |
| 429 | #line 430 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:358 */ |
| 430 | |
| 431 | #ifdef short |
| 432 | # undef short |
| 433 | #endif |
| 434 | |
| 435 | #ifdef YYTYPE_UINT8 |
| 436 | typedef YYTYPE_UINT8 gmltype_uint8; |
| 437 | #else |
| 438 | typedef unsigned char gmltype_uint8; |
| 439 | #endif |
| 440 | |
| 441 | #ifdef YYTYPE_INT8 |
| 442 | typedef YYTYPE_INT8 gmltype_int8; |
| 443 | #else |
| 444 | typedef signed char gmltype_int8; |
| 445 | #endif |
| 446 | |
| 447 | #ifdef YYTYPE_UINT16 |
| 448 | typedef YYTYPE_UINT16 gmltype_uint16; |
| 449 | #else |
| 450 | typedef unsigned short int gmltype_uint16; |
| 451 | #endif |
| 452 | |
| 453 | #ifdef YYTYPE_INT16 |
| 454 | typedef YYTYPE_INT16 gmltype_int16; |
| 455 | #else |
| 456 | typedef short int gmltype_int16; |
| 457 | #endif |
| 458 | |
| 459 | #ifndef YYSIZE_T |
| 460 | # ifdef __SIZE_TYPE__ |
| 461 | # define YYSIZE_T __SIZE_TYPE__ |
| 462 | # elif defined size_t |
| 463 | # define YYSIZE_T size_t |
| 464 | # elif ! defined YYSIZE_T |
| 465 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
| 466 | # define YYSIZE_T size_t |
| 467 | # else |
| 468 | # define YYSIZE_T unsigned int |
| 469 | # endif |
| 470 | #endif |
| 471 | |
| 472 | #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) |
| 473 | |
| 474 | #ifndef YY_ |
| 475 | # if defined YYENABLE_NLS && YYENABLE_NLS |
| 476 | # if ENABLE_NLS |
| 477 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
| 478 | # define YY_(Msgid) dgettext ("bison-runtime", Msgid) |
| 479 | # endif |
| 480 | # endif |
| 481 | # ifndef YY_ |
| 482 | # define YY_(Msgid) Msgid |
| 483 | # endif |
| 484 | #endif |
| 485 | |
| 486 | #ifndef YY_ATTRIBUTE |
| 487 | # if (defined __GNUC__ \ |
| 488 | && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ |
| 489 | || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C |
| 490 | # define YY_ATTRIBUTE(Spec) __attribute__(Spec) |
| 491 | # else |
| 492 | # define YY_ATTRIBUTE(Spec) /* empty */ |
| 493 | # endif |
| 494 | #endif |
| 495 | |
| 496 | #ifndef YY_ATTRIBUTE_PURE |
| 497 | # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) |
| 498 | #endif |
| 499 | |
| 500 | #ifndef YY_ATTRIBUTE_UNUSED |
| 501 | # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) |
| 502 | #endif |
| 503 | |
| 504 | #if !defined _Noreturn \ |
| 505 | && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) |
| 506 | # if defined _MSC_VER && 1200 <= _MSC_VER |
| 507 | # define _Noreturn __declspec (noreturn) |
| 508 | # else |
| 509 | # define _Noreturn YY_ATTRIBUTE ((__noreturn__)) |
| 510 | # endif |
| 511 | #endif |
| 512 | |
| 513 | /* Suppress unused-variable warnings by "using" E. */ |
| 514 | #if ! defined lint || defined __GNUC__ |
| 515 | # define YYUSE(E) ((void) (E)) |
| 516 | #else |
| 517 | # define YYUSE(E) /* empty */ |
| 518 | #endif |
| 519 | |
| 520 | #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ |
| 521 | /* Suppress an incorrect diagnostic about gmllval being uninitialized. */ |
| 522 | # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ |
| 523 | _Pragma ("GCC diagnostic push") \ |
| 524 | _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ |
| 525 | _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") |
| 526 | # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ |
| 527 | _Pragma ("GCC diagnostic pop") |
| 528 | #else |
| 529 | # define YY_INITIAL_VALUE(Value) Value |
| 530 | #endif |
| 531 | #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
| 532 | # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
| 533 | # define YY_IGNORE_MAYBE_UNINITIALIZED_END |
| 534 | #endif |
| 535 | #ifndef YY_INITIAL_VALUE |
| 536 | # define YY_INITIAL_VALUE(Value) /* Nothing. */ |
| 537 | #endif |
| 538 | |
| 539 | |
| 540 | #if ! defined gmloverflow || YYERROR_VERBOSE |
| 541 | |
| 542 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
| 543 | |
| 544 | # ifdef YYSTACK_USE_ALLOCA |
| 545 | # if YYSTACK_USE_ALLOCA |
| 546 | # ifdef __GNUC__ |
| 547 | # define YYSTACK_ALLOC __builtin_alloca |
| 548 | # elif defined __BUILTIN_VA_ARG_INCR |
| 549 | # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ |
| 550 | # elif defined _AIX |
| 551 | # define YYSTACK_ALLOC __alloca |
| 552 | # elif defined _MSC_VER |
| 553 | # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ |
| 554 | # define alloca _alloca |
| 555 | # else |
| 556 | # define YYSTACK_ALLOC alloca |
| 557 | # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS |
| 558 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 559 | /* Use EXIT_SUCCESS as a witness for stdlib.h. */ |
| 560 | # ifndef EXIT_SUCCESS |
| 561 | # define EXIT_SUCCESS 0 |
| 562 | # endif |
| 563 | # endif |
| 564 | # endif |
| 565 | # endif |
| 566 | # endif |
| 567 | |
| 568 | # ifdef YYSTACK_ALLOC |
| 569 | /* Pacify GCC's 'empty if-body' warning. */ |
| 570 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) |
| 571 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 572 | /* The OS might guarantee only one guard page at the bottom of the stack, |
| 573 | and a page size can be as small as 4096 bytes. So we cannot safely |
| 574 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number |
| 575 | to allow for a few compiler-allocated temporary stack slots. */ |
| 576 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ |
| 577 | # endif |
| 578 | # else |
| 579 | # define YYSTACK_ALLOC YYMALLOC |
| 580 | # define YYSTACK_FREE YYFREE |
| 581 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 582 | # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM |
| 583 | # endif |
| 584 | # if (defined __cplusplus && ! defined EXIT_SUCCESS \ |
| 585 | && ! ((defined YYMALLOC || defined malloc) \ |
| 586 | && (defined YYFREE || defined free))) |
| 587 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 588 | # ifndef EXIT_SUCCESS |
| 589 | # define EXIT_SUCCESS 0 |
| 590 | # endif |
| 591 | # endif |
| 592 | # ifndef YYMALLOC |
| 593 | # define YYMALLOC malloc |
| 594 | # if ! defined malloc && ! defined EXIT_SUCCESS |
| 595 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ |
| 596 | # endif |
| 597 | # endif |
| 598 | # ifndef YYFREE |
| 599 | # define YYFREE free |
| 600 | # if ! defined free && ! defined EXIT_SUCCESS |
| 601 | void free (void *); /* INFRINGES ON USER NAME SPACE */ |
| 602 | # endif |
| 603 | # endif |
| 604 | # endif |
| 605 | #endif /* ! defined gmloverflow || YYERROR_VERBOSE */ |
| 606 | |
| 607 | |
| 608 | #if (! defined gmloverflow \ |
| 609 | && (! defined __cplusplus \ |
| 610 | || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) |
| 611 | |
| 612 | /* A type that is properly aligned for any stack member. */ |
| 613 | union gmlalloc |
| 614 | { |
| 615 | gmltype_int16 gmlss_alloc; |
| 616 | YYSTYPE gmlvs_alloc; |
| 617 | }; |
| 618 | |
| 619 | /* The size of the maximum gap between one aligned stack and the next. */ |
| 620 | # define YYSTACK_GAP_MAXIMUM (sizeof (union gmlalloc) - 1) |
| 621 | |
| 622 | /* The size of an array large to enough to hold all stacks, each with |
| 623 | N elements. */ |
| 624 | # define YYSTACK_BYTES(N) \ |
| 625 | ((N) * (sizeof (gmltype_int16) + sizeof (YYSTYPE)) \ |
| 626 | + YYSTACK_GAP_MAXIMUM) |
| 627 | |
| 628 | # define YYCOPY_NEEDED 1 |
| 629 | |
| 630 | /* Relocate STACK from its old location to the new one. The |
| 631 | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
| 632 | elements in the stack, and YYPTR gives the new location of the |
| 633 | stack. Advance YYPTR to a properly aligned location for the next |
| 634 | stack. */ |
| 635 | # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ |
| 636 | do \ |
| 637 | { \ |
| 638 | YYSIZE_T gmlnewbytes; \ |
| 639 | YYCOPY (&gmlptr->Stack_alloc, Stack, gmlsize); \ |
| 640 | Stack = &gmlptr->Stack_alloc; \ |
| 641 | gmlnewbytes = gmlstacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
| 642 | gmlptr += gmlnewbytes / sizeof (*gmlptr); \ |
| 643 | } \ |
| 644 | while (0) |
| 645 | |
| 646 | #endif |
| 647 | |
| 648 | #if defined YYCOPY_NEEDED && YYCOPY_NEEDED |
| 649 | /* Copy COUNT objects from SRC to DST. The source and destination do |
| 650 | not overlap. */ |
| 651 | # ifndef YYCOPY |
| 652 | # if defined __GNUC__ && 1 < __GNUC__ |
| 653 | # define YYCOPY(Dst, Src, Count) \ |
| 654 | __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) |
| 655 | # else |
| 656 | # define YYCOPY(Dst, Src, Count) \ |
| 657 | do \ |
| 658 | { \ |
| 659 | YYSIZE_T gmli; \ |
| 660 | for (gmli = 0; gmli < (Count); gmli++) \ |
| 661 | (Dst)[gmli] = (Src)[gmli]; \ |
| 662 | } \ |
| 663 | while (0) |
| 664 | # endif |
| 665 | # endif |
| 666 | #endif /* !YYCOPY_NEEDED */ |
| 667 | |
| 668 | /* YYFINAL -- State number of the termination state. */ |
| 669 | #define YYFINAL 54 |
| 670 | /* YYLAST -- Last index in YYTABLE. */ |
| 671 | #define YYLAST 225 |
| 672 | |
| 673 | /* YYNTOKENS -- Number of terminals. */ |
| 674 | #define YYNTOKENS 37 |
| 675 | /* YYNNTS -- Number of nonterminals. */ |
| 676 | #define YYNNTS 20 |
| 677 | /* YYNRULES -- Number of rules. */ |
| 678 | #define YYNRULES 62 |
| 679 | /* YYNSTATES -- Number of states. */ |
| 680 | #define YYNSTATES 101 |
| 681 | |
| 682 | /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned |
| 683 | by gmllex, with out-of-bounds checking. */ |
| 684 | #define YYUNDEFTOK 2 |
| 685 | #define YYMAXUTOK 289 |
| 686 | |
| 687 | #define YYTRANSLATE(YYX) \ |
| 688 | ((unsigned int) (YYX) <= YYMAXUTOK ? gmltranslate[YYX] : YYUNDEFTOK) |
| 689 | |
| 690 | /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM |
| 691 | as returned by gmllex, without out-of-bounds checking. */ |
| 692 | static const gmltype_uint8 gmltranslate[] = |
| 693 | { |
| 694 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 695 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 696 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 697 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 698 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 699 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 700 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 701 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 702 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 703 | 2, 35, 2, 36, 2, 2, 2, 2, 2, 2, |
| 704 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 705 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 706 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 707 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 708 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 709 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 710 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 711 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 712 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 713 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 714 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 715 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 716 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 717 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 718 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 719 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
| 720 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
| 721 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
| 722 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34 |
| 723 | }; |
| 724 | |
| 725 | #if YYDEBUG |
| 726 | /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ |
| 727 | static const gmltype_uint16 gmlrline[] = |
| 728 | { |
| 729 | 0, 299, 299, 300, 301, 304, 307, 310, 311, 314, |
| 730 | 315, 318, 319, 320, 321, 328, 329, 332, 332, 335, |
| 731 | 336, 339, 340, 343, 343, 346, 347, 350, 351, 352, |
| 732 | 353, 356, 356, 359, 360, 363, 364, 367, 368, 369, |
| 733 | 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, |
| 734 | 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, |
| 735 | 390, 391, 392 |
| 736 | }; |
| 737 | #endif |
| 738 | |
| 739 | #if YYDEBUG || YYERROR_VERBOSE || 0 |
| 740 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
| 741 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
| 742 | static const char *const gmltname[] = |
| 743 | { |
| 744 | "$end" , "error" , "$undefined" , "GRAPH" , "NODE" , "EDGE" , "DIRECTED" , |
| 745 | "SOURCE" , "TARGET" , "XVAL" , "YVAL" , "WVAL" , "HVAL" , "LABEL" , "GRAPHICS" , |
| 746 | "LABELGRAPHICS" , "TYPE" , "FILL" , "OUTLINE" , "OUTLINESTYLE" , |
| 747 | "OUTLINEWIDTH" , "WIDTH" , "STYLE" , "LINE" , "POINT" , "TEXT" , "FONTSIZE" , |
| 748 | "FONTNAME" , "COLOR" , "INTEGER" , "REAL" , "STRING" , "ID" , "NAME" , "LIST" , |
| 749 | "'['" , "']'" , "$accept" , "graph" , "hdr" , "body" , "optglist" , "glist" , |
| 750 | "glistitem" , "node" , "$@1" , "nlist" , "nlistitem" , "edge" , "$@2" , "elist" , |
| 751 | "elistitem" , "attrlist" , "$@3" , "optalist" , "alist" , "alistitem" , YY_NULLPTR |
| 752 | }; |
| 753 | #endif |
| 754 | |
| 755 | # ifdef YYPRINT |
| 756 | /* YYTOKNUM[NUM] -- (External) token number corresponding to the |
| 757 | (internal) symbol number NUM (which must be that of a token). */ |
| 758 | static const gmltype_uint16 gmltoknum[] = |
| 759 | { |
| 760 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
| 761 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
| 762 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, |
| 763 | 285, 286, 287, 288, 289, 91, 93 |
| 764 | }; |
| 765 | # endif |
| 766 | |
| 767 | #define YYPACT_NINF -30 |
| 768 | |
| 769 | #define gmlpact_value_is_default(Yystate) \ |
| 770 | (!!((Yystate) == (-30))) |
| 771 | |
| 772 | #define YYTABLE_NINF -35 |
| 773 | |
| 774 | #define gmltable_value_is_error(Yytable_value) \ |
| 775 | 0 |
| 776 | |
| 777 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 778 | STATE-NUM. */ |
| 779 | static const gmltype_int16 gmlpact[] = |
| 780 | { |
| 781 | 2, -30, -23, -29, -21, -20, 1, -2, -2, 5, |
| 782 | 6, 10, 11, 15, 19, -27, -2, -2, 20, 21, |
| 783 | 22, 24, 17, 54, 55, 192, -30, -30, -30, -30, |
| 784 | -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, |
| 785 | -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, |
| 786 | -30, -30, -30, -30, -30, -30, 29, -30, 192, 57, |
| 787 | -30, 50, -30, -30, 58, 59, 29, 77, 57, -30, |
| 788 | -30, -30, -30, -30, 79, 80, -30, -30, -30, -30, |
| 789 | -30, 167, 142, 89, 112, -30, -30, 90, 113, 114, |
| 790 | 84, -30, -30, -30, -30, -30, -30, -30, -30, -30, |
| 791 | -30 |
| 792 | }; |
| 793 | |
| 794 | /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. |
| 795 | Performed when YYTABLE does not specify something else to do. Zero |
| 796 | means the default is an error. */ |
| 797 | static const gmltype_uint8 gmldefact[] = |
| 798 | { |
| 799 | 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, |
| 800 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 801 | 0, 0, 0, 0, 0, 33, 36, 42, 41, 43, |
| 802 | 44, 45, 46, 31, 47, 48, 49, 50, 51, 52, |
| 803 | 53, 54, 55, 56, 57, 58, 59, 61, 60, 62, |
| 804 | 37, 38, 39, 40, 1, 5, 0, 35, 34, 8, |
| 805 | 2, 0, 17, 23, 0, 0, 0, 0, 7, 10, |
| 806 | 11, 12, 16, 32, 0, 0, 14, 15, 13, 6, |
| 807 | 9, 0, 0, 0, 0, 20, 22, 0, 0, 0, |
| 808 | 0, 26, 30, 21, 18, 19, 27, 28, 29, 24, |
| 809 | 25 |
| 810 | }; |
| 811 | |
| 812 | /* YYPGOTO[NTERM-NUM]. */ |
| 813 | static const gmltype_int8 gmlpgoto[] = |
| 814 | { |
| 815 | -30, -30, 117, 81, -30, -30, 78, -30, -30, -30, |
| 816 | 87, -30, -30, -30, 82, 23, -30, 115, -30, -25 |
| 817 | }; |
| 818 | |
| 819 | /* YYDEFGOTO[NTERM-NUM]. */ |
| 820 | static const gmltype_int8 gmldefgoto[] = |
| 821 | { |
| 822 | -1, 23, 66, 60, 67, 68, 69, 70, 74, 84, |
| 823 | 85, 71, 75, 90, 91, 34, 58, 24, 25, 26 |
| 824 | }; |
| 825 | |
| 826 | /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If |
| 827 | positive, shift that token. If negative, reduce the rule whose |
| 828 | number is the opposite. If YYTABLE_NINF, syntax error. */ |
| 829 | static const gmltype_int8 gmltable[] = |
| 830 | { |
| 831 | 57, 29, -4, 1, 42, -34, 27, 28, 33, 30, |
| 832 | 31, 2, 3, 4, 5, 6, 7, 8, 9, 10, |
| 833 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 834 | 21, 35, 32, 33, 72, 22, 36, 37, 43, 44, |
| 835 | 45, 38, 39, 72, 40, 53, 50, 51, 52, 41, |
| 836 | 47, 46, 33, 48, 54, 49, 86, 92, 55, 86, |
| 837 | 55, 62, 63, 64, 59, 92, 2, 3, 4, 5, |
| 838 | 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
| 839 | 16, 17, 18, 19, 20, 21, 73, 76, 77, 65, |
| 840 | 22, 87, 88, 2, 3, 4, 5, 6, 7, 8, |
| 841 | 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, |
| 842 | 19, 20, 21, 79, 81, 82, 89, 22, 93, 96, |
| 843 | 99, 2, 3, 4, 5, 6, 7, 8, 9, 10, |
| 844 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 845 | 21, 56, 97, 98, 83, 22, 80, 78, 94, 87, |
| 846 | 88, 2, 3, 4, 5, 6, 7, 8, 9, 10, |
| 847 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 848 | 21, 95, 100, 61, 89, 22, 2, 3, 4, 5, |
| 849 | 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
| 850 | 16, 17, 18, 19, 20, 21, 0, 0, 0, 83, |
| 851 | 22, 2, 3, 4, 5, 6, 7, 8, 9, 10, |
| 852 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 853 | 21, 0, 0, 0, 0, 22 |
| 854 | }; |
| 855 | |
| 856 | static const gmltype_int8 gmlcheck[] = |
| 857 | { |
| 858 | 25, 30, 0, 1, 31, 3, 29, 30, 35, 30, |
| 859 | 30, 9, 10, 11, 12, 13, 14, 15, 16, 17, |
| 860 | 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, |
| 861 | 28, 8, 31, 35, 59, 33, 31, 31, 15, 16, |
| 862 | 17, 31, 31, 68, 29, 22, 29, 30, 31, 30, |
| 863 | 29, 31, 35, 31, 0, 31, 81, 82, 3, 84, |
| 864 | 3, 4, 5, 6, 35, 90, 9, 10, 11, 12, |
| 865 | 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, |
| 866 | 23, 24, 25, 26, 27, 28, 36, 29, 29, 32, |
| 867 | 33, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
| 868 | 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, |
| 869 | 26, 27, 28, 36, 35, 35, 32, 33, 29, 29, |
| 870 | 36, 9, 10, 11, 12, 13, 14, 15, 16, 17, |
| 871 | 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, |
| 872 | 28, 24, 29, 29, 32, 33, 68, 66, 36, 7, |
| 873 | 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, |
| 874 | 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, |
| 875 | 28, 84, 90, 58, 32, 33, 9, 10, 11, 12, |
| 876 | 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, |
| 877 | 23, 24, 25, 26, 27, 28, -1, -1, -1, 32, |
| 878 | 33, 9, 10, 11, 12, 13, 14, 15, 16, 17, |
| 879 | 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, |
| 880 | 28, -1, -1, -1, -1, 33 |
| 881 | }; |
| 882 | |
| 883 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
| 884 | symbol of state STATE-NUM. */ |
| 885 | static const gmltype_uint8 gmlstos[] = |
| 886 | { |
| 887 | 0, 1, 9, 10, 11, 12, 13, 14, 15, 16, |
| 888 | 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, |
| 889 | 27, 28, 33, 38, 54, 55, 56, 29, 30, 30, |
| 890 | 30, 30, 31, 35, 52, 52, 31, 31, 31, 31, |
| 891 | 29, 30, 31, 52, 52, 52, 31, 29, 31, 31, |
| 892 | 29, 30, 31, 52, 0, 3, 39, 56, 53, 35, |
| 893 | 40, 54, 4, 5, 6, 32, 39, 41, 42, 43, |
| 894 | 44, 48, 56, 36, 45, 49, 29, 29, 40, 36, |
| 895 | 43, 35, 35, 32, 46, 47, 56, 7, 8, 32, |
| 896 | 50, 51, 56, 29, 36, 47, 29, 29, 29, 36, |
| 897 | 51 |
| 898 | }; |
| 899 | |
| 900 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
| 901 | static const gmltype_uint8 gmlr1[] = |
| 902 | { |
| 903 | 0, 37, 38, 38, 38, 39, 40, 41, 41, 42, |
| 904 | 42, 43, 43, 43, 43, 43, 43, 45, 44, 46, |
| 905 | 46, 47, 47, 49, 48, 50, 50, 51, 51, 51, |
| 906 | 51, 53, 52, 54, 54, 55, 55, 56, 56, 56, |
| 907 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, |
| 908 | 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, |
| 909 | 56, 56, 56 |
| 910 | }; |
| 911 | |
| 912 | /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ |
| 913 | static const gmltype_uint8 gmlr2[] = |
| 914 | { |
| 915 | 0, 2, 3, 1, 0, 1, 3, 1, 0, 2, |
| 916 | 1, 1, 1, 2, 2, 2, 1, 0, 5, 2, |
| 917 | 1, 2, 1, 0, 5, 2, 1, 2, 2, 2, |
| 918 | 1, 0, 4, 1, 0, 2, 1, 2, 2, 2, |
| 919 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 920 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 921 | 2, 2, 2 |
| 922 | }; |
| 923 | |
| 924 | |
| 925 | #define gmlerrok (gmlerrstatus = 0) |
| 926 | #define gmlclearin (gmlchar = YYEMPTY) |
| 927 | #define YYEMPTY (-2) |
| 928 | #define YYEOF 0 |
| 929 | |
| 930 | #define YYACCEPT goto gmlacceptlab |
| 931 | #define YYABORT goto gmlabortlab |
| 932 | #define YYERROR goto gmlerrorlab |
| 933 | |
| 934 | |
| 935 | #define YYRECOVERING() (!!gmlerrstatus) |
| 936 | |
| 937 | #define YYBACKUP(Token, Value) \ |
| 938 | do \ |
| 939 | if (gmlchar == YYEMPTY) \ |
| 940 | { \ |
| 941 | gmlchar = (Token); \ |
| 942 | gmllval = (Value); \ |
| 943 | YYPOPSTACK (gmllen); \ |
| 944 | gmlstate = *gmlssp; \ |
| 945 | goto gmlbackup; \ |
| 946 | } \ |
| 947 | else \ |
| 948 | { \ |
| 949 | gmlerror (YY_("syntax error: cannot back up")); \ |
| 950 | YYERROR; \ |
| 951 | } \ |
| 952 | while (0) |
| 953 | |
| 954 | /* Error token number */ |
| 955 | #define YYTERROR 1 |
| 956 | #define YYERRCODE 256 |
| 957 | |
| 958 | |
| 959 | |
| 960 | /* Enable debugging if requested. */ |
| 961 | #if YYDEBUG |
| 962 | |
| 963 | # ifndef YYFPRINTF |
| 964 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
| 965 | # define YYFPRINTF fprintf |
| 966 | # endif |
| 967 | |
| 968 | # define YYDPRINTF(Args) \ |
| 969 | do { \ |
| 970 | if (gmldebug) \ |
| 971 | YYFPRINTF Args; \ |
| 972 | } while (0) |
| 973 | |
| 974 | /* This macro is provided for backward compatibility. */ |
| 975 | #ifndef YY_LOCATION_PRINT |
| 976 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) |
| 977 | #endif |
| 978 | |
| 979 | |
| 980 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
| 981 | do { \ |
| 982 | if (gmldebug) \ |
| 983 | { \ |
| 984 | YYFPRINTF (stderr, "%s ", Title); \ |
| 985 | gml_symbol_print (stderr, \ |
| 986 | Type, Value); \ |
| 987 | YYFPRINTF (stderr, "\n"); \ |
| 988 | } \ |
| 989 | } while (0) |
| 990 | |
| 991 | |
| 992 | /*----------------------------------------. |
| 993 | | Print this symbol's value on YYOUTPUT. | |
| 994 | `----------------------------------------*/ |
| 995 | |
| 996 | static void |
| 997 | gml_symbol_value_print (FILE *gmloutput, int gmltype, YYSTYPE const * const gmlvaluep) |
| 998 | { |
| 999 | FILE *gmlo = gmloutput; |
| 1000 | YYUSE (gmlo); |
| 1001 | if (!gmlvaluep) |
| 1002 | return; |
| 1003 | # ifdef YYPRINT |
| 1004 | if (gmltype < YYNTOKENS) |
| 1005 | YYPRINT (gmloutput, gmltoknum[gmltype], *gmlvaluep); |
| 1006 | # endif |
| 1007 | YYUSE (gmltype); |
| 1008 | } |
| 1009 | |
| 1010 | |
| 1011 | /*--------------------------------. |
| 1012 | | Print this symbol on YYOUTPUT. | |
| 1013 | `--------------------------------*/ |
| 1014 | |
| 1015 | static void |
| 1016 | gml_symbol_print (FILE *gmloutput, int gmltype, YYSTYPE const * const gmlvaluep) |
| 1017 | { |
| 1018 | YYFPRINTF (gmloutput, "%s %s (" , |
| 1019 | gmltype < YYNTOKENS ? "token" : "nterm" , gmltname[gmltype]); |
| 1020 | |
| 1021 | gml_symbol_value_print (gmloutput, gmltype, gmlvaluep); |
| 1022 | YYFPRINTF (gmloutput, ")" ); |
| 1023 | } |
| 1024 | |
| 1025 | /*------------------------------------------------------------------. |
| 1026 | | gml_stack_print -- Print the state stack from its BOTTOM up to its | |
| 1027 | | TOP (included). | |
| 1028 | `------------------------------------------------------------------*/ |
| 1029 | |
| 1030 | static void |
| 1031 | gml_stack_print (gmltype_int16 *gmlbottom, gmltype_int16 *gmltop) |
| 1032 | { |
| 1033 | YYFPRINTF (stderr, "Stack now" ); |
| 1034 | for (; gmlbottom <= gmltop; gmlbottom++) |
| 1035 | { |
| 1036 | int gmlbot = *gmlbottom; |
| 1037 | YYFPRINTF (stderr, " %d" , gmlbot); |
| 1038 | } |
| 1039 | YYFPRINTF (stderr, "\n" ); |
| 1040 | } |
| 1041 | |
| 1042 | # define YY_STACK_PRINT(Bottom, Top) \ |
| 1043 | do { \ |
| 1044 | if (gmldebug) \ |
| 1045 | gml_stack_print ((Bottom), (Top)); \ |
| 1046 | } while (0) |
| 1047 | |
| 1048 | |
| 1049 | /*------------------------------------------------. |
| 1050 | | Report that the YYRULE is going to be reduced. | |
| 1051 | `------------------------------------------------*/ |
| 1052 | |
| 1053 | static void |
| 1054 | gml_reduce_print (gmltype_int16 *gmlssp, YYSTYPE *gmlvsp, int gmlrule) |
| 1055 | { |
| 1056 | uint_64_t gmllno = gmlrline[gmlrule]; |
| 1057 | int gmlnrhs = gmlr2[gmlrule]; |
| 1058 | int gmli; |
| 1059 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n" , |
| 1060 | gmlrule - 1, gmllno); |
| 1061 | /* The symbols being reduced. */ |
| 1062 | for (gmli = 0; gmli < gmlnrhs; gmli++) |
| 1063 | { |
| 1064 | YYFPRINTF (stderr, " $%d = " , gmli + 1); |
| 1065 | gml_symbol_print (stderr, |
| 1066 | gmlstos[gmlssp[gmli + 1 - gmlnrhs]], |
| 1067 | &(gmlvsp[(gmli + 1) - (gmlnrhs)]) |
| 1068 | ); |
| 1069 | YYFPRINTF (stderr, "\n" ); |
| 1070 | } |
| 1071 | } |
| 1072 | |
| 1073 | # define YY_REDUCE_PRINT(Rule) \ |
| 1074 | do { \ |
| 1075 | if (gmldebug) \ |
| 1076 | gml_reduce_print (gmlssp, gmlvsp, Rule); \ |
| 1077 | } while (0) |
| 1078 | |
| 1079 | /* Nonzero means print parse trace. It is left uninitialized so that |
| 1080 | multiple parsers can coexist. */ |
| 1081 | int gmldebug; |
| 1082 | #else /* !YYDEBUG */ |
| 1083 | # define YYDPRINTF(Args) |
| 1084 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) |
| 1085 | # define YY_STACK_PRINT(Bottom, Top) |
| 1086 | # define YY_REDUCE_PRINT(Rule) |
| 1087 | #endif /* !YYDEBUG */ |
| 1088 | |
| 1089 | |
| 1090 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
| 1091 | #ifndef YYINITDEPTH |
| 1092 | # define YYINITDEPTH 200 |
| 1093 | #endif |
| 1094 | |
| 1095 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
| 1096 | if the built-in stack extension method is used). |
| 1097 | |
| 1098 | Do not make this value too large; the results are undefined if |
| 1099 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) |
| 1100 | evaluated with infinite-precision integer arithmetic. */ |
| 1101 | |
| 1102 | #ifndef YYMAXDEPTH |
| 1103 | # define YYMAXDEPTH 10000 |
| 1104 | #endif |
| 1105 | |
| 1106 | |
| 1107 | #if YYERROR_VERBOSE |
| 1108 | |
| 1109 | # ifndef gmlstrlen |
| 1110 | # if defined __GLIBC__ && defined _STRING_H |
| 1111 | # define gmlstrlen strlen |
| 1112 | # else |
| 1113 | /* Return the length of YYSTR. */ |
| 1114 | static YYSIZE_T |
| 1115 | gmlstrlen (const char *gmlstr) |
| 1116 | { |
| 1117 | YYSIZE_T gmllen; |
| 1118 | for (gmllen = 0; gmlstr[gmllen]; gmllen++) |
| 1119 | continue; |
| 1120 | return gmllen; |
| 1121 | } |
| 1122 | # endif |
| 1123 | # endif |
| 1124 | |
| 1125 | # ifndef gmlstpcpy |
| 1126 | # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE |
| 1127 | # define gmlstpcpy stpcpy |
| 1128 | # else |
| 1129 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
| 1130 | YYDEST. */ |
| 1131 | static char * |
| 1132 | gmlstpcpy (char *gmldest, const char *gmlsrc) |
| 1133 | { |
| 1134 | char *gmld = gmldest; |
| 1135 | const char *gmls = gmlsrc; |
| 1136 | |
| 1137 | while ((*gmld++ = *gmls++) != '\0') |
| 1138 | continue; |
| 1139 | |
| 1140 | return gmld - 1; |
| 1141 | } |
| 1142 | # endif |
| 1143 | # endif |
| 1144 | |
| 1145 | # ifndef gmltnamerr |
| 1146 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary |
| 1147 | quotes and backslashes, so that it's suitable for gmlerror. The |
| 1148 | heuristic is that double-quoting is unnecessary unless the string |
| 1149 | contains an apostrophe, a comma, or backslash (other than |
| 1150 | backslash-backslash). YYSTR is taken from gmltname. If YYRES is |
| 1151 | null, do not copy; instead, return the length of what the result |
| 1152 | would have been. */ |
| 1153 | static YYSIZE_T |
| 1154 | gmltnamerr (char *gmlres, const char *gmlstr) |
| 1155 | { |
| 1156 | if (*gmlstr == '"') |
| 1157 | { |
| 1158 | YYSIZE_T gmln = 0; |
| 1159 | char const *gmlp = gmlstr; |
| 1160 | |
| 1161 | for (;;) |
| 1162 | switch (*++gmlp) |
| 1163 | { |
| 1164 | case '\'': |
| 1165 | case ',': |
| 1166 | goto do_not_strip_quotes; |
| 1167 | |
| 1168 | case '\\': |
| 1169 | if (*++gmlp != '\\') |
| 1170 | goto do_not_strip_quotes; |
| 1171 | /* Fall through. */ |
| 1172 | default: |
| 1173 | if (gmlres) |
| 1174 | gmlres[gmln] = *gmlp; |
| 1175 | gmln++; |
| 1176 | break; |
| 1177 | |
| 1178 | case '"': |
| 1179 | if (gmlres) |
| 1180 | gmlres[gmln] = '\0'; |
| 1181 | return gmln; |
| 1182 | } |
| 1183 | do_not_strip_quotes: ; |
| 1184 | } |
| 1185 | |
| 1186 | if (! gmlres) |
| 1187 | return gmlstrlen (gmlstr); |
| 1188 | |
| 1189 | return gmlstpcpy (gmlres, gmlstr) - gmlres; |
| 1190 | } |
| 1191 | # endif |
| 1192 | |
| 1193 | /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message |
| 1194 | about the unexpected token YYTOKEN for the state stack whose top is |
| 1195 | YYSSP. |
| 1196 | |
| 1197 | Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is |
| 1198 | not large enough to hold the message. In that case, also set |
| 1199 | *YYMSG_ALLOC to the required number of bytes. Return 2 if the |
| 1200 | required number of bytes is too large to store. */ |
| 1201 | static int |
| 1202 | gmlsyntax_error (YYSIZE_T *gmlmsg_alloc, char **gmlmsg, |
| 1203 | gmltype_int16 *gmlssp, int gmltoken) |
| 1204 | { |
| 1205 | YYSIZE_T gmlsize0 = gmltnamerr (YY_NULLPTR, gmltname[gmltoken]); |
| 1206 | YYSIZE_T gmlsize = gmlsize0; |
| 1207 | enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; |
| 1208 | /* Internationalized format string. */ |
| 1209 | const char *gmlformat = YY_NULLPTR; |
| 1210 | /* Arguments of gmlformat. */ |
| 1211 | char const *gmlarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; |
| 1212 | /* Number of reported tokens (one for the "unexpected", one per |
| 1213 | "expected"). */ |
| 1214 | int gmlcount = 0; |
| 1215 | |
| 1216 | /* There are many possibilities here to consider: |
| 1217 | - If this state is a consistent state with a default action, then |
| 1218 | the only way this function was invoked is if the default action |
| 1219 | is an error action. In that case, don't check for expected |
| 1220 | tokens because there are none. |
| 1221 | - The only way there can be no lookahead present (in gmlchar) is if |
| 1222 | this state is a consistent state with a default action. Thus, |
| 1223 | detecting the absence of a lookahead is sufficient to determine |
| 1224 | that there is no unexpected or expected token to report. In that |
| 1225 | case, just report a simple "syntax error". |
| 1226 | - Don't assume there isn't a lookahead just because this state is a |
| 1227 | consistent state with a default action. There might have been a |
| 1228 | previous inconsistent state, consistent state with a non-default |
| 1229 | action, or user semantic action that manipulated gmlchar. |
| 1230 | - Of course, the expected token list depends on states to have |
| 1231 | correct lookahead information, and it depends on the parser not |
| 1232 | to perform extra reductions after fetching a lookahead from the |
| 1233 | scanner and before detecting a syntax error. Thus, state merging |
| 1234 | (from LALR or IELR) and default reductions corrupt the expected |
| 1235 | token list. However, the list is correct for canonical LR with |
| 1236 | one exception: it will still contain any token that will not be |
| 1237 | accepted due to an error action in a later state. |
| 1238 | */ |
| 1239 | if (gmltoken != YYEMPTY) |
| 1240 | { |
| 1241 | int gmln = gmlpact[*gmlssp]; |
| 1242 | gmlarg[gmlcount++] = gmltname[gmltoken]; |
| 1243 | if (!gmlpact_value_is_default (gmln)) |
| 1244 | { |
| 1245 | /* Start YYX at -YYN if negative to avoid negative indexes in |
| 1246 | YYCHECK. In other words, skip the first -YYN actions for |
| 1247 | this state because they are default actions. */ |
| 1248 | int gmlxbegin = gmln < 0 ? -gmln : 0; |
| 1249 | /* Stay within bounds of both gmlcheck and gmltname. */ |
| 1250 | int gmlchecklim = YYLAST - gmln + 1; |
| 1251 | int gmlxend = gmlchecklim < YYNTOKENS ? gmlchecklim : YYNTOKENS; |
| 1252 | int gmlx; |
| 1253 | |
| 1254 | for (gmlx = gmlxbegin; gmlx < gmlxend; ++gmlx) |
| 1255 | if (gmlcheck[gmlx + gmln] == gmlx && gmlx != YYTERROR |
| 1256 | && !gmltable_value_is_error (gmltable[gmlx + gmln])) |
| 1257 | { |
| 1258 | if (gmlcount == YYERROR_VERBOSE_ARGS_MAXIMUM) |
| 1259 | { |
| 1260 | gmlcount = 1; |
| 1261 | gmlsize = gmlsize0; |
| 1262 | break; |
| 1263 | } |
| 1264 | gmlarg[gmlcount++] = gmltname[gmlx]; |
| 1265 | { |
| 1266 | YYSIZE_T gmlsize1 = gmlsize + gmltnamerr (YY_NULLPTR, gmltname[gmlx]); |
| 1267 | if (! (gmlsize <= gmlsize1 |
| 1268 | && gmlsize1 <= YYSTACK_ALLOC_MAXIMUM)) |
| 1269 | return 2; |
| 1270 | gmlsize = gmlsize1; |
| 1271 | } |
| 1272 | } |
| 1273 | } |
| 1274 | } |
| 1275 | |
| 1276 | switch (gmlcount) |
| 1277 | { |
| 1278 | # define YYCASE_(N, S) \ |
| 1279 | case N: \ |
| 1280 | gmlformat = S; \ |
| 1281 | break |
| 1282 | YYCASE_(0, YY_("syntax error" )); |
| 1283 | YYCASE_(1, YY_("syntax error, unexpected %s" )); |
| 1284 | YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s" )); |
| 1285 | YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s" )); |
| 1286 | YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s" )); |
| 1287 | YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s" )); |
| 1288 | # undef YYCASE_ |
| 1289 | } |
| 1290 | |
| 1291 | { |
| 1292 | YYSIZE_T gmlsize1 = gmlsize + gmlstrlen (gmlformat); |
| 1293 | if (! (gmlsize <= gmlsize1 && gmlsize1 <= YYSTACK_ALLOC_MAXIMUM)) |
| 1294 | return 2; |
| 1295 | gmlsize = gmlsize1; |
| 1296 | } |
| 1297 | |
| 1298 | if (*gmlmsg_alloc < gmlsize) |
| 1299 | { |
| 1300 | *gmlmsg_alloc = 2 * gmlsize; |
| 1301 | if (! (gmlsize <= *gmlmsg_alloc |
| 1302 | && *gmlmsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) |
| 1303 | *gmlmsg_alloc = YYSTACK_ALLOC_MAXIMUM; |
| 1304 | return 1; |
| 1305 | } |
| 1306 | |
| 1307 | /* Avoid sprintf, as that infringes on the user's name space. |
| 1308 | Don't have undefined behavior even if the translation |
| 1309 | produced a string with the wrong number of "%s"s. */ |
| 1310 | { |
| 1311 | char *gmlp = *gmlmsg; |
| 1312 | int gmli = 0; |
| 1313 | while ((*gmlp = *gmlformat) != '\0') |
| 1314 | if (*gmlp == '%' && gmlformat[1] == 's' && gmli < gmlcount) |
| 1315 | { |
| 1316 | gmlp += gmltnamerr (gmlp, gmlarg[gmli++]); |
| 1317 | gmlformat += 2; |
| 1318 | } |
| 1319 | else |
| 1320 | { |
| 1321 | gmlp++; |
| 1322 | gmlformat++; |
| 1323 | } |
| 1324 | } |
| 1325 | return 0; |
| 1326 | } |
| 1327 | #endif /* YYERROR_VERBOSE */ |
| 1328 | |
| 1329 | /*-----------------------------------------------. |
| 1330 | | Release the memory associated to this symbol. | |
| 1331 | `-----------------------------------------------*/ |
| 1332 | |
| 1333 | static void |
| 1334 | gmldestruct (const char *gmlmsg, int gmltype, YYSTYPE *gmlvaluep) |
| 1335 | { |
| 1336 | YYUSE (gmlvaluep); |
| 1337 | if (!gmlmsg) |
| 1338 | gmlmsg = "Deleting" ; |
| 1339 | YY_SYMBOL_PRINT (gmlmsg, gmltype, gmlvaluep, gmllocationp); |
| 1340 | |
| 1341 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
| 1342 | YYUSE (gmltype); |
| 1343 | YY_IGNORE_MAYBE_UNINITIALIZED_END |
| 1344 | } |
| 1345 | |
| 1346 | |
| 1347 | |
| 1348 | |
| 1349 | /* The lookahead symbol. */ |
| 1350 | int gmlchar; |
| 1351 | |
| 1352 | /* The semantic value of the lookahead symbol. */ |
| 1353 | YYSTYPE gmllval; |
| 1354 | /* Number of syntax errors so far. */ |
| 1355 | int gmlnerrs; |
| 1356 | |
| 1357 | |
| 1358 | /*----------. |
| 1359 | | gmlparse. | |
| 1360 | `----------*/ |
| 1361 | |
| 1362 | int |
| 1363 | gmlparse (void) |
| 1364 | { |
| 1365 | int gmlstate; |
| 1366 | /* Number of tokens to shift before error messages enabled. */ |
| 1367 | int gmlerrstatus; |
| 1368 | |
| 1369 | /* The stacks and their tools: |
| 1370 | 'gmlss': related to states. |
| 1371 | 'gmlvs': related to semantic values. |
| 1372 | |
| 1373 | Refer to the stacks through separate pointers, to allow gmloverflow |
| 1374 | to reallocate them elsewhere. */ |
| 1375 | |
| 1376 | /* The state stack. */ |
| 1377 | gmltype_int16 gmlssa[YYINITDEPTH]; |
| 1378 | gmltype_int16 *gmlss; |
| 1379 | gmltype_int16 *gmlssp; |
| 1380 | |
| 1381 | /* The semantic value stack. */ |
| 1382 | YYSTYPE gmlvsa[YYINITDEPTH]; |
| 1383 | YYSTYPE *gmlvs; |
| 1384 | YYSTYPE *gmlvsp; |
| 1385 | |
| 1386 | YYSIZE_T gmlstacksize; |
| 1387 | |
| 1388 | int gmln; |
| 1389 | int gmlresult; |
| 1390 | /* Lookahead token as an internal (translated) token number. */ |
| 1391 | int gmltoken = 0; |
| 1392 | /* The variables used to return semantic value and location from the |
| 1393 | action routines. */ |
| 1394 | YYSTYPE gmlval; |
| 1395 | |
| 1396 | #if YYERROR_VERBOSE |
| 1397 | /* Buffer for error messages, and its allocated size. */ |
| 1398 | char gmlmsgbuf[128]; |
| 1399 | char *gmlmsg = gmlmsgbuf; |
| 1400 | YYSIZE_T gmlmsg_alloc = sizeof gmlmsgbuf; |
| 1401 | #endif |
| 1402 | |
| 1403 | #define YYPOPSTACK(N) (gmlvsp -= (N), gmlssp -= (N)) |
| 1404 | |
| 1405 | /* The number of symbols on the RHS of the reduced rule. |
| 1406 | Keep to zero when no symbol should be popped. */ |
| 1407 | int gmllen = 0; |
| 1408 | |
| 1409 | gmlssp = gmlss = gmlssa; |
| 1410 | gmlvsp = gmlvs = gmlvsa; |
| 1411 | gmlstacksize = YYINITDEPTH; |
| 1412 | |
| 1413 | YYDPRINTF ((stderr, "Starting parse\n" )); |
| 1414 | |
| 1415 | gmlstate = 0; |
| 1416 | gmlerrstatus = 0; |
| 1417 | gmlnerrs = 0; |
| 1418 | gmlchar = YYEMPTY; /* Cause a token to be read. */ |
| 1419 | goto gmlsetstate; |
| 1420 | |
| 1421 | /*------------------------------------------------------------. |
| 1422 | | gmlnewstate -- Push a new state, which is found in gmlstate. | |
| 1423 | `------------------------------------------------------------*/ |
| 1424 | gmlnewstate: |
| 1425 | /* In all cases, when you get here, the value and location stacks |
| 1426 | have just been pushed. So pushing a state here evens the stacks. */ |
| 1427 | gmlssp++; |
| 1428 | |
| 1429 | gmlsetstate: |
| 1430 | *gmlssp = gmlstate; |
| 1431 | |
| 1432 | if (gmlss + gmlstacksize - 1 <= gmlssp) |
| 1433 | { |
| 1434 | /* Get the current used size of the three stacks, in elements. */ |
| 1435 | YYSIZE_T gmlsize = gmlssp - gmlss + 1; |
| 1436 | |
| 1437 | #ifdef gmloverflow |
| 1438 | { |
| 1439 | /* Give user a chance to reallocate the stack. Use copies of |
| 1440 | these so that the &'s don't force the real ones into |
| 1441 | memory. */ |
| 1442 | YYSTYPE *gmlvs1 = gmlvs; |
| 1443 | gmltype_int16 *gmlss1 = gmlss; |
| 1444 | |
| 1445 | /* Each stack pointer address is followed by the size of the |
| 1446 | data in use in that stack, in bytes. This used to be a |
| 1447 | conditional around just the two extra args, but that might |
| 1448 | be undefined if gmloverflow is a macro. */ |
| 1449 | gmloverflow (YY_("memory exhausted" ), |
| 1450 | &gmlss1, gmlsize * sizeof (*gmlssp), |
| 1451 | &gmlvs1, gmlsize * sizeof (*gmlvsp), |
| 1452 | &gmlstacksize); |
| 1453 | |
| 1454 | gmlss = gmlss1; |
| 1455 | gmlvs = gmlvs1; |
| 1456 | } |
| 1457 | #else /* no gmloverflow */ |
| 1458 | # ifndef YYSTACK_RELOCATE |
| 1459 | goto gmlexhaustedlab; |
| 1460 | # else |
| 1461 | /* Extend the stack our own way. */ |
| 1462 | if (YYMAXDEPTH <= gmlstacksize) |
| 1463 | goto gmlexhaustedlab; |
| 1464 | gmlstacksize *= 2; |
| 1465 | if (YYMAXDEPTH < gmlstacksize) |
| 1466 | gmlstacksize = YYMAXDEPTH; |
| 1467 | |
| 1468 | { |
| 1469 | gmltype_int16 *gmlss1 = gmlss; |
| 1470 | union gmlalloc *gmlptr = |
| 1471 | (union gmlalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (gmlstacksize)); |
| 1472 | if (! gmlptr) |
| 1473 | goto gmlexhaustedlab; |
| 1474 | YYSTACK_RELOCATE (gmlss_alloc, gmlss); |
| 1475 | YYSTACK_RELOCATE (gmlvs_alloc, gmlvs); |
| 1476 | # undef YYSTACK_RELOCATE |
| 1477 | if (gmlss1 != gmlssa) |
| 1478 | YYSTACK_FREE (gmlss1); |
| 1479 | } |
| 1480 | # endif |
| 1481 | #endif /* no gmloverflow */ |
| 1482 | |
| 1483 | gmlssp = gmlss + gmlsize - 1; |
| 1484 | gmlvsp = gmlvs + gmlsize - 1; |
| 1485 | |
| 1486 | YYDPRINTF ((stderr, "Stack size increased to %lu\n" , |
| 1487 | (uint_64_t) gmlstacksize)); |
| 1488 | |
| 1489 | if (gmlss + gmlstacksize - 1 <= gmlssp) |
| 1490 | YYABORT; |
| 1491 | } |
| 1492 | |
| 1493 | YYDPRINTF ((stderr, "Entering state %d\n" , gmlstate)); |
| 1494 | |
| 1495 | if (gmlstate == YYFINAL) |
| 1496 | YYACCEPT; |
| 1497 | |
| 1498 | goto gmlbackup; |
| 1499 | |
| 1500 | /*-----------. |
| 1501 | | gmlbackup. | |
| 1502 | `-----------*/ |
| 1503 | gmlbackup: |
| 1504 | |
| 1505 | /* Do appropriate processing given the current state. Read a |
| 1506 | lookahead token if we need one and don't already have one. */ |
| 1507 | |
| 1508 | /* First try to decide what to do without reference to lookahead token. */ |
| 1509 | gmln = gmlpact[gmlstate]; |
| 1510 | if (gmlpact_value_is_default (gmln)) |
| 1511 | goto gmldefault; |
| 1512 | |
| 1513 | /* Not known => get a lookahead token if don't already have one. */ |
| 1514 | |
| 1515 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ |
| 1516 | if (gmlchar == YYEMPTY) |
| 1517 | { |
| 1518 | YYDPRINTF ((stderr, "Reading a token: " )); |
| 1519 | gmlchar = gmllex (); |
| 1520 | } |
| 1521 | |
| 1522 | if (gmlchar <= YYEOF) |
| 1523 | { |
| 1524 | gmlchar = gmltoken = YYEOF; |
| 1525 | YYDPRINTF ((stderr, "Now at end of input.\n" )); |
| 1526 | } |
| 1527 | else |
| 1528 | { |
| 1529 | gmltoken = YYTRANSLATE (gmlchar); |
| 1530 | YY_SYMBOL_PRINT ("Next token is" , gmltoken, &gmllval, &gmllloc); |
| 1531 | } |
| 1532 | |
| 1533 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
| 1534 | detect an error, take that action. */ |
| 1535 | gmln += gmltoken; |
| 1536 | if (gmln < 0 || YYLAST < gmln || gmlcheck[gmln] != gmltoken) |
| 1537 | goto gmldefault; |
| 1538 | gmln = gmltable[gmln]; |
| 1539 | if (gmln <= 0) |
| 1540 | { |
| 1541 | if (gmltable_value_is_error (gmln)) |
| 1542 | goto gmlerrlab; |
| 1543 | gmln = -gmln; |
| 1544 | goto gmlreduce; |
| 1545 | } |
| 1546 | |
| 1547 | /* Count tokens shifted since error; after three, turn off error |
| 1548 | status. */ |
| 1549 | if (gmlerrstatus) |
| 1550 | gmlerrstatus--; |
| 1551 | |
| 1552 | /* Shift the lookahead token. */ |
| 1553 | YY_SYMBOL_PRINT ("Shifting" , gmltoken, &gmllval, &gmllloc); |
| 1554 | |
| 1555 | /* Discard the shifted token. */ |
| 1556 | gmlchar = YYEMPTY; |
| 1557 | |
| 1558 | gmlstate = gmln; |
| 1559 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
| 1560 | *++gmlvsp = gmllval; |
| 1561 | YY_IGNORE_MAYBE_UNINITIALIZED_END |
| 1562 | |
| 1563 | goto gmlnewstate; |
| 1564 | |
| 1565 | |
| 1566 | /*-----------------------------------------------------------. |
| 1567 | | gmldefault -- do the default action for the current state. | |
| 1568 | `-----------------------------------------------------------*/ |
| 1569 | gmldefault: |
| 1570 | gmln = gmldefact[gmlstate]; |
| 1571 | if (gmln == 0) |
| 1572 | goto gmlerrlab; |
| 1573 | goto gmlreduce; |
| 1574 | |
| 1575 | |
| 1576 | /*-----------------------------. |
| 1577 | | gmlreduce -- Do a reduction. | |
| 1578 | `-----------------------------*/ |
| 1579 | gmlreduce: |
| 1580 | /* gmln is the number of a rule to reduce with. */ |
| 1581 | gmllen = gmlr2[gmln]; |
| 1582 | |
| 1583 | /* If YYLEN is nonzero, implement the default value of the action: |
| 1584 | '$$ = $1'. |
| 1585 | |
| 1586 | Otherwise, the following line sets YYVAL to garbage. |
| 1587 | This behavior is undocumented and Bison |
| 1588 | users should not rely upon it. Assigning to YYVAL |
| 1589 | unconditionally makes the parser a bit smaller, and it avoids a |
| 1590 | GCC warning that YYVAL may be used uninitialized. */ |
| 1591 | gmlval = gmlvsp[1-gmllen]; |
| 1592 | |
| 1593 | |
| 1594 | YY_REDUCE_PRINT (gmln); |
| 1595 | switch (gmln) |
| 1596 | { |
| 1597 | case 2: |
| 1598 | #line 299 "gmlparse.y" /* yacc.c:1646 */ |
| 1599 | {gmllexeof(); if (G->parent) popG(); } |
| 1600 | #line 1601 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1601 | break; |
| 1602 | |
| 1603 | case 3: |
| 1604 | #line 300 "gmlparse.y" /* yacc.c:1646 */ |
| 1605 | { cleanup(); YYABORT; } |
| 1606 | #line 1607 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1607 | break; |
| 1608 | |
| 1609 | case 5: |
| 1610 | #line 304 "gmlparse.y" /* yacc.c:1646 */ |
| 1611 | { pushG(); } |
| 1612 | #line 1613 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1613 | break; |
| 1614 | |
| 1615 | case 11: |
| 1616 | #line 318 "gmlparse.y" /* yacc.c:1646 */ |
| 1617 | { dtinsert (G->nodelist, (gmlvsp[0].np)); } |
| 1618 | #line 1619 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1619 | break; |
| 1620 | |
| 1621 | case 12: |
| 1622 | #line 319 "gmlparse.y" /* yacc.c:1646 */ |
| 1623 | { dtinsert (G->edgelist, (gmlvsp[0].ep)); } |
| 1624 | #line 1625 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1625 | break; |
| 1626 | |
| 1627 | case 14: |
| 1628 | #line 321 "gmlparse.y" /* yacc.c:1646 */ |
| 1629 | { |
| 1630 | if (setDir((gmlvsp[0].str))) { |
| 1631 | gmlerror("mixed directed and undirected graphs" ); |
| 1632 | cleanup (); |
| 1633 | YYABORT; |
| 1634 | } |
| 1635 | } |
| 1636 | #line 1637 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1637 | break; |
| 1638 | |
| 1639 | case 15: |
| 1640 | #line 328 "gmlparse.y" /* yacc.c:1646 */ |
| 1641 | { dtinsert (G->attrlist, mkAttr (strdup("id" ), 0, INTEGER, (gmlvsp[0].str), 0)); } |
| 1642 | #line 1643 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1643 | break; |
| 1644 | |
| 1645 | case 16: |
| 1646 | #line 329 "gmlparse.y" /* yacc.c:1646 */ |
| 1647 | { dtinsert (G->attrlist, (gmlvsp[0].ap)); } |
| 1648 | #line 1649 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1649 | break; |
| 1650 | |
| 1651 | case 17: |
| 1652 | #line 332 "gmlparse.y" /* yacc.c:1646 */ |
| 1653 | { N = mkNode(); } |
| 1654 | #line 1655 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1655 | break; |
| 1656 | |
| 1657 | case 18: |
| 1658 | #line 332 "gmlparse.y" /* yacc.c:1646 */ |
| 1659 | { (gmlval.np) = N; N = NULL; } |
| 1660 | #line 1661 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1661 | break; |
| 1662 | |
| 1663 | case 21: |
| 1664 | #line 339 "gmlparse.y" /* yacc.c:1646 */ |
| 1665 | { N->id = (gmlvsp[0].str); } |
| 1666 | #line 1667 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1667 | break; |
| 1668 | |
| 1669 | case 22: |
| 1670 | #line 340 "gmlparse.y" /* yacc.c:1646 */ |
| 1671 | { dtinsert (N->attrlist, (gmlvsp[0].ap)); } |
| 1672 | #line 1673 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1673 | break; |
| 1674 | |
| 1675 | case 23: |
| 1676 | #line 343 "gmlparse.y" /* yacc.c:1646 */ |
| 1677 | { E = mkEdge(); } |
| 1678 | #line 1679 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1679 | break; |
| 1680 | |
| 1681 | case 24: |
| 1682 | #line 343 "gmlparse.y" /* yacc.c:1646 */ |
| 1683 | { (gmlval.ep) = E; E = NULL; } |
| 1684 | #line 1685 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1685 | break; |
| 1686 | |
| 1687 | case 27: |
| 1688 | #line 350 "gmlparse.y" /* yacc.c:1646 */ |
| 1689 | { E->source = (gmlvsp[0].str); } |
| 1690 | #line 1691 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1691 | break; |
| 1692 | |
| 1693 | case 28: |
| 1694 | #line 351 "gmlparse.y" /* yacc.c:1646 */ |
| 1695 | { E->target = (gmlvsp[0].str); } |
| 1696 | #line 1697 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1697 | break; |
| 1698 | |
| 1699 | case 29: |
| 1700 | #line 352 "gmlparse.y" /* yacc.c:1646 */ |
| 1701 | { dtinsert (E->attrlist, mkAttr (strdup("id" ), 0, INTEGER, (gmlvsp[0].str), 0)); } |
| 1702 | #line 1703 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1703 | break; |
| 1704 | |
| 1705 | case 30: |
| 1706 | #line 353 "gmlparse.y" /* yacc.c:1646 */ |
| 1707 | { dtinsert (E->attrlist, (gmlvsp[0].ap)); } |
| 1708 | #line 1709 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1709 | break; |
| 1710 | |
| 1711 | case 31: |
| 1712 | #line 356 "gmlparse.y" /* yacc.c:1646 */ |
| 1713 | {pushAlist(); } |
| 1714 | #line 1715 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1715 | break; |
| 1716 | |
| 1717 | case 32: |
| 1718 | #line 356 "gmlparse.y" /* yacc.c:1646 */ |
| 1719 | { (gmlval.list) = popAlist(); } |
| 1720 | #line 1721 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1721 | break; |
| 1722 | |
| 1723 | case 35: |
| 1724 | #line 363 "gmlparse.y" /* yacc.c:1646 */ |
| 1725 | { dtinsert (L, (gmlvsp[0].ap)); } |
| 1726 | #line 1727 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1727 | break; |
| 1728 | |
| 1729 | case 36: |
| 1730 | #line 364 "gmlparse.y" /* yacc.c:1646 */ |
| 1731 | { dtinsert (L, (gmlvsp[0].ap)); } |
| 1732 | #line 1733 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1733 | break; |
| 1734 | |
| 1735 | case 37: |
| 1736 | #line 367 "gmlparse.y" /* yacc.c:1646 */ |
| 1737 | { (gmlval.ap) = mkAttr ((gmlvsp[-1].str), 0, INTEGER, (gmlvsp[0].str), 0); } |
| 1738 | #line 1739 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1739 | break; |
| 1740 | |
| 1741 | case 38: |
| 1742 | #line 368 "gmlparse.y" /* yacc.c:1646 */ |
| 1743 | { (gmlval.ap) = mkAttr ((gmlvsp[-1].str), 0, REAL, (gmlvsp[0].str), 0); } |
| 1744 | #line 1745 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1745 | break; |
| 1746 | |
| 1747 | case 39: |
| 1748 | #line 369 "gmlparse.y" /* yacc.c:1646 */ |
| 1749 | { (gmlval.ap) = mkAttr ((gmlvsp[-1].str), 0, STRING, (gmlvsp[0].str), 0); } |
| 1750 | #line 1751 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1751 | break; |
| 1752 | |
| 1753 | case 40: |
| 1754 | #line 370 "gmlparse.y" /* yacc.c:1646 */ |
| 1755 | { (gmlval.ap) = mkAttr ((gmlvsp[-1].str), 0, LIST, 0, (gmlvsp[0].list)); } |
| 1756 | #line 1757 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1757 | break; |
| 1758 | |
| 1759 | case 41: |
| 1760 | #line 371 "gmlparse.y" /* yacc.c:1646 */ |
| 1761 | { (gmlval.ap) = mkAttr (0, XVAL, REAL, (gmlvsp[0].str), 0); } |
| 1762 | #line 1763 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1763 | break; |
| 1764 | |
| 1765 | case 42: |
| 1766 | #line 372 "gmlparse.y" /* yacc.c:1646 */ |
| 1767 | { (gmlval.ap) = mkAttr (0, XVAL, REAL, (gmlvsp[0].str), 0); } |
| 1768 | #line 1769 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1769 | break; |
| 1770 | |
| 1771 | case 43: |
| 1772 | #line 373 "gmlparse.y" /* yacc.c:1646 */ |
| 1773 | { (gmlval.ap) = mkAttr (0, YVAL, REAL, (gmlvsp[0].str), 0); } |
| 1774 | #line 1775 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1775 | break; |
| 1776 | |
| 1777 | case 44: |
| 1778 | #line 374 "gmlparse.y" /* yacc.c:1646 */ |
| 1779 | { (gmlval.ap) = mkAttr (0, WVAL, REAL, (gmlvsp[0].str), 0); } |
| 1780 | #line 1781 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1781 | break; |
| 1782 | |
| 1783 | case 45: |
| 1784 | #line 375 "gmlparse.y" /* yacc.c:1646 */ |
| 1785 | { (gmlval.ap) = mkAttr (0, HVAL, REAL, (gmlvsp[0].str), 0); } |
| 1786 | #line 1787 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1787 | break; |
| 1788 | |
| 1789 | case 46: |
| 1790 | #line 376 "gmlparse.y" /* yacc.c:1646 */ |
| 1791 | { (gmlval.ap) = mkAttr (0, LABEL, STRING, (gmlvsp[0].str), 0); } |
| 1792 | #line 1793 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1793 | break; |
| 1794 | |
| 1795 | case 47: |
| 1796 | #line 377 "gmlparse.y" /* yacc.c:1646 */ |
| 1797 | { (gmlval.ap) = mkAttr (0, GRAPHICS, LIST, 0, (gmlvsp[0].list)); } |
| 1798 | #line 1799 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1799 | break; |
| 1800 | |
| 1801 | case 48: |
| 1802 | #line 378 "gmlparse.y" /* yacc.c:1646 */ |
| 1803 | { (gmlval.ap) = mkAttr (0, LABELGRAPHICS, LIST, 0, (gmlvsp[0].list)); } |
| 1804 | #line 1805 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1805 | break; |
| 1806 | |
| 1807 | case 49: |
| 1808 | #line 379 "gmlparse.y" /* yacc.c:1646 */ |
| 1809 | { (gmlval.ap) = mkAttr (0, TYPE, STRING, (gmlvsp[0].str), 0); } |
| 1810 | #line 1811 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1811 | break; |
| 1812 | |
| 1813 | case 50: |
| 1814 | #line 380 "gmlparse.y" /* yacc.c:1646 */ |
| 1815 | { (gmlval.ap) = mkAttr (0, FILL, STRING, (gmlvsp[0].str), 0); } |
| 1816 | #line 1817 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1817 | break; |
| 1818 | |
| 1819 | case 51: |
| 1820 | #line 381 "gmlparse.y" /* yacc.c:1646 */ |
| 1821 | { (gmlval.ap) = mkAttr (0, OUTLINE, STRING, (gmlvsp[0].str), 0); } |
| 1822 | #line 1823 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1823 | break; |
| 1824 | |
| 1825 | case 52: |
| 1826 | #line 382 "gmlparse.y" /* yacc.c:1646 */ |
| 1827 | { (gmlval.ap) = mkAttr (0, OUTLINESTYLE, STRING, (gmlvsp[0].str), 0); } |
| 1828 | #line 1829 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1829 | break; |
| 1830 | |
| 1831 | case 53: |
| 1832 | #line 383 "gmlparse.y" /* yacc.c:1646 */ |
| 1833 | { (gmlval.ap) = mkAttr (0, OUTLINEWIDTH, INTEGER, (gmlvsp[0].str), 0); } |
| 1834 | #line 1835 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1835 | break; |
| 1836 | |
| 1837 | case 54: |
| 1838 | #line 384 "gmlparse.y" /* yacc.c:1646 */ |
| 1839 | { (gmlval.ap) = mkAttr (0, OUTLINEWIDTH, REAL, (gmlvsp[0].str), 0); } |
| 1840 | #line 1841 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1841 | break; |
| 1842 | |
| 1843 | case 55: |
| 1844 | #line 385 "gmlparse.y" /* yacc.c:1646 */ |
| 1845 | { (gmlval.ap) = mkAttr (0, STYLE, STRING, (gmlvsp[0].str), 0); } |
| 1846 | #line 1847 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1847 | break; |
| 1848 | |
| 1849 | case 56: |
| 1850 | #line 386 "gmlparse.y" /* yacc.c:1646 */ |
| 1851 | { (gmlval.ap) = mkAttr (0, STYLE, LIST, 0, (gmlvsp[0].list)); } |
| 1852 | #line 1853 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1853 | break; |
| 1854 | |
| 1855 | case 57: |
| 1856 | #line 387 "gmlparse.y" /* yacc.c:1646 */ |
| 1857 | { (gmlval.ap) = mkAttr (0, LINE, LIST, 0, (gmlvsp[0].list)); } |
| 1858 | #line 1859 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1859 | break; |
| 1860 | |
| 1861 | case 58: |
| 1862 | #line 388 "gmlparse.y" /* yacc.c:1646 */ |
| 1863 | { (gmlval.ap) = mkAttr (0, POINT, LIST, 0, (gmlvsp[0].list)); } |
| 1864 | #line 1865 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1865 | break; |
| 1866 | |
| 1867 | case 59: |
| 1868 | #line 389 "gmlparse.y" /* yacc.c:1646 */ |
| 1869 | { (gmlval.ap) = mkAttr (0, TEXT, STRING, (gmlvsp[0].str), 0); } |
| 1870 | #line 1871 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1871 | break; |
| 1872 | |
| 1873 | case 60: |
| 1874 | #line 390 "gmlparse.y" /* yacc.c:1646 */ |
| 1875 | { (gmlval.ap) = mkAttr (0, FONTNAME, STRING, (gmlvsp[0].str), 0); } |
| 1876 | #line 1877 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1877 | break; |
| 1878 | |
| 1879 | case 61: |
| 1880 | #line 391 "gmlparse.y" /* yacc.c:1646 */ |
| 1881 | { (gmlval.ap) = mkAttr (0, FONTNAME, INTEGER, (gmlvsp[0].str), 0); } |
| 1882 | #line 1883 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1883 | break; |
| 1884 | |
| 1885 | case 62: |
| 1886 | #line 392 "gmlparse.y" /* yacc.c:1646 */ |
| 1887 | { (gmlval.ap) = mkAttr (0, COLOR, STRING, (gmlvsp[0].str), 0); } |
| 1888 | #line 1889 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1889 | break; |
| 1890 | |
| 1891 | |
| 1892 | #line 1893 "/workspace/graphviz/build/cmd/tools/gmlparse.c" /* yacc.c:1646 */ |
| 1893 | default: break; |
| 1894 | } |
| 1895 | /* User semantic actions sometimes alter gmlchar, and that requires |
| 1896 | that gmltoken be updated with the new translation. We take the |
| 1897 | approach of translating immediately before every use of gmltoken. |
| 1898 | One alternative is translating here after every semantic action, |
| 1899 | but that translation would be missed if the semantic action invokes |
| 1900 | YYABORT, YYACCEPT, or YYERROR immediately after altering gmlchar or |
| 1901 | if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an |
| 1902 | incorrect destructor might then be invoked immediately. In the |
| 1903 | case of YYERROR or YYBACKUP, subsequent parser actions might lead |
| 1904 | to an incorrect destructor call or verbose syntax error message |
| 1905 | before the lookahead is translated. */ |
| 1906 | YY_SYMBOL_PRINT ("-> $$ =" , gmlr1[gmln], &gmlval, &gmlloc); |
| 1907 | |
| 1908 | YYPOPSTACK (gmllen); |
| 1909 | gmllen = 0; |
| 1910 | YY_STACK_PRINT (gmlss, gmlssp); |
| 1911 | |
| 1912 | *++gmlvsp = gmlval; |
| 1913 | |
| 1914 | /* Now 'shift' the result of the reduction. Determine what state |
| 1915 | that goes to, based on the state we popped back to and the rule |
| 1916 | number reduced by. */ |
| 1917 | |
| 1918 | gmln = gmlr1[gmln]; |
| 1919 | |
| 1920 | gmlstate = gmlpgoto[gmln - YYNTOKENS] + *gmlssp; |
| 1921 | if (0 <= gmlstate && gmlstate <= YYLAST && gmlcheck[gmlstate] == *gmlssp) |
| 1922 | gmlstate = gmltable[gmlstate]; |
| 1923 | else |
| 1924 | gmlstate = gmldefgoto[gmln - YYNTOKENS]; |
| 1925 | |
| 1926 | goto gmlnewstate; |
| 1927 | |
| 1928 | |
| 1929 | /*--------------------------------------. |
| 1930 | | gmlerrlab -- here on detecting error. | |
| 1931 | `--------------------------------------*/ |
| 1932 | gmlerrlab: |
| 1933 | /* Make sure we have latest lookahead translation. See comments at |
| 1934 | user semantic actions for why this is necessary. */ |
| 1935 | gmltoken = gmlchar == YYEMPTY ? YYEMPTY : YYTRANSLATE (gmlchar); |
| 1936 | |
| 1937 | /* If not already recovering from an error, report this error. */ |
| 1938 | if (!gmlerrstatus) |
| 1939 | { |
| 1940 | ++gmlnerrs; |
| 1941 | #if ! YYERROR_VERBOSE |
| 1942 | gmlerror (YY_("syntax error" )); |
| 1943 | #else |
| 1944 | # define YYSYNTAX_ERROR gmlsyntax_error (&gmlmsg_alloc, &gmlmsg, \ |
| 1945 | gmlssp, gmltoken) |
| 1946 | { |
| 1947 | char const *gmlmsgp = YY_("syntax error" ); |
| 1948 | int gmlsyntax_error_status; |
| 1949 | gmlsyntax_error_status = YYSYNTAX_ERROR; |
| 1950 | if (gmlsyntax_error_status == 0) |
| 1951 | gmlmsgp = gmlmsg; |
| 1952 | else if (gmlsyntax_error_status == 1) |
| 1953 | { |
| 1954 | if (gmlmsg != gmlmsgbuf) |
| 1955 | YYSTACK_FREE (gmlmsg); |
| 1956 | gmlmsg = (char *) YYSTACK_ALLOC (gmlmsg_alloc); |
| 1957 | if (!gmlmsg) |
| 1958 | { |
| 1959 | gmlmsg = gmlmsgbuf; |
| 1960 | gmlmsg_alloc = sizeof gmlmsgbuf; |
| 1961 | gmlsyntax_error_status = 2; |
| 1962 | } |
| 1963 | else |
| 1964 | { |
| 1965 | gmlsyntax_error_status = YYSYNTAX_ERROR; |
| 1966 | gmlmsgp = gmlmsg; |
| 1967 | } |
| 1968 | } |
| 1969 | gmlerror (gmlmsgp); |
| 1970 | if (gmlsyntax_error_status == 2) |
| 1971 | goto gmlexhaustedlab; |
| 1972 | } |
| 1973 | # undef YYSYNTAX_ERROR |
| 1974 | #endif |
| 1975 | } |
| 1976 | |
| 1977 | |
| 1978 | |
| 1979 | if (gmlerrstatus == 3) |
| 1980 | { |
| 1981 | /* If just tried and failed to reuse lookahead token after an |
| 1982 | error, discard it. */ |
| 1983 | |
| 1984 | if (gmlchar <= YYEOF) |
| 1985 | { |
| 1986 | /* Return failure if at end of input. */ |
| 1987 | if (gmlchar == YYEOF) |
| 1988 | YYABORT; |
| 1989 | } |
| 1990 | else |
| 1991 | { |
| 1992 | gmldestruct ("Error: discarding" , |
| 1993 | gmltoken, &gmllval); |
| 1994 | gmlchar = YYEMPTY; |
| 1995 | } |
| 1996 | } |
| 1997 | |
| 1998 | /* Else will try to reuse lookahead token after shifting the error |
| 1999 | token. */ |
| 2000 | goto gmlerrlab1; |
| 2001 | |
| 2002 | |
| 2003 | /*---------------------------------------------------. |
| 2004 | | gmlerrorlab -- error raised explicitly by YYERROR. | |
| 2005 | `---------------------------------------------------*/ |
| 2006 | gmlerrorlab: |
| 2007 | |
| 2008 | /* Pacify compilers like GCC when the user code never invokes |
| 2009 | YYERROR and the label gmlerrorlab therefore never appears in user |
| 2010 | code. */ |
| 2011 | if (/*CONSTCOND*/ 0) |
| 2012 | goto gmlerrorlab; |
| 2013 | |
| 2014 | /* Do not reclaim the symbols of the rule whose action triggered |
| 2015 | this YYERROR. */ |
| 2016 | YYPOPSTACK (gmllen); |
| 2017 | gmllen = 0; |
| 2018 | YY_STACK_PRINT (gmlss, gmlssp); |
| 2019 | gmlstate = *gmlssp; |
| 2020 | goto gmlerrlab1; |
| 2021 | |
| 2022 | |
| 2023 | /*-------------------------------------------------------------. |
| 2024 | | gmlerrlab1 -- common code for both syntax error and YYERROR. | |
| 2025 | `-------------------------------------------------------------*/ |
| 2026 | gmlerrlab1: |
| 2027 | gmlerrstatus = 3; /* Each real token shifted decrements this. */ |
| 2028 | |
| 2029 | for (;;) |
| 2030 | { |
| 2031 | gmln = gmlpact[gmlstate]; |
| 2032 | if (!gmlpact_value_is_default (gmln)) |
| 2033 | { |
| 2034 | gmln += YYTERROR; |
| 2035 | if (0 <= gmln && gmln <= YYLAST && gmlcheck[gmln] == YYTERROR) |
| 2036 | { |
| 2037 | gmln = gmltable[gmln]; |
| 2038 | if (0 < gmln) |
| 2039 | break; |
| 2040 | } |
| 2041 | } |
| 2042 | |
| 2043 | /* Pop the current state because it cannot handle the error token. */ |
| 2044 | if (gmlssp == gmlss) |
| 2045 | YYABORT; |
| 2046 | |
| 2047 | |
| 2048 | gmldestruct ("Error: popping" , |
| 2049 | gmlstos[gmlstate], gmlvsp); |
| 2050 | YYPOPSTACK (1); |
| 2051 | gmlstate = *gmlssp; |
| 2052 | YY_STACK_PRINT (gmlss, gmlssp); |
| 2053 | } |
| 2054 | |
| 2055 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
| 2056 | *++gmlvsp = gmllval; |
| 2057 | YY_IGNORE_MAYBE_UNINITIALIZED_END |
| 2058 | |
| 2059 | |
| 2060 | /* Shift the error token. */ |
| 2061 | YY_SYMBOL_PRINT ("Shifting" , gmlstos[gmln], gmlvsp, gmllsp); |
| 2062 | |
| 2063 | gmlstate = gmln; |
| 2064 | goto gmlnewstate; |
| 2065 | |
| 2066 | |
| 2067 | /*-------------------------------------. |
| 2068 | | gmlacceptlab -- YYACCEPT comes here. | |
| 2069 | `-------------------------------------*/ |
| 2070 | gmlacceptlab: |
| 2071 | gmlresult = 0; |
| 2072 | goto gmlreturn; |
| 2073 | |
| 2074 | /*-----------------------------------. |
| 2075 | | gmlabortlab -- YYABORT comes here. | |
| 2076 | `-----------------------------------*/ |
| 2077 | gmlabortlab: |
| 2078 | gmlresult = 1; |
| 2079 | goto gmlreturn; |
| 2080 | |
| 2081 | #if !defined gmloverflow || YYERROR_VERBOSE |
| 2082 | /*-------------------------------------------------. |
| 2083 | | gmlexhaustedlab -- memory exhaustion comes here. | |
| 2084 | `-------------------------------------------------*/ |
| 2085 | gmlexhaustedlab: |
| 2086 | gmlerror (YY_("memory exhausted" )); |
| 2087 | gmlresult = 2; |
| 2088 | /* Fall through. */ |
| 2089 | #endif |
| 2090 | |
| 2091 | gmlreturn: |
| 2092 | if (gmlchar != YYEMPTY) |
| 2093 | { |
| 2094 | /* Make sure we have latest lookahead translation. See comments at |
| 2095 | user semantic actions for why this is necessary. */ |
| 2096 | gmltoken = YYTRANSLATE (gmlchar); |
| 2097 | gmldestruct ("Cleanup: discarding lookahead" , |
| 2098 | gmltoken, &gmllval); |
| 2099 | } |
| 2100 | /* Do not reclaim the symbols of the rule whose action triggered |
| 2101 | this YYABORT or YYACCEPT. */ |
| 2102 | YYPOPSTACK (gmllen); |
| 2103 | YY_STACK_PRINT (gmlss, gmlssp); |
| 2104 | while (gmlssp != gmlss) |
| 2105 | { |
| 2106 | gmldestruct ("Cleanup: popping" , |
| 2107 | gmlstos[*gmlssp], gmlvsp); |
| 2108 | YYPOPSTACK (1); |
| 2109 | } |
| 2110 | #ifndef gmloverflow |
| 2111 | if (gmlss != gmlssa) |
| 2112 | YYSTACK_FREE (gmlss); |
| 2113 | #endif |
| 2114 | #if YYERROR_VERBOSE |
| 2115 | if (gmlmsg != gmlmsgbuf) |
| 2116 | YYSTACK_FREE (gmlmsg); |
| 2117 | #endif |
| 2118 | return gmlresult; |
| 2119 | } |
| 2120 | #line 395 "gmlparse.y" /* yacc.c:1906 */ |
| 2121 | |
| 2122 | |
| 2123 | static void |
| 2124 | free_attr (Dt_t*d, gmlattr* p, Dtdisc_t* ds) |
| 2125 | { |
| 2126 | if (!p) return; |
| 2127 | if ((p->kind == LIST) && p->u.lp) |
| 2128 | dtclose (p->u.lp); |
| 2129 | else |
| 2130 | free (p->u.value); |
| 2131 | free (p->name); |
| 2132 | free (p); |
| 2133 | } |
| 2134 | |
| 2135 | static void deparseList (Dt_t* alist, agxbuf* xb); /* forward declaration */ |
| 2136 | |
| 2137 | static void |
| 2138 | deparseAttr (gmlattr* ap, agxbuf* xb) |
| 2139 | { |
| 2140 | if (ap->kind == LIST) { |
| 2141 | agxbput (xb, ap->name); |
| 2142 | agxbputc (xb, ' '); |
| 2143 | deparseList (ap->u.lp, xb); |
| 2144 | } |
| 2145 | else if (ap->kind == STRING) { |
| 2146 | agxbput (xb, ap->name); |
| 2147 | agxbput (xb, " \"" ); |
| 2148 | agxbput (xb, ap->u.value); |
| 2149 | agxbput (xb, "\"" ); |
| 2150 | } |
| 2151 | else { |
| 2152 | agxbput (xb, ap->name); |
| 2153 | agxbputc (xb, ' '); |
| 2154 | agxbput (xb, ap->u.value); |
| 2155 | } |
| 2156 | } |
| 2157 | |
| 2158 | static void |
| 2159 | deparseList (Dt_t* alist, agxbuf* xb) |
| 2160 | { |
| 2161 | gmlattr* ap; |
| 2162 | |
| 2163 | agxbput (xb, "[ " ); |
| 2164 | if (alist) for (ap = dtfirst(alist); ap; ap = dtnext (alist, ap)) { |
| 2165 | deparseAttr (ap, xb); |
| 2166 | agxbputc (xb, ' '); |
| 2167 | } |
| 2168 | agxbput (xb, "]" ); |
| 2169 | |
| 2170 | } |
| 2171 | |
| 2172 | static void |
| 2173 | unknown (Agobj_t* obj, gmlattr* ap, agxbuf* xb) |
| 2174 | { |
| 2175 | char* str; |
| 2176 | |
| 2177 | if (ap->kind == LIST) { |
| 2178 | deparseList (ap->u.lp, xb); |
| 2179 | str = agxbuse (xb); |
| 2180 | } |
| 2181 | else |
| 2182 | str = ap->u.value; |
| 2183 | |
| 2184 | agsafeset (obj, ap->name, str, "" ); |
| 2185 | } |
| 2186 | |
| 2187 | static void |
| 2188 | addNodeLabelGraphics (Agnode_t* np, Dt_t* alist, agxbuf* xb, agxbuf* unk) |
| 2189 | { |
| 2190 | gmlattr* ap; |
| 2191 | int cnt = 0; |
| 2192 | |
| 2193 | if (!alist) |
| 2194 | return; |
| 2195 | |
| 2196 | for (ap = dtfirst(alist); ap; ap = dtnext (alist, ap)) { |
| 2197 | if (ap->sort == TEXT) { |
| 2198 | agsafeset (np, "label" , ap->u.value, "" ); |
| 2199 | } |
| 2200 | else if (ap->sort == COLOR) { |
| 2201 | agsafeset (np, "fontcolor" , ap->u.value, "" ); |
| 2202 | } |
| 2203 | else if (ap->sort == FONTSIZE) { |
| 2204 | agsafeset (np, "fontsize" , ap->u.value, "" ); |
| 2205 | } |
| 2206 | else if (ap->sort == FONTNAME) { |
| 2207 | agsafeset (np, "fontname" , ap->u.value, "" ); |
| 2208 | } |
| 2209 | else { |
| 2210 | if (cnt) |
| 2211 | agxbputc (unk, ' '); |
| 2212 | else { |
| 2213 | agxbput (unk, "[ " ); |
| 2214 | } |
| 2215 | deparseAttr (ap, unk); |
| 2216 | cnt++; |
| 2217 | } |
| 2218 | } |
| 2219 | |
| 2220 | if (cnt) { |
| 2221 | agxbput (unk, " ]" ); |
| 2222 | agsafeset (np, "LabelGraphics" , agxbuse (unk), "" ); |
| 2223 | } |
| 2224 | else |
| 2225 | agxbclear (unk); |
| 2226 | } |
| 2227 | |
| 2228 | static void |
| 2229 | addEdgeLabelGraphics (Agedge_t* ep, Dt_t* alist, agxbuf* xb, agxbuf* unk) |
| 2230 | { |
| 2231 | gmlattr* ap; |
| 2232 | char* x = "0" ; |
| 2233 | char* y = "0" ; |
| 2234 | int cnt = 0; |
| 2235 | |
| 2236 | if (!alist) |
| 2237 | return; |
| 2238 | |
| 2239 | for (ap = dtfirst(alist); ap; ap = dtnext (alist, ap)) { |
| 2240 | if (ap->sort == TEXT) { |
| 2241 | agsafeset (ep, "label" , ap->u.value, "" ); |
| 2242 | } |
| 2243 | else if (ap->sort == COLOR) { |
| 2244 | agsafeset (ep, "fontcolor" , ap->u.value, "" ); |
| 2245 | } |
| 2246 | else if (ap->sort == FONTSIZE) { |
| 2247 | agsafeset (ep, "fontsize" , ap->u.value, "" ); |
| 2248 | } |
| 2249 | else if (ap->sort == FONTNAME) { |
| 2250 | agsafeset (ep, "fontname" , ap->u.value, "" ); |
| 2251 | } |
| 2252 | else if (ap->sort == XVAL) { |
| 2253 | x = ap->u.value; |
| 2254 | } |
| 2255 | else if (ap->sort == YVAL) { |
| 2256 | y = ap->u.value; |
| 2257 | } |
| 2258 | else { |
| 2259 | if (cnt) |
| 2260 | agxbputc (unk, ' '); |
| 2261 | else { |
| 2262 | agxbput (unk, "[ " ); |
| 2263 | } |
| 2264 | deparseAttr (ap, unk); |
| 2265 | cnt++; |
| 2266 | } |
| 2267 | } |
| 2268 | |
| 2269 | agxbput (xb, x); |
| 2270 | agxbputc (xb, ','); |
| 2271 | agxbput (xb, y); |
| 2272 | agsafeset (ep, "lp" , agxbuse (xb), "" ); |
| 2273 | |
| 2274 | if (cnt) { |
| 2275 | agxbput (unk, " ]" ); |
| 2276 | agsafeset (ep, "LabelGraphics" , agxbuse (unk), "" ); |
| 2277 | } |
| 2278 | else |
| 2279 | agxbclear (unk); |
| 2280 | } |
| 2281 | |
| 2282 | static void |
| 2283 | addNodeGraphics (Agnode_t* np, Dt_t* alist, agxbuf* xb, agxbuf* unk) |
| 2284 | { |
| 2285 | gmlattr* ap; |
| 2286 | char* x = "0" ; |
| 2287 | char* y = "0" ; |
| 2288 | char buf[BUFSIZ]; |
| 2289 | double d; |
| 2290 | int cnt = 0; |
| 2291 | |
| 2292 | for (ap = dtfirst(alist); ap; ap = dtnext (alist, ap)) { |
| 2293 | if (ap->sort == XVAL) { |
| 2294 | x = ap->u.value; |
| 2295 | } |
| 2296 | else if (ap->sort == YVAL) { |
| 2297 | y = ap->u.value; |
| 2298 | } |
| 2299 | else if (ap->sort == WVAL) { |
| 2300 | d = atof (ap->u.value); |
| 2301 | sprintf (buf, "%.04f" , d/72.0); |
| 2302 | agsafeset (np, "width" , buf, "" ); |
| 2303 | } |
| 2304 | else if (ap->sort == HVAL) { |
| 2305 | d = atof (ap->u.value); |
| 2306 | sprintf (buf, "%.04f" , d/72.0); |
| 2307 | agsafeset (np, "height" , buf, "" ); |
| 2308 | } |
| 2309 | else if (ap->sort == TYPE) { |
| 2310 | agsafeset (np, "shape" , ap->u.value, "" ); |
| 2311 | } |
| 2312 | else if (ap->sort == FILL) { |
| 2313 | agsafeset (np, "color" , ap->u.value, "" ); |
| 2314 | } |
| 2315 | else if (ap->sort == OUTLINE) { |
| 2316 | agsafeset (np, "pencolor" , ap->u.value, "" ); |
| 2317 | } |
| 2318 | else if ((ap->sort == WIDTH) && (ap->sort == OUTLINEWIDTH )) { |
| 2319 | agsafeset (np, "penwidth" , ap->u.value, "" ); |
| 2320 | } |
| 2321 | else if ((ap->sort == OUTLINESTYLE) && (ap->sort == OUTLINEWIDTH )) { |
| 2322 | agsafeset (np, "style" , ap->u.value, "" ); |
| 2323 | } |
| 2324 | else { |
| 2325 | if (cnt) |
| 2326 | agxbputc (unk, ' '); |
| 2327 | else { |
| 2328 | agxbput (unk, "[ " ); |
| 2329 | } |
| 2330 | deparseAttr (ap, unk); |
| 2331 | cnt++; |
| 2332 | } |
| 2333 | } |
| 2334 | |
| 2335 | agxbput (xb, x); |
| 2336 | agxbputc (xb, ','); |
| 2337 | agxbput (xb, y); |
| 2338 | agsafeset (np, "pos" , agxbuse (xb), "" ); |
| 2339 | |
| 2340 | if (cnt) { |
| 2341 | agxbput (unk, " ]" ); |
| 2342 | agsafeset (np, "graphics" , agxbuse (unk), "" ); |
| 2343 | } |
| 2344 | else |
| 2345 | agxbclear (unk); |
| 2346 | } |
| 2347 | |
| 2348 | static void |
| 2349 | addEdgePoint (Agedge_t* ep, Dt_t* alist, agxbuf* xb) |
| 2350 | { |
| 2351 | gmlattr* ap; |
| 2352 | char* x = "0" ; |
| 2353 | char* y = "0" ; |
| 2354 | |
| 2355 | for (ap = dtfirst(alist); ap; ap = dtnext (alist, ap)) { |
| 2356 | if (ap->sort == XVAL) { |
| 2357 | x = ap->u.value; |
| 2358 | } |
| 2359 | else if (ap->sort == YVAL) { |
| 2360 | y = ap->u.value; |
| 2361 | } |
| 2362 | else { |
| 2363 | fprintf (stderr, "non-X/Y field in point attribute" ); |
| 2364 | unknown ((Agobj_t*)ep, ap, xb); |
| 2365 | } |
| 2366 | } |
| 2367 | |
| 2368 | if (agxblen(xb)) agxbputc (xb, ' '); |
| 2369 | agxbput (xb, x); |
| 2370 | agxbputc (xb, ','); |
| 2371 | agxbput (xb, y); |
| 2372 | } |
| 2373 | |
| 2374 | static void |
| 2375 | addEdgePos (Agedge_t* ep, Dt_t* alist, agxbuf* xb) |
| 2376 | { |
| 2377 | gmlattr* ap; |
| 2378 | |
| 2379 | if (!alist) return; |
| 2380 | for (ap = dtfirst(alist); ap; ap = dtnext (alist, ap)) { |
| 2381 | if (ap->sort == POINT) { |
| 2382 | addEdgePoint (ep, ap->u.lp, xb); |
| 2383 | } |
| 2384 | else { |
| 2385 | fprintf (stderr, "non-point field in line attribute" ); |
| 2386 | unknown ((Agobj_t*)ep, ap, xb); |
| 2387 | } |
| 2388 | } |
| 2389 | agsafeset (ep, "pos" , agxbuse (xb), "" ); |
| 2390 | } |
| 2391 | |
| 2392 | static void |
| 2393 | addEdgeGraphics (Agedge_t* ep, Dt_t* alist, agxbuf* xb, agxbuf* unk) |
| 2394 | { |
| 2395 | gmlattr* ap; |
| 2396 | int cnt = 0; |
| 2397 | |
| 2398 | for (ap = dtfirst(alist); ap; ap = dtnext (alist, ap)) { |
| 2399 | if (ap->sort == WIDTH) { |
| 2400 | agsafeset (ep, "penwidth" , ap->u.value, "" ); |
| 2401 | } |
| 2402 | else if (ap->sort == STYLE) { |
| 2403 | agsafeset (ep, "style" , ap->u.value, "" ); |
| 2404 | } |
| 2405 | else if (ap->sort == FILL) { |
| 2406 | agsafeset (ep, "color" , ap->u.value, "" ); |
| 2407 | } |
| 2408 | else if (ap->sort == LINE) { |
| 2409 | addEdgePos (ep, ap->u.lp, xb); |
| 2410 | } |
| 2411 | else { |
| 2412 | if (cnt) |
| 2413 | agxbputc (unk, ' '); |
| 2414 | else { |
| 2415 | agxbput (unk, "[ " ); |
| 2416 | } |
| 2417 | deparseAttr (ap, unk); |
| 2418 | cnt++; |
| 2419 | } |
| 2420 | } |
| 2421 | |
| 2422 | if (cnt) { |
| 2423 | agxbput (unk, " ]" ); |
| 2424 | agsafeset (ep, "graphics" , agxbuse (unk), "" ); |
| 2425 | } |
| 2426 | else |
| 2427 | agxbclear(unk); |
| 2428 | } |
| 2429 | |
| 2430 | static void |
| 2431 | addAttrs (Agobj_t* obj, Dt_t* alist, agxbuf* xb, agxbuf* unk) |
| 2432 | { |
| 2433 | gmlattr* ap; |
| 2434 | |
| 2435 | for (ap = dtfirst(alist); ap; ap = dtnext (alist, ap)) { |
| 2436 | if (ap->sort == GRAPHICS) { |
| 2437 | if (AGTYPE(obj) == AGNODE) |
| 2438 | addNodeGraphics ((Agnode_t*)obj, ap->u.lp, xb, unk); |
| 2439 | else if (AGTYPE(obj) == AGEDGE) |
| 2440 | addEdgeGraphics ((Agedge_t*)obj, ap->u.lp, xb, unk); |
| 2441 | else |
| 2442 | unknown (obj, ap, xb); |
| 2443 | } |
| 2444 | else if (ap->sort == LABELGRAPHICS) { |
| 2445 | if (AGTYPE(obj) == AGNODE) |
| 2446 | addNodeLabelGraphics ((Agnode_t*)obj, ap->u.lp, xb, unk); |
| 2447 | else if (AGTYPE(obj) == AGEDGE) |
| 2448 | addEdgeLabelGraphics ((Agedge_t*)obj, ap->u.lp, xb, unk); |
| 2449 | else |
| 2450 | unknown (obj, ap, xb); |
| 2451 | } |
| 2452 | else if ((ap->sort == LABEL) && (AGTYPE(obj) != AGRAPH)) { |
| 2453 | agsafeset (obj, "name" , ap->u.value, "" ); |
| 2454 | } |
| 2455 | else |
| 2456 | unknown (obj, ap, xb); |
| 2457 | } |
| 2458 | } |
| 2459 | |
| 2460 | static Agraph_t* |
| 2461 | mkGraph (gmlgraph* G, Agraph_t* parent, char* name, agxbuf* xb, agxbuf* unk) |
| 2462 | { |
| 2463 | Agraph_t* g; |
| 2464 | Agnode_t* n; |
| 2465 | Agnode_t* h; |
| 2466 | Agedge_t* e; |
| 2467 | gmlnode* np; |
| 2468 | gmledge* ep; |
| 2469 | gmlgraph* gp; |
| 2470 | |
| 2471 | if (parent) { |
| 2472 | g = agsubg (parent, NULL, 1); |
| 2473 | } |
| 2474 | else if (G->directed >= 1) |
| 2475 | g = agopen (name, Agdirected, 0); |
| 2476 | else |
| 2477 | g = agopen (name, Agundirected, 0); |
| 2478 | |
| 2479 | if (!parent && L) { |
| 2480 | addAttrs ((Agobj_t*)g, L, xb, unk); |
| 2481 | } |
| 2482 | for (np = dtfirst(G->nodelist); np; np = dtnext (G->nodelist, np)) { |
| 2483 | if (!np->id) { |
| 2484 | fprintf (stderr, "node without an id attribute" ); |
| 2485 | exit (1); |
| 2486 | } |
| 2487 | n = agnode (g, np->id, 1); |
| 2488 | addAttrs ((Agobj_t*)n, np->attrlist, xb, unk); |
| 2489 | } |
| 2490 | |
| 2491 | for (ep = dtfirst(G->edgelist); ep; ep = dtnext (G->edgelist, ep)) { |
| 2492 | if (!ep->source) { |
| 2493 | fprintf (stderr, "edge without an source attribute" ); |
| 2494 | exit (1); |
| 2495 | } |
| 2496 | if (!ep->target) { |
| 2497 | fprintf (stderr, "node without an target attribute" ); |
| 2498 | exit (1); |
| 2499 | } |
| 2500 | n = agnode (g, ep->source, 1); |
| 2501 | h = agnode (g, ep->target, 1); |
| 2502 | e = agedge (g, n, h, NULL, 1); |
| 2503 | addAttrs ((Agobj_t*)e, ep->attrlist, xb, unk); |
| 2504 | } |
| 2505 | for (gp = dtfirst(G->graphlist); gp; gp = dtnext (G->graphlist, gp)) { |
| 2506 | mkGraph (gp, g, NULL, xb, unk); |
| 2507 | } |
| 2508 | |
| 2509 | addAttrs ((Agobj_t*)g, G->attrlist, xb, unk); |
| 2510 | |
| 2511 | return g; |
| 2512 | } |
| 2513 | |
| 2514 | Agraph_t* |
| 2515 | gml_to_gv (char* name, FILE* fp, int cnt, int* errors) |
| 2516 | { |
| 2517 | Agraph_t* g; |
| 2518 | agxbuf xb; |
| 2519 | unsigned char buf[BUFSIZ]; |
| 2520 | agxbuf unk; |
| 2521 | unsigned char unknownb[BUFSIZ]; |
| 2522 | int error; |
| 2523 | |
| 2524 | if (cnt == 0) |
| 2525 | initgmlscan(fp); |
| 2526 | else |
| 2527 | initgmlscan(0); |
| 2528 | |
| 2529 | initstk(); |
| 2530 | L = NULL; |
| 2531 | pushAlist (); |
| 2532 | gmlparse (); |
| 2533 | |
| 2534 | error = gmlerrors(); |
| 2535 | *errors |= error; |
| 2536 | if (!G || error) |
| 2537 | g = NULL; |
| 2538 | else { |
| 2539 | agxbinit (&xb, BUFSIZ, buf); |
| 2540 | agxbinit (&unk, BUFSIZ, unknownb); |
| 2541 | g = mkGraph (G, NULL, name, &xb, &unk); |
| 2542 | agxbfree (&xb); |
| 2543 | } |
| 2544 | |
| 2545 | cleanup (); |
| 2546 | |
| 2547 | return g; |
| 2548 | } |
| 2549 | |
| 2550 | static char* |
| 2551 | sortToStr (int sort) |
| 2552 | { |
| 2553 | char* s; |
| 2554 | |
| 2555 | switch (sort) { |
| 2556 | case GRAPH : |
| 2557 | s = "graph" ; break; |
| 2558 | case NODE : |
| 2559 | s = "node" ; break; |
| 2560 | case EDGE : |
| 2561 | s = "edge" ; break; |
| 2562 | case DIRECTED : |
| 2563 | s = "directed" ; break; |
| 2564 | case ID : |
| 2565 | s = "id" ; break; |
| 2566 | case SOURCE : |
| 2567 | s = "source" ; break; |
| 2568 | case TARGET : |
| 2569 | s = "target" ; break; |
| 2570 | case XVAL : |
| 2571 | s = "xval" ; break; |
| 2572 | case YVAL : |
| 2573 | s = "yval" ; break; |
| 2574 | case WVAL : |
| 2575 | s = "wval" ; break; |
| 2576 | case HVAL : |
| 2577 | s = "hval" ; break; |
| 2578 | case LABEL : |
| 2579 | s = "label" ; break; |
| 2580 | case GRAPHICS : |
| 2581 | s = "graphics" ; break; |
| 2582 | case LABELGRAPHICS : |
| 2583 | s = "labelGraphics" ; break; |
| 2584 | case TYPE : |
| 2585 | s = "type" ; break; |
| 2586 | case FILL : |
| 2587 | s = "fill" ; break; |
| 2588 | case OUTLINE : |
| 2589 | s = "outline" ; break; |
| 2590 | case OUTLINESTYLE : |
| 2591 | s = "outlineStyle" ; break; |
| 2592 | case OUTLINEWIDTH : |
| 2593 | s = "outlineWidth" ; break; |
| 2594 | case WIDTH : |
| 2595 | s = "width" ; break; |
| 2596 | case STYLE : |
| 2597 | s = "style" ; break; |
| 2598 | case LINE : |
| 2599 | s = "line" ; break; |
| 2600 | case POINT : |
| 2601 | s = "point" ; break; |
| 2602 | case TEXT : |
| 2603 | s = "text" ; break; |
| 2604 | case FONTSIZE : |
| 2605 | s = "fontSize" ; break; |
| 2606 | case FONTNAME : |
| 2607 | s = "fontName" ; break; |
| 2608 | case COLOR : |
| 2609 | s = "color" ; break; |
| 2610 | case INTEGER : |
| 2611 | s = "integer" ; break; |
| 2612 | case REAL : |
| 2613 | s = "real" ; break; |
| 2614 | case STRING : |
| 2615 | s = "string" ; break; |
| 2616 | case NAME : |
| 2617 | s = "name" ; break; |
| 2618 | case LIST : |
| 2619 | s = "list" ; break; |
| 2620 | case '[' : |
| 2621 | s = "[" ; break; |
| 2622 | case ']' : |
| 2623 | s = "]" ; break; |
| 2624 | default : |
| 2625 | s = NULL;break; |
| 2626 | } |
| 2627 | |
| 2628 | return s; |
| 2629 | } |
| 2630 | |
| 2631 | #if 0 |
| 2632 | int gmllex () |
| 2633 | { |
| 2634 | int tok = _gmllex(); |
| 2635 | char* s = sortToStr (tok); |
| 2636 | |
| 2637 | if (s) |
| 2638 | fprintf (stderr, "token = %s\n" , s); |
| 2639 | else |
| 2640 | fprintf (stderr, "token = <%d>\n" , tok); |
| 2641 | return tok; |
| 2642 | } |
| 2643 | #endif |
| 2644 | |
| 2645 | |