gram.c revision fd7d9bd3
1/* A Bison parser, made by GNU Bison 1.875c. */ 2 3/* Skeleton parser for Yacc-like parsing with Bison, 4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 59 Temple Place - Suite 330, 19 Boston, MA 02111-1307, USA. */ 20 21/* As a special exception, when this file is copied by Bison into a 22 Bison output file, you may use that output file without restriction. 23 This special exception was added by the Free Software Foundation 24 in version 1.24 of Bison. */ 25 26/* Written by Richard Stallman by simplifying the original so called 27 ``semantic'' parser. */ 28 29/* All symbols defined below should begin with yy or YY, to avoid 30 infringing on user name space. This should be done even for local 31 variables, as they might otherwise be expanded by user macros. 32 There are some unavoidable exceptions within include files to 33 define necessary library symbols; they are noted "INFRINGES ON 34 USER NAME SPACE" below. */ 35 36/* Identify Bison output. */ 37#define YYBISON 1 38 39/* Skeleton name. */ 40#define YYSKELETON_NAME "yacc.c" 41 42/* Pure parsers. */ 43#define YYPURE 0 44 45/* Using locations. */ 46#define YYLSP_NEEDED 0 47 48 49 50/* Tokens. */ 51#ifndef YYTOKENTYPE 52# define YYTOKENTYPE 53 /* Put the tokens into the symbol table, so that GDB and other debuggers 54 know about them. */ 55 enum yytokentype { 56 STRING = 258, 57 NUMBER = 259, 58 RUN = 260, 59 FUNCTION = 261, 60 FUNCTIONTYPE = 262, 61 TEST = 263, 62 TESTTYPE = 264, 63 LINESTYLE = 265, 64 LINESTYLETYPE = 266, 65 CAPSTYLE = 267, 66 CAPSTYLETYPE = 268, 67 JOINSTYLE = 269, 68 JOINSTYLETYPE = 270, 69 ROUND = 271, 70 SOLID = 272, 71 FILLSTYLE = 273, 72 FILLSTYLETYPE = 274, 73 FILLRULE = 275, 74 FILLRULETYPE = 276, 75 ARCMODE = 277, 76 ARCMODETYPE = 278, 77 FOREGROUND = 279, 78 BACKGROUND = 280, 79 LINEWIDTH = 281, 80 PLANEMASK = 282, 81 DASHLIST = 283, 82 PERCENT = 284, 83 FONT = 285 84 }; 85#endif 86#define STRING 258 87#define NUMBER 259 88#define RUN 260 89#define FUNCTION 261 90#define FUNCTIONTYPE 262 91#define TEST 263 92#define TESTTYPE 264 93#define LINESTYLE 265 94#define LINESTYLETYPE 266 95#define CAPSTYLE 267 96#define CAPSTYLETYPE 268 97#define JOINSTYLE 269 98#define JOINSTYLETYPE 270 99#define ROUND 271 100#define SOLID 272 101#define FILLSTYLE 273 102#define FILLSTYLETYPE 274 103#define FILLRULE 275 104#define FILLRULETYPE 276 105#define ARCMODE 277 106#define ARCMODETYPE 278 107#define FOREGROUND 279 108#define BACKGROUND 280 109#define LINEWIDTH 281 110#define PLANEMASK 282 111#define DASHLIST 283 112#define PERCENT 284 113#define FONT 285 114 115 116 117 118/* Copy the first part of user declarations. */ 119#line 6 "gram.y" 120 121#define YYDEBUG 1 122 123#include <stdio.h> 124#include <X11/X.h> 125#include <X11/Intrinsic.h> 126#include "xgc.h" 127 128extern int yylineno; 129 130 131 132/* Enabling traces. */ 133#ifndef YYDEBUG 134# define YYDEBUG 0 135#endif 136 137/* Enabling verbose error messages. */ 138#ifdef YYERROR_VERBOSE 139# undef YYERROR_VERBOSE 140# define YYERROR_VERBOSE 1 141#else 142# define YYERROR_VERBOSE 0 143#endif 144 145#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) 146#line 19 "gram.y" 147typedef union YYSTYPE { 148 int num; 149 char *ptr; 150} YYSTYPE; 151/* Line 191 of yacc.c. */ 152#line 153 "gram.c" 153# define yystype YYSTYPE /* obsolescent; will be withdrawn */ 154# define YYSTYPE_IS_DECLARED 1 155# define YYSTYPE_IS_TRIVIAL 1 156#endif 157 158 159 160/* Copy the second part of user declarations. */ 161 162 163/* Line 214 of yacc.c. */ 164#line 165 "gram.c" 165 166#if ! defined (yyoverflow) || YYERROR_VERBOSE 167 168# ifndef YYFREE 169# define YYFREE free 170# endif 171# ifndef YYMALLOC 172# define YYMALLOC malloc 173# endif 174 175/* The parser invokes alloca or malloc; define the necessary symbols. */ 176 177# ifdef YYSTACK_USE_ALLOCA 178# if YYSTACK_USE_ALLOCA 179# define YYSTACK_ALLOC alloca 180# endif 181# else 182# if defined (alloca) || defined (_ALLOCA_H) 183# define YYSTACK_ALLOC alloca 184# else 185# ifdef __GNUC__ 186# define YYSTACK_ALLOC __builtin_alloca 187# endif 188# endif 189# endif 190 191# ifdef YYSTACK_ALLOC 192 /* Pacify GCC's `empty if-body' warning. */ 193# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) 194# else 195# if defined (__STDC__) || defined (__cplusplus) 196# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 197# define YYSIZE_T size_t 198# endif 199# define YYSTACK_ALLOC YYMALLOC 200# define YYSTACK_FREE YYFREE 201# endif 202#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ 203 204 205#if (! defined (yyoverflow) \ 206 && (! defined (__cplusplus) \ 207 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) 208 209/* A type that is properly aligned for any stack member. */ 210union yyalloc 211{ 212 short yyss; 213 YYSTYPE yyvs; 214 }; 215 216/* The size of the maximum gap between one aligned stack and the next. */ 217# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) 218 219/* The size of an array large to enough to hold all stacks, each with 220 N elements. */ 221# define YYSTACK_BYTES(N) \ 222 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ 223 + YYSTACK_GAP_MAXIMUM) 224 225/* Copy COUNT objects from FROM to TO. The source and destination do 226 not overlap. */ 227# ifndef YYCOPY 228# if defined (__GNUC__) && 1 < __GNUC__ 229# define YYCOPY(To, From, Count) \ 230 __builtin_memcpy (To, From, (Count) * sizeof (*(From))) 231# else 232# define YYCOPY(To, From, Count) \ 233 do \ 234 { \ 235 register YYSIZE_T yyi; \ 236 for (yyi = 0; yyi < (Count); yyi++) \ 237 (To)[yyi] = (From)[yyi]; \ 238 } \ 239 while (0) 240# endif 241# endif 242 243/* Relocate STACK from its old location to the new one. The 244 local variables YYSIZE and YYSTACKSIZE give the old and new number of 245 elements in the stack, and YYPTR gives the new location of the 246 stack. Advance YYPTR to a properly aligned location for the next 247 stack. */ 248# define YYSTACK_RELOCATE(Stack) \ 249 do \ 250 { \ 251 YYSIZE_T yynewbytes; \ 252 YYCOPY (&yyptr->Stack, Stack, yysize); \ 253 Stack = &yyptr->Stack; \ 254 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ 255 yyptr += yynewbytes / sizeof (*yyptr); \ 256 } \ 257 while (0) 258 259#endif 260 261#if defined (__STDC__) || defined (__cplusplus) 262 typedef signed char yysigned_char; 263#else 264 typedef short yysigned_char; 265#endif 266 267/* YYFINAL -- State number of the termination state. */ 268#define YYFINAL 3 269/* YYLAST -- Last index in YYTABLE. */ 270#define YYLAST 40 271 272/* YYNTOKENS -- Number of terminals. */ 273#define YYNTOKENS 32 274/* YYNNTS -- Number of nonterminals. */ 275#define YYNNTS 4 276/* YYNRULES -- Number of rules. */ 277#define YYNRULES 26 278/* YYNRULES -- Number of states. */ 279#define YYNSTATES 43 280 281/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ 282#define YYUNDEFTOK 2 283#define YYMAXUTOK 285 284 285#define YYTRANSLATE(YYX) \ 286 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) 287 288/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ 289static const unsigned char yytranslate[] = 290{ 291 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 292 31, 2, 2, 2, 2, 2, 2, 2, 2, 2, 293 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 294 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 295 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 296 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 297 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 298 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 299 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 300 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 301 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 302 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 303 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 304 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 305 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 306 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 307 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 308 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 309 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 310 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 311 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 312 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 313 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 314 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 315 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 316 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 317 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 318 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 319 25, 26, 27, 28, 29, 30 320}; 321 322#if YYDEBUG 323/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in 324 YYRHS. */ 325static const unsigned char yyprhs[] = 326{ 327 0, 0, 3, 5, 6, 9, 13, 15, 17, 20, 328 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 329 53, 56, 59, 62, 65, 68, 71 330}; 331 332/* YYRHS -- A `-1'-separated list of the rules' RHS. */ 333static const yysigned_char yyrhs[] = 334{ 335 33, 0, -1, 34, -1, -1, 34, 31, -1, 34, 336 35, 31, -1, 1, -1, 5, -1, 8, 9, -1, 337 6, 7, -1, 10, 11, -1, 10, 17, -1, 12, 338 13, -1, 12, 16, -1, 14, 15, -1, 14, 16, 339 -1, 18, 19, -1, 18, 17, -1, 20, 21, -1, 340 22, 23, -1, 24, 4, -1, 25, 4, -1, 26, 341 4, -1, 27, 4, -1, 28, 4, -1, 30, 3, 342 -1, 29, 4, -1 343}; 344 345/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 346static const unsigned char yyrline[] = 347{ 348 0, 41, 41, 44, 45, 46, 49, 50, 52, 54, 349 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 350 76, 78, 80, 82, 84, 86, 88 351}; 352#endif 353 354#if YYDEBUG || YYERROR_VERBOSE 355/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. 356 First, the terminals, then, starting at YYNTOKENS, nonterminals. */ 357static const char *const yytname[] = 358{ 359 "$end", "error", "$undefined", "STRING", "NUMBER", "RUN", "FUNCTION", 360 "FUNCTIONTYPE", "TEST", "TESTTYPE", "LINESTYLE", "LINESTYLETYPE", 361 "CAPSTYLE", "CAPSTYLETYPE", "JOINSTYLE", "JOINSTYLETYPE", "ROUND", 362 "SOLID", "FILLSTYLE", "FILLSTYLETYPE", "FILLRULE", "FILLRULETYPE", 363 "ARCMODE", "ARCMODETYPE", "FOREGROUND", "BACKGROUND", "LINEWIDTH", 364 "PLANEMASK", "DASHLIST", "PERCENT", "FONT", "'\\n'", "$accept", "all", 365 "stmts", "stmt", 0 366}; 367#endif 368 369# ifdef YYPRINT 370/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to 371 token YYLEX-NUM. */ 372static const unsigned short yytoknum[] = 373{ 374 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 375 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 376 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 377 285, 10 378}; 379# endif 380 381/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 382static const unsigned char yyr1[] = 383{ 384 0, 32, 33, 34, 34, 34, 35, 35, 35, 35, 385 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 386 35, 35, 35, 35, 35, 35, 35 387}; 388 389/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 390static const unsigned char yyr2[] = 391{ 392 0, 2, 1, 0, 2, 3, 1, 1, 2, 2, 393 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 394 2, 2, 2, 2, 2, 2, 2 395}; 396 397/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state 398 STATE-NUM when YYTABLE doesn't specify something else to do. Zero 399 means the default is an error. */ 400static const unsigned char yydefact[] = 401{ 402 3, 0, 0, 1, 6, 7, 0, 0, 0, 0, 403 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 404 0, 4, 0, 9, 8, 10, 11, 12, 13, 14, 405 15, 17, 16, 18, 19, 20, 21, 22, 23, 24, 406 26, 25, 5 407}; 408 409/* YYDEFGOTO[NTERM-NUM]. */ 410static const yysigned_char yydefgoto[] = 411{ 412 -1, 1, 2, 22 413}; 414 415/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 416 STATE-NUM. */ 417#define YYPACT_NINF -10 418static const yysigned_char yypact[] = 419{ 420 -10, 2, 0, -10, -10, -10, 8, 10, -8, -9, 421 1, -6, 11, -2, 19, 29, 30, 31, 32, 33, 422 35, -10, 9, -10, -10, -10, -10, -10, -10, -10, 423 -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, 424 -10, -10, -10 425}; 426 427/* YYPGOTO[NTERM-NUM]. */ 428static const yysigned_char yypgoto[] = 429{ 430 -10, -10, -10, -10 431}; 432 433/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 434 positive, shift that token. If negative, reduce the rule which 435 number is the opposite. If zero, do what YYDEFACT says. 436 If YYTABLE_NINF, syntax error. */ 437#define YYTABLE_NINF -3 438static const yysigned_char yytable[] = 439{ 440 -2, 4, 3, 25, 27, 5, 6, 28, 7, 26, 441 8, 31, 9, 32, 10, 23, 29, 30, 11, 24, 442 12, 34, 13, 35, 14, 15, 16, 17, 18, 19, 443 20, 21, 33, 36, 37, 38, 39, 40, 41, 0, 444 42 445}; 446 447static const yysigned_char yycheck[] = 448{ 449 0, 1, 0, 11, 13, 5, 6, 16, 8, 17, 450 10, 17, 12, 19, 14, 7, 15, 16, 18, 9, 451 20, 23, 22, 4, 24, 25, 26, 27, 28, 29, 452 30, 31, 21, 4, 4, 4, 4, 4, 3, -1, 453 31 454}; 455 456/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing 457 symbol of state STATE-NUM. */ 458static const unsigned char yystos[] = 459{ 460 0, 33, 34, 0, 1, 5, 6, 8, 10, 12, 461 14, 18, 20, 22, 24, 25, 26, 27, 28, 29, 462 30, 31, 35, 7, 9, 11, 17, 13, 16, 15, 463 16, 17, 19, 21, 23, 4, 4, 4, 4, 4, 464 4, 3, 31 465}; 466 467#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) 468# define YYSIZE_T __SIZE_TYPE__ 469#endif 470#if ! defined (YYSIZE_T) && defined (size_t) 471# define YYSIZE_T size_t 472#endif 473#if ! defined (YYSIZE_T) 474# if defined (__STDC__) || defined (__cplusplus) 475# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ 476# define YYSIZE_T size_t 477# endif 478#endif 479#if ! defined (YYSIZE_T) 480# define YYSIZE_T unsigned int 481#endif 482 483#define yyerrok (yyerrstatus = 0) 484#define yyclearin (yychar = YYEMPTY) 485#define YYEMPTY (-2) 486#define YYEOF 0 487 488#define YYACCEPT goto yyacceptlab 489#define YYABORT goto yyabortlab 490#define YYERROR goto yyerrorlab 491 492 493/* Like YYERROR except do call yyerror. This remains here temporarily 494 to ease the transition to the new meaning of YYERROR, for GCC. 495 Once GCC version 2 has supplanted version 1, this can go. */ 496 497#define YYFAIL goto yyerrlab 498 499#define YYRECOVERING() (!!yyerrstatus) 500 501#define YYBACKUP(Token, Value) \ 502do \ 503 if (yychar == YYEMPTY && yylen == 1) \ 504 { \ 505 yychar = (Token); \ 506 yylval = (Value); \ 507 yytoken = YYTRANSLATE (yychar); \ 508 YYPOPSTACK; \ 509 goto yybackup; \ 510 } \ 511 else \ 512 { \ 513 yyerror ("syntax error: cannot back up");\ 514 YYERROR; \ 515 } \ 516while (0) 517 518#define YYTERROR 1 519#define YYERRCODE 256 520 521/* YYLLOC_DEFAULT -- Compute the default location (before the actions 522 are run). */ 523 524#ifndef YYLLOC_DEFAULT 525# define YYLLOC_DEFAULT(Current, Rhs, N) \ 526 ((Current).first_line = (Rhs)[1].first_line, \ 527 (Current).first_column = (Rhs)[1].first_column, \ 528 (Current).last_line = (Rhs)[N].last_line, \ 529 (Current).last_column = (Rhs)[N].last_column) 530#endif 531 532/* YYLEX -- calling `yylex' with the right arguments. */ 533 534#ifdef YYLEX_PARAM 535# define YYLEX yylex (YYLEX_PARAM) 536#else 537# define YYLEX yylex () 538#endif 539 540/* Enable debugging if requested. */ 541#if YYDEBUG 542 543# ifndef YYFPRINTF 544# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ 545# define YYFPRINTF fprintf 546# endif 547 548# define YYDPRINTF(Args) \ 549do { \ 550 if (yydebug) \ 551 YYFPRINTF Args; \ 552} while (0) 553 554# define YYDSYMPRINT(Args) \ 555do { \ 556 if (yydebug) \ 557 yysymprint Args; \ 558} while (0) 559 560# define YYDSYMPRINTF(Title, Token, Value, Location) \ 561do { \ 562 if (yydebug) \ 563 { \ 564 YYFPRINTF (stderr, "%s ", Title); \ 565 yysymprint (stderr, \ 566 Token, Value); \ 567 YYFPRINTF (stderr, "\n"); \ 568 } \ 569} while (0) 570 571/*------------------------------------------------------------------. 572| yy_stack_print -- Print the state stack from its BOTTOM up to its | 573| TOP (included). | 574`------------------------------------------------------------------*/ 575 576#if defined (__STDC__) || defined (__cplusplus) 577static void 578yy_stack_print (short *bottom, short *top) 579#else 580static void 581yy_stack_print (bottom, top) 582 short *bottom; 583 short *top; 584#endif 585{ 586 YYFPRINTF (stderr, "Stack now"); 587 for (/* Nothing. */; bottom <= top; ++bottom) 588 YYFPRINTF (stderr, " %d", *bottom); 589 YYFPRINTF (stderr, "\n"); 590} 591 592# define YY_STACK_PRINT(Bottom, Top) \ 593do { \ 594 if (yydebug) \ 595 yy_stack_print ((Bottom), (Top)); \ 596} while (0) 597 598 599/*------------------------------------------------. 600| Report that the YYRULE is going to be reduced. | 601`------------------------------------------------*/ 602 603#if defined (__STDC__) || defined (__cplusplus) 604static void 605yy_reduce_print (int yyrule) 606#else 607static void 608yy_reduce_print (yyrule) 609 int yyrule; 610#endif 611{ 612 int yyi; 613 unsigned int yylno = yyrline[yyrule]; 614 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", 615 yyrule - 1, yylno); 616 /* Print the symbols being reduced, and their result. */ 617 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) 618 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); 619 YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); 620} 621 622# define YY_REDUCE_PRINT(Rule) \ 623do { \ 624 if (yydebug) \ 625 yy_reduce_print (Rule); \ 626} while (0) 627 628/* Nonzero means print parse trace. It is left uninitialized so that 629 multiple parsers can coexist. */ 630int yydebug; 631#else /* !YYDEBUG */ 632# define YYDPRINTF(Args) 633# define YYDSYMPRINT(Args) 634# define YYDSYMPRINTF(Title, Token, Value, Location) 635# define YY_STACK_PRINT(Bottom, Top) 636# define YY_REDUCE_PRINT(Rule) 637#endif /* !YYDEBUG */ 638 639 640/* YYINITDEPTH -- initial size of the parser's stacks. */ 641#ifndef YYINITDEPTH 642# define YYINITDEPTH 200 643#endif 644 645/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only 646 if the built-in stack extension method is used). 647 648 Do not make this value too large; the results are undefined if 649 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) 650 evaluated with infinite-precision integer arithmetic. */ 651 652#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 653# undef YYMAXDEPTH 654#endif 655 656#ifndef YYMAXDEPTH 657# define YYMAXDEPTH 10000 658#endif 659 660 661 662#if YYERROR_VERBOSE 663 664# ifndef yystrlen 665# if defined (__GLIBC__) && defined (_STRING_H) 666# define yystrlen strlen 667# else 668/* Return the length of YYSTR. */ 669static YYSIZE_T 670# if defined (__STDC__) || defined (__cplusplus) 671yystrlen (const char *yystr) 672# else 673yystrlen (yystr) 674 const char *yystr; 675# endif 676{ 677 register const char *yys = yystr; 678 679 while (*yys++ != '\0') 680 continue; 681 682 return yys - yystr - 1; 683} 684# endif 685# endif 686 687# ifndef yystpcpy 688# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) 689# define yystpcpy stpcpy 690# else 691/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in 692 YYDEST. */ 693static char * 694# if defined (__STDC__) || defined (__cplusplus) 695yystpcpy (char *yydest, const char *yysrc) 696# else 697yystpcpy (yydest, yysrc) 698 char *yydest; 699 const char *yysrc; 700# endif 701{ 702 register char *yyd = yydest; 703 register const char *yys = yysrc; 704 705 while ((*yyd++ = *yys++) != '\0') 706 continue; 707 708 return yyd - 1; 709} 710# endif 711# endif 712 713#endif /* !YYERROR_VERBOSE */ 714 715 716 717#if YYDEBUG 718/*--------------------------------. 719| Print this symbol on YYOUTPUT. | 720`--------------------------------*/ 721 722#if defined (__STDC__) || defined (__cplusplus) 723static void 724yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) 725#else 726static void 727yysymprint (yyoutput, yytype, yyvaluep) 728 FILE *yyoutput; 729 int yytype; 730 YYSTYPE *yyvaluep; 731#endif 732{ 733 /* Pacify ``unused variable'' warnings. */ 734 (void) yyvaluep; 735 736 if (yytype < YYNTOKENS) 737 { 738 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); 739# ifdef YYPRINT 740 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); 741# endif 742 } 743 else 744 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); 745 746 switch (yytype) 747 { 748 default: 749 break; 750 } 751 YYFPRINTF (yyoutput, ")"); 752} 753 754#endif /* ! YYDEBUG */ 755/*-----------------------------------------------. 756| Release the memory associated to this symbol. | 757`-----------------------------------------------*/ 758 759#if defined (__STDC__) || defined (__cplusplus) 760static void 761yydestruct (int yytype, YYSTYPE *yyvaluep) 762#else 763static void 764yydestruct (yytype, yyvaluep) 765 int yytype; 766 YYSTYPE *yyvaluep; 767#endif 768{ 769 /* Pacify ``unused variable'' warnings. */ 770 (void) yyvaluep; 771 772 switch (yytype) 773 { 774 775 default: 776 break; 777 } 778} 779 780 781/* Prevent warnings from -Wmissing-prototypes. */ 782 783#ifdef YYPARSE_PARAM 784# if defined (__STDC__) || defined (__cplusplus) 785int yyparse (void *YYPARSE_PARAM); 786# else 787int yyparse (); 788# endif 789#else /* ! YYPARSE_PARAM */ 790#if defined (__STDC__) || defined (__cplusplus) 791int yyparse (void); 792#else 793int yyparse (); 794#endif 795#endif /* ! YYPARSE_PARAM */ 796 797 798 799/* The lookahead symbol. */ 800int yychar; 801 802/* The semantic value of the lookahead symbol. */ 803YYSTYPE yylval; 804 805/* Number of syntax errors so far. */ 806int yynerrs; 807 808 809 810/*----------. 811| yyparse. | 812`----------*/ 813 814#ifdef YYPARSE_PARAM 815# if defined (__STDC__) || defined (__cplusplus) 816int yyparse (void *YYPARSE_PARAM) 817# else 818int yyparse (YYPARSE_PARAM) 819 void *YYPARSE_PARAM; 820# endif 821#else /* ! YYPARSE_PARAM */ 822#if defined (__STDC__) || defined (__cplusplus) 823int 824yyparse (void) 825#else 826int 827yyparse () 828 829#endif 830#endif 831{ 832 833 register int yystate; 834 register int yyn; 835 int yyresult; 836 /* Number of tokens to shift before error messages enabled. */ 837 int yyerrstatus; 838 /* Lookahead token as an internal (translated) token number. */ 839 int yytoken = 0; 840 841 /* Three stacks and their tools: 842 `yyss': related to states, 843 `yyvs': related to semantic values, 844 `yyls': related to locations. 845 846 Refer to the stacks thru separate pointers, to allow yyoverflow 847 to reallocate them elsewhere. */ 848 849 /* The state stack. */ 850 short yyssa[YYINITDEPTH]; 851 short *yyss = yyssa; 852 register short *yyssp; 853 854 /* The semantic value stack. */ 855 YYSTYPE yyvsa[YYINITDEPTH]; 856 YYSTYPE *yyvs = yyvsa; 857 register YYSTYPE *yyvsp; 858 859 860 861#define YYPOPSTACK (yyvsp--, yyssp--) 862 863 YYSIZE_T yystacksize = YYINITDEPTH; 864 865 /* The variables used to return semantic value and location from the 866 action routines. */ 867 YYSTYPE yyval; 868 869 870 /* When reducing, the number of symbols on the RHS of the reduced 871 rule. */ 872 int yylen; 873 874 YYDPRINTF ((stderr, "Starting parse\n")); 875 876 yystate = 0; 877 yyerrstatus = 0; 878 yynerrs = 0; 879 yychar = YYEMPTY; /* Cause a token to be read. */ 880 881 /* Initialize stack pointers. 882 Waste one element of value and location stack 883 so that they stay on the same level as the state stack. 884 The wasted elements are never initialized. */ 885 886 yyssp = yyss; 887 yyvsp = yyvs; 888 889 goto yysetstate; 890 891/*------------------------------------------------------------. 892| yynewstate -- Push a new state, which is found in yystate. | 893`------------------------------------------------------------*/ 894 yynewstate: 895 /* In all cases, when you get here, the value and location stacks 896 have just been pushed. so pushing a state here evens the stacks. 897 */ 898 yyssp++; 899 900 yysetstate: 901 *yyssp = yystate; 902 903 if (yyss + yystacksize - 1 <= yyssp) 904 { 905 /* Get the current used size of the three stacks, in elements. */ 906 YYSIZE_T yysize = yyssp - yyss + 1; 907 908#ifdef yyoverflow 909 { 910 /* Give user a chance to reallocate the stack. Use copies of 911 these so that the &'s don't force the real ones into 912 memory. */ 913 YYSTYPE *yyvs1 = yyvs; 914 short *yyss1 = yyss; 915 916 917 /* Each stack pointer address is followed by the size of the 918 data in use in that stack, in bytes. This used to be a 919 conditional around just the two extra args, but that might 920 be undefined if yyoverflow is a macro. */ 921 yyoverflow ("parser stack overflow", 922 &yyss1, yysize * sizeof (*yyssp), 923 &yyvs1, yysize * sizeof (*yyvsp), 924 925 &yystacksize); 926 927 yyss = yyss1; 928 yyvs = yyvs1; 929 } 930#else /* no yyoverflow */ 931# ifndef YYSTACK_RELOCATE 932 goto yyoverflowlab; 933# else 934 /* Extend the stack our own way. */ 935 if (YYMAXDEPTH <= yystacksize) 936 goto yyoverflowlab; 937 yystacksize *= 2; 938 if (YYMAXDEPTH < yystacksize) 939 yystacksize = YYMAXDEPTH; 940 941 { 942 short *yyss1 = yyss; 943 union yyalloc *yyptr = 944 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 945 if (! yyptr) 946 goto yyoverflowlab; 947 YYSTACK_RELOCATE (yyss); 948 YYSTACK_RELOCATE (yyvs); 949 950# undef YYSTACK_RELOCATE 951 if (yyss1 != yyssa) 952 YYSTACK_FREE (yyss1); 953 } 954# endif 955#endif /* no yyoverflow */ 956 957 yyssp = yyss + yysize - 1; 958 yyvsp = yyvs + yysize - 1; 959 960 961 YYDPRINTF ((stderr, "Stack size increased to %lu\n", 962 (unsigned long int) yystacksize)); 963 964 if (yyss + yystacksize - 1 <= yyssp) 965 YYABORT; 966 } 967 968 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 969 970 goto yybackup; 971 972/*-----------. 973| yybackup. | 974`-----------*/ 975yybackup: 976 977/* Do appropriate processing given the current state. */ 978/* Read a lookahead token if we need one and don't already have one. */ 979/* yyresume: */ 980 981 /* First try to decide what to do without reference to lookahead token. */ 982 983 yyn = yypact[yystate]; 984 if (yyn == YYPACT_NINF) 985 goto yydefault; 986 987 /* Not known => get a lookahead token if don't already have one. */ 988 989 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ 990 if (yychar == YYEMPTY) 991 { 992 YYDPRINTF ((stderr, "Reading a token: ")); 993 yychar = YYLEX; 994 } 995 996 if (yychar <= YYEOF) 997 { 998 yychar = yytoken = YYEOF; 999 YYDPRINTF ((stderr, "Now at end of input.\n")); 1000 } 1001 else 1002 { 1003 yytoken = YYTRANSLATE (yychar); 1004 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); 1005 } 1006 1007 /* If the proper action on seeing token YYTOKEN is to reduce or to 1008 detect an error, take that action. */ 1009 yyn += yytoken; 1010 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) 1011 goto yydefault; 1012 yyn = yytable[yyn]; 1013 if (yyn <= 0) 1014 { 1015 if (yyn == 0 || yyn == YYTABLE_NINF) 1016 goto yyerrlab; 1017 yyn = -yyn; 1018 goto yyreduce; 1019 } 1020 1021 if (yyn == YYFINAL) 1022 YYACCEPT; 1023 1024 /* Shift the lookahead token. */ 1025 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); 1026 1027 /* Discard the token being shifted unless it is eof. */ 1028 if (yychar != YYEOF) 1029 yychar = YYEMPTY; 1030 1031 *++yyvsp = yylval; 1032 1033 1034 /* Count tokens shifted since error; after three, turn off error 1035 status. */ 1036 if (yyerrstatus) 1037 yyerrstatus--; 1038 1039 yystate = yyn; 1040 goto yynewstate; 1041 1042 1043/*-----------------------------------------------------------. 1044| yydefault -- do the default action for the current state. | 1045`-----------------------------------------------------------*/ 1046yydefault: 1047 yyn = yydefact[yystate]; 1048 if (yyn == 0) 1049 goto yyerrlab; 1050 goto yyreduce; 1051 1052 1053/*-----------------------------. 1054| yyreduce -- Do a reduction. | 1055`-----------------------------*/ 1056yyreduce: 1057 /* yyn is the number of a rule to reduce with. */ 1058 yylen = yyr2[yyn]; 1059 1060 /* If YYLEN is nonzero, implement the default value of the action: 1061 `$$ = $1'. 1062 1063 Otherwise, the following line sets YYVAL to garbage. 1064 This behavior is undocumented and Bison 1065 users should not rely upon it. Assigning to YYVAL 1066 unconditionally makes the parser a bit smaller, and it avoids a 1067 GCC warning that YYVAL may be used uninitialized. */ 1068 yyval = yyvsp[1-yylen]; 1069 1070 1071 YY_REDUCE_PRINT (yyn); 1072 switch (yyn) 1073 { 1074 case 7: 1075#line 51 "gram.y" 1076 { run_test(); } 1077 break; 1078 1079 case 8: 1080#line 53 "gram.y" 1081 { change_test (yyvsp[0].num, TRUE); } 1082 break; 1083 1084 case 9: 1085#line 55 "gram.y" 1086 { GC_change_function (yyvsp[0].num, TRUE); } 1087 break; 1088 1089 case 10: 1090#line 57 "gram.y" 1091 { GC_change_linestyle (yyvsp[0].num, TRUE); } 1092 break; 1093 1094 case 11: 1095#line 59 "gram.y" 1096 { GC_change_linestyle (LineSolid, TRUE); } 1097 break; 1098 1099 case 12: 1100#line 61 "gram.y" 1101 { GC_change_capstyle (yyvsp[0].num, TRUE); } 1102 break; 1103 1104 case 13: 1105#line 63 "gram.y" 1106 { GC_change_capstyle (CapRound, TRUE); } 1107 break; 1108 1109 case 14: 1110#line 65 "gram.y" 1111 { GC_change_joinstyle (yyvsp[0].num, TRUE); } 1112 break; 1113 1114 case 15: 1115#line 67 "gram.y" 1116 { GC_change_joinstyle (JoinRound, TRUE); } 1117 break; 1118 1119 case 16: 1120#line 69 "gram.y" 1121 { GC_change_fillstyle (yyvsp[0].num, TRUE); } 1122 break; 1123 1124 case 17: 1125#line 71 "gram.y" 1126 { GC_change_fillstyle (FillSolid, TRUE); } 1127 break; 1128 1129 case 18: 1130#line 73 "gram.y" 1131 { GC_change_fillrule (yyvsp[0].num, TRUE); } 1132 break; 1133 1134 case 19: 1135#line 75 "gram.y" 1136 { GC_change_arcmode (yyvsp[0].num, TRUE); } 1137 break; 1138 1139 case 20: 1140#line 77 "gram.y" 1141 { GC_change_foreground (yyvsp[0].num, TRUE); } 1142 break; 1143 1144 case 21: 1145#line 79 "gram.y" 1146 { GC_change_background (yyvsp[0].num, TRUE); } 1147 break; 1148 1149 case 22: 1150#line 81 "gram.y" 1151 { GC_change_linewidth (yyvsp[0].num, TRUE); } 1152 break; 1153 1154 case 23: 1155#line 83 "gram.y" 1156 { GC_change_planemask (yyvsp[0].num, TRUE); } 1157 break; 1158 1159 case 24: 1160#line 85 "gram.y" 1161 { GC_change_dashlist (yyvsp[0].num, TRUE); } 1162 break; 1163 1164 case 25: 1165#line 87 "gram.y" 1166 { GC_change_font (yyvsp[0].ptr, TRUE); } 1167 break; 1168 1169 case 26: 1170#line 89 "gram.y" 1171 { change_percent (yyvsp[0].num, TRUE); } 1172 break; 1173 1174 1175 } 1176 1177/* Line 1000 of yacc.c. */ 1178#line 1179 "gram.c" 1179 1180 yyvsp -= yylen; 1181 yyssp -= yylen; 1182 1183 1184 YY_STACK_PRINT (yyss, yyssp); 1185 1186 *++yyvsp = yyval; 1187 1188 1189 /* Now `shift' the result of the reduction. Determine what state 1190 that goes to, based on the state we popped back to and the rule 1191 number reduced by. */ 1192 1193 yyn = yyr1[yyn]; 1194 1195 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; 1196 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) 1197 yystate = yytable[yystate]; 1198 else 1199 yystate = yydefgoto[yyn - YYNTOKENS]; 1200 1201 goto yynewstate; 1202 1203 1204/*------------------------------------. 1205| yyerrlab -- here on detecting error | 1206`------------------------------------*/ 1207yyerrlab: 1208 /* If not already recovering from an error, report this error. */ 1209 if (!yyerrstatus) 1210 { 1211 ++yynerrs; 1212#if YYERROR_VERBOSE 1213 yyn = yypact[yystate]; 1214 1215 if (YYPACT_NINF < yyn && yyn < YYLAST) 1216 { 1217 YYSIZE_T yysize = 0; 1218 int yytype = YYTRANSLATE (yychar); 1219 const char* yyprefix; 1220 char *yymsg; 1221 int yyx; 1222 1223 /* Start YYX at -YYN if negative to avoid negative indexes in 1224 YYCHECK. */ 1225 int yyxbegin = yyn < 0 ? -yyn : 0; 1226 1227 /* Stay within bounds of both yycheck and yytname. */ 1228 int yychecklim = YYLAST - yyn; 1229 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; 1230 int yycount = 0; 1231 1232 yyprefix = ", expecting "; 1233 for (yyx = yyxbegin; yyx < yyxend; ++yyx) 1234 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) 1235 { 1236 yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); 1237 yycount += 1; 1238 if (yycount == 5) 1239 { 1240 yysize = 0; 1241 break; 1242 } 1243 } 1244 yysize += (sizeof ("syntax error, unexpected ") 1245 + yystrlen (yytname[yytype])); 1246 yymsg = (char *) YYSTACK_ALLOC (yysize); 1247 if (yymsg != 0) 1248 { 1249 char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); 1250 yyp = yystpcpy (yyp, yytname[yytype]); 1251 1252 if (yycount < 5) 1253 { 1254 yyprefix = ", expecting "; 1255 for (yyx = yyxbegin; yyx < yyxend; ++yyx) 1256 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) 1257 { 1258 yyp = yystpcpy (yyp, yyprefix); 1259 yyp = yystpcpy (yyp, yytname[yyx]); 1260 yyprefix = " or "; 1261 } 1262 } 1263 yyerror (yymsg); 1264 YYSTACK_FREE (yymsg); 1265 } 1266 else 1267 yyerror ("syntax error; also virtual memory exhausted"); 1268 } 1269 else 1270#endif /* YYERROR_VERBOSE */ 1271 yyerror ("syntax error"); 1272 } 1273 1274 1275 1276 if (yyerrstatus == 3) 1277 { 1278 /* If just tried and failed to reuse lookahead token after an 1279 error, discard it. */ 1280 1281 if (yychar <= YYEOF) 1282 { 1283 /* If at end of input, pop the error token, 1284 then the rest of the stack, then return failure. */ 1285 if (yychar == YYEOF) 1286 for (;;) 1287 { 1288 YYPOPSTACK; 1289 if (yyssp == yyss) 1290 YYABORT; 1291 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); 1292 yydestruct (yystos[*yyssp], yyvsp); 1293 } 1294 } 1295 else 1296 { 1297 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); 1298 yydestruct (yytoken, &yylval); 1299 yychar = YYEMPTY; 1300 1301 } 1302 } 1303 1304 /* Else will try to reuse lookahead token after shifting the error 1305 token. */ 1306 goto yyerrlab1; 1307 1308 1309/*---------------------------------------------------. 1310| yyerrorlab -- error raised explicitly by YYERROR. | 1311`---------------------------------------------------*/ 1312yyerrorlab: 1313 1314#ifdef __GNUC__ 1315 /* Pacify GCC when the user code never invokes YYERROR and the label 1316 yyerrorlab therefore never appears in user code. */ 1317 if (0) 1318 goto yyerrorlab; 1319#endif 1320 1321 yyvsp -= yylen; 1322 yyssp -= yylen; 1323 yystate = *yyssp; 1324 goto yyerrlab1; 1325 1326 1327/*-------------------------------------------------------------. 1328| yyerrlab1 -- common code for both syntax error and YYERROR. | 1329`-------------------------------------------------------------*/ 1330yyerrlab1: 1331 yyerrstatus = 3; /* Each real token shifted decrements this. */ 1332 1333 for (;;) 1334 { 1335 yyn = yypact[yystate]; 1336 if (yyn != YYPACT_NINF) 1337 { 1338 yyn += YYTERROR; 1339 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) 1340 { 1341 yyn = yytable[yyn]; 1342 if (0 < yyn) 1343 break; 1344 } 1345 } 1346 1347 /* Pop the current state because it cannot handle the error token. */ 1348 if (yyssp == yyss) 1349 YYABORT; 1350 1351 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); 1352 yydestruct (yystos[yystate], yyvsp); 1353 YYPOPSTACK; 1354 yystate = *yyssp; 1355 YY_STACK_PRINT (yyss, yyssp); 1356 } 1357 1358 if (yyn == YYFINAL) 1359 YYACCEPT; 1360 1361 YYDPRINTF ((stderr, "Shifting error token, ")); 1362 1363 *++yyvsp = yylval; 1364 1365 1366 yystate = yyn; 1367 goto yynewstate; 1368 1369 1370/*-------------------------------------. 1371| yyacceptlab -- YYACCEPT comes here. | 1372`-------------------------------------*/ 1373yyacceptlab: 1374 yyresult = 0; 1375 goto yyreturn; 1376 1377/*-----------------------------------. 1378| yyabortlab -- YYABORT comes here. | 1379`-----------------------------------*/ 1380yyabortlab: 1381 yyresult = 1; 1382 goto yyreturn; 1383 1384#ifndef yyoverflow 1385/*----------------------------------------------. 1386| yyoverflowlab -- parser overflow comes here. | 1387`----------------------------------------------*/ 1388yyoverflowlab: 1389 yyerror ("parser stack overflow"); 1390 yyresult = 2; 1391 /* Fall through. */ 1392#endif 1393 1394yyreturn: 1395#ifndef yyoverflow 1396 if (yyss != yyssa) 1397 YYSTACK_FREE (yyss); 1398#endif 1399 return yyresult; 1400} 1401 1402 1403#line 92 "gram.y" 1404 1405void 1406yyerror(const char *s) 1407{ 1408 fprintf(stderr, "xgc: syntax error, line %d\n", yylineno); 1409} 1410 1411