LTP GCOV extension - code coverage report
Current view: directory - csrc/cl - y.tab.c
Test: app.info
Date: 2007-12-10 Instrumented lines: 221
Code covered: 71.5 % Executed lines: 158

       1                 : /* A Bison parser, made by GNU Bison 2.3.  */
       2                 : 
       3                 : /* Skeleton implementation for Bison's Yacc-like parsers in C
       4                 : 
       5                 :    Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
       6                 :    Free Software Foundation, Inc.
       7                 : 
       8                 :    This program is free software; you can redistribute it and/or modify
       9                 :    it under the terms of the GNU General Public License as published by
      10                 :    the Free Software Foundation; either version 2, or (at your option)
      11                 :    any later version.
      12                 : 
      13                 :    This program is distributed in the hope that it will be useful,
      14                 :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      15                 :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16                 :    GNU General Public License for more details.
      17                 : 
      18                 :    You should have received a copy of the GNU General Public License
      19                 :    along with this program; if not, write to the Free Software
      20                 :    Foundation, Inc., 51 Franklin Street, Fifth Floor,
      21                 :    Boston, MA 02110-1301, USA.  */
      22                 : 
      23                 : /* As a special exception, you may create a larger work that contains
      24                 :    part or all of the Bison parser skeleton and distribute that work
      25                 :    under terms of your choice, so long as that work isn't itself a
      26                 :    parser generator using the skeleton or a modified version thereof
      27                 :    as a parser skeleton.  Alternatively, if you modify or redistribute
      28                 :    the parser skeleton itself, you may (at your option) remove this
      29                 :    special exception, which will cause the skeleton and the resulting
      30                 :    Bison output files to be licensed under the GNU General Public
      31                 :    License without this special exception.
      32                 : 
      33                 :    This special exception was added by the Free Software Foundation in
      34                 :    version 2.2 of Bison.  */
      35                 : 
      36                 : /* C LALR(1) parser skeleton written by Richard Stallman, by
      37                 :    simplifying the original so-called "semantic" parser.  */
      38                 : 
      39                 : /* All symbols defined below should begin with yy or YY, to avoid
      40                 :    infringing on user name space.  This should be done even for local
      41                 :    variables, as they might otherwise be expanded by user macros.
      42                 :    There are some unavoidable exceptions within include files to
      43                 :    define necessary library symbols; they are noted "INFRINGES ON
      44                 :    USER NAME SPACE" below.  */
      45                 : 
      46                 : /* Identify Bison output.  */
      47                 : #define YYBISON 1
      48                 : 
      49                 : /* Bison version.  */
      50                 : #define YYBISON_VERSION "2.3"
      51                 : 
      52                 : /* Skeleton name.  */
      53                 : #define YYSKELETON_NAME "yacc.c"
      54                 : 
      55                 : /* Pure parsers.  */
      56                 : #define YYPURE 0
      57                 : 
      58                 : /* Using locations.  */
      59                 : #define YYLSP_NEEDED 0
      60                 : 
      61                 : 
      62                 : 
      63                 : /* Tokens.  */
      64                 : #ifndef YYTOKENTYPE
      65                 : # define YYTOKENTYPE
      66                 :    /* Put the tokens into the symbol table, so that GDB and other debuggers
      67                 :       know about them.  */
      68                 :    enum yytokentype {
      69                 :      TK_EOL = 258,
      70                 :      TK_LPAREN = 259,
      71                 :      TK_RPAREN = 260,
      72                 :      TK_LBRACK = 261,
      73                 :      TK_RBRACK = 262,
      74                 :      TK_IDENTIFIER = 263,
      75                 :      TK_PRIMITIVE = 264,
      76                 :      STRING_LITERAL = 265,
      77                 :      TK_REDUCE = 266,
      78                 :      TK_TIMEOUT = 267,
      79                 :      NUMERICAL_CONSTANT = 268,
      80                 :      TK_ALGORITHM_NAME = 269,
      81                 :      TK_DEF = 270,
      82                 :      TK_TIME = 271,
      83                 :      TK_LOAD = 272,
      84                 :      TK_ELABORATE = 273,
      85                 :      TK_TRACE = 274,
      86                 :      TK_SINGLE_STEP = 275,
      87                 :      TK_DEBUG = 276,
      88                 :      TK_MAX_COUNT = 277,
      89                 :      TK_SET_BRACKET_ABSTRACTION = 278
      90                 :    };
      91                 : #endif
      92                 : /* Tokens.  */
      93                 : #define TK_EOL 258
      94                 : #define TK_LPAREN 259
      95                 : #define TK_RPAREN 260
      96                 : #define TK_LBRACK 261
      97                 : #define TK_RBRACK 262
      98                 : #define TK_IDENTIFIER 263
      99                 : #define TK_PRIMITIVE 264
     100                 : #define STRING_LITERAL 265
     101                 : #define TK_REDUCE 266
     102                 : #define TK_TIMEOUT 267
     103                 : #define NUMERICAL_CONSTANT 268
     104                 : #define TK_ALGORITHM_NAME 269
     105                 : #define TK_DEF 270
     106                 : #define TK_TIME 271
     107                 : #define TK_LOAD 272
     108                 : #define TK_ELABORATE 273
     109                 : #define TK_TRACE 274
     110                 : #define TK_SINGLE_STEP 275
     111                 : #define TK_DEBUG 276
     112                 : #define TK_MAX_COUNT 277
     113                 : #define TK_SET_BRACKET_ABSTRACTION 278
     114                 : 
     115                 : 
     116                 : 
     117                 : 
     118                 : /* Copy the first part of user declarations.  */
     119                 : #line 1 "grammar.y"
     120                 : 
     121                 : /*
     122                 :         Copyright (C) 2007, Bruce Ediger
     123                 : 
     124                 :     This file is part of cl.
     125                 : 
     126                 :     cl is free software; you can redistribute it and/or modify
     127                 :     it under the terms of the GNU General Public License as published by
     128                 :     the Free Software Foundation; either version 2 of the License, or
     129                 :     (at your option) any later version.
     130                 : 
     131                 :     cl is distributed in the hope that it will be useful,
     132                 :     but WITHOUT ANY WARRANTY; without even the implied warranty of
     133                 :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     134                 :     GNU General Public License for more details.
     135                 : 
     136                 :     You should have received a copy of the GNU General Public License
     137                 :     along with cl; if not, write to the Free Software
     138                 :     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     139                 : 
     140                 : */
     141                 : #include <stdio.h>
     142                 : #include <errno.h>    /* errno */
     143                 : #include <string.h>   /* strerror() */
     144                 : #include <stdlib.h>   /* malloc(), free(), strtoul() */
     145                 : #include <unistd.h>   /* getopt() */
     146                 : #include <signal.h>   /* signal(), etc */
     147                 : #include <setjmp.h>   /* setjmp(), longjmp(), jmp_buf */
     148                 : #include <sys/time.h> /* gettimeofday(), struct timeval */
     149                 : 
     150                 : extern char *optarg;
     151                 : 
     152                 : #include <node.h>
     153                 : #include <hashtable.h>
     154                 : #include <atom.h>
     155                 : #include <graph.h>
     156                 : #include <abbreviations.h>
     157                 : #include <spine_stack.h>
     158                 : #include <bracket_abstraction.h>
     159                 : 
     160                 : #ifdef YYBISON
     161                 : #define YYERROR_VERBOSE
     162                 : #endif
     163                 : 
     164                 : /* flags, binary on/off for various outputs */
     165                 : int debug_reduction  = 0;
     166                 : int elaborate_output = 0;
     167                 : int trace_reduction  = 0;
     168                 : int reduction_timer  = 0;
     169                 : int single_step      = 0;
     170                 : int memory_info      = 0;
     171                 : int count_reductions = 0;    /* produce a count of reductions */
     172                 : 
     173                 : int reduction_timeout = 0;   /* how long to let a graph reduction run, seconds */
     174                 : int max_reduction_count = 0; /* when non-zero, how many reductions to perform */
     175                 : 
     176                 : int prompting = 1;
     177                 : 
     178                 : /* Signal handling.  in_reduce_graph used to (a) handle
     179                 :  * contrl-C interruptions (b) reduction-run-time timeouts,
     180                 :  * (c) getting out of single-stepped graph reduction in reduce_graph()
     181                 :  */
     182                 : void sigint_handler(int signo);
     183                 : sigjmp_buf in_reduce_graph;
     184                 : int interpreter_interrupted = 0;
     185                 : int reduction_interrupted = 0;
     186                 : 
     187                 : void top_level_cleanup(int syntax_error_processing);
     188                 : 
     189                 : struct node *reduce_tree(struct node *root);
     190                 : struct node *execute_bracket_abstraction(
     191                 :         struct node *(*bafunc)(struct node *, struct node *),
     192                 :         struct node *abstracted_var,
     193                 :         struct node *root
     194                 : );
     195                 : float elapsed_time(struct timeval before, struct timeval after);
     196                 : void usage(char *progname);
     197                 : 
     198                 : struct filename_node {
     199                 :         const char *filename;
     200                 :         struct filename_node *next;
     201                 : };
     202                 : 
     203                 : /* from lex.l */
     204                 : extern void set_yyin_stdin(void); 
     205                 : extern void set_yyin(const char *filename); 
     206                 : extern void reset_yyin(void);
     207                 : extern void  push_and_open(const char *filename);
     208                 : 
     209                 : extern int yylex(void);
     210                 : int yyerror(char *s1);
     211                 : 
     212                 : /* Various "treat as combinator" flags.
     213                 :  * For example: S_as_combinator, when set (default) causes
     214                 :  * the lexer to treat "S" as an S-combinator.  When unset,
     215                 :  * the lexer treats "S" as any other variable. This can interact
     216                 :  * strangely with bracket abstraction, which assumes that its
     217                 :  * own use of "S" (again, as example) always constitutes a combinator.
     218                 :  */
     219                 : int S_as_combinator = 1;
     220                 : int K_as_combinator = 1;
     221                 : int I_as_combinator = 1;
     222                 : int B_as_combinator = 1;
     223                 : int C_as_combinator = 1;
     224                 : int W_as_combinator = 1;
     225                 : int T_as_combinator = 1;
     226                 : int M_as_combinator = 1;
     227                 : 
     228                 : 
     229                 : 
     230                 : /* Enabling traces.  */
     231                 : #ifndef YYDEBUG
     232                 : # define YYDEBUG 0
     233                 : #endif
     234                 : 
     235                 : /* Enabling verbose error messages.  */
     236                 : #ifdef YYERROR_VERBOSE
     237                 : # undef YYERROR_VERBOSE
     238                 : # define YYERROR_VERBOSE 1
     239                 : #else
     240                 : # define YYERROR_VERBOSE 0
     241                 : #endif
     242                 : 
     243                 : /* Enabling the token table.  */
     244                 : #ifndef YYTOKEN_TABLE
     245                 : # define YYTOKEN_TABLE 0
     246                 : #endif
     247                 : 
     248                 : #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
     249                 : typedef union YYSTYPE
     250                 : #line 111 "grammar.y"
     251                 : {
     252                 :         const char *identifier;
     253                 :         const char *string_constant;
     254                 :         int   numerical_constant;
     255                 :         struct node *node;
     256                 :         enum combinatorName cn;
     257                 :         struct node *(*bafunc)(struct node *, struct node *);
     258                 : }
     259                 : /* Line 187 of yacc.c.  */
     260                 : #line 261 "y.tab.c"
     261                 :         YYSTYPE;
     262                 : # define yystype YYSTYPE /* obsolescent; will be withdrawn */
     263                 : # define YYSTYPE_IS_DECLARED 1
     264                 : # define YYSTYPE_IS_TRIVIAL 1
     265                 : #endif
     266                 : 
     267                 : 
     268                 : 
     269                 : /* Copy the second part of user declarations.  */
     270                 : 
     271                 : 
     272                 : /* Line 216 of yacc.c.  */
     273                 : #line 274 "y.tab.c"
     274                 : 
     275                 : #ifdef short
     276                 : # undef short
     277                 : #endif
     278                 : 
     279                 : #ifdef YYTYPE_UINT8
     280                 : typedef YYTYPE_UINT8 yytype_uint8;
     281                 : #else
     282                 : typedef unsigned char yytype_uint8;
     283                 : #endif
     284                 : 
     285                 : #ifdef YYTYPE_INT8
     286                 : typedef YYTYPE_INT8 yytype_int8;
     287                 : #elif (defined __STDC__ || defined __C99__FUNC__ \
     288                 :      || defined __cplusplus || defined _MSC_VER)
     289                 : typedef signed char yytype_int8;
     290                 : #else
     291                 : typedef short int yytype_int8;
     292                 : #endif
     293                 : 
     294                 : #ifdef YYTYPE_UINT16
     295                 : typedef YYTYPE_UINT16 yytype_uint16;
     296                 : #else
     297                 : typedef unsigned short int yytype_uint16;
     298                 : #endif
     299                 : 
     300                 : #ifdef YYTYPE_INT16
     301                 : typedef YYTYPE_INT16 yytype_int16;
     302                 : #else
     303                 : typedef short int yytype_int16;
     304                 : #endif
     305                 : 
     306                 : #ifndef YYSIZE_T
     307                 : # ifdef __SIZE_TYPE__
     308                 : #  define YYSIZE_T __SIZE_TYPE__
     309                 : # elif defined size_t
     310                 : #  define YYSIZE_T size_t
     311                 : # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
     312                 :      || defined __cplusplus || defined _MSC_VER)
     313                 : #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
     314                 : #  define YYSIZE_T size_t
     315                 : # else
     316                 : #  define YYSIZE_T unsigned int
     317                 : # endif
     318                 : #endif
     319                 : 
     320                 : #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
     321                 : 
     322                 : #ifndef YY_
     323                 : # if YYENABLE_NLS
     324                 : #  if ENABLE_NLS
     325                 : #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
     326                 : #   define YY_(msgid) dgettext ("bison-runtime", msgid)
     327                 : #  endif
     328                 : # endif
     329                 : # ifndef YY_
     330                 : #  define YY_(msgid) msgid
     331                 : # endif
     332                 : #endif
     333                 : 
     334                 : /* Suppress unused-variable warnings by "using" E.  */
     335                 : #if ! defined lint || defined __GNUC__
     336                 : # define YYUSE(e) ((void) (e))
     337                 : #else
     338                 : # define YYUSE(e) /* empty */
     339                 : #endif
     340                 : 
     341                 : /* Identity function, used to suppress warnings about constant conditions.  */
     342                 : #ifndef lint
     343                 : # define YYID(n) (n)
     344                 : #else
     345                 : #if (defined __STDC__ || defined __C99__FUNC__ \
     346                 :      || defined __cplusplus || defined _MSC_VER)
     347                 : static int
     348                 : YYID (int i)
     349                 : #else
     350                 : static int
     351                 : YYID (i)
     352                 :     int i;
     353                 : #endif
     354                 : {
     355                 :   return i;
     356                 : }
     357                 : #endif
     358                 : 
     359                 : #if ! defined yyoverflow || YYERROR_VERBOSE
     360                 : 
     361                 : /* The parser invokes alloca or malloc; define the necessary symbols.  */
     362                 : 
     363                 : # ifdef YYSTACK_USE_ALLOCA
     364                 : #  if YYSTACK_USE_ALLOCA
     365                 : #   ifdef __GNUC__
     366                 : #    define YYSTACK_ALLOC __builtin_alloca
     367                 : #   elif defined __BUILTIN_VA_ARG_INCR
     368                 : #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
     369                 : #   elif defined _AIX
     370                 : #    define YYSTACK_ALLOC __alloca
     371                 : #   elif defined _MSC_VER
     372                 : #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
     373                 : #    define alloca _alloca
     374                 : #   else
     375                 : #    define YYSTACK_ALLOC alloca
     376                 : #    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
     377                 :      || defined __cplusplus || defined _MSC_VER)
     378                 : #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
     379                 : #     ifndef _STDLIB_H
     380                 : #      define _STDLIB_H 1
     381                 : #     endif
     382                 : #    endif
     383                 : #   endif
     384                 : #  endif
     385                 : # endif
     386                 : 
     387                 : # ifdef YYSTACK_ALLOC
     388                 :    /* Pacify GCC's `empty if-body' warning.  */
     389                 : #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
     390                 : #  ifndef YYSTACK_ALLOC_MAXIMUM
     391                 :     /* The OS might guarantee only one guard page at the bottom of the stack,
     392                 :        and a page size can be as small as 4096 bytes.  So we cannot safely
     393                 :        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
     394                 :        to allow for a few compiler-allocated temporary stack slots.  */
     395                 : #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
     396                 : #  endif
     397                 : # else
     398                 : #  define YYSTACK_ALLOC YYMALLOC
     399                 : #  define YYSTACK_FREE YYFREE
     400                 : #  ifndef YYSTACK_ALLOC_MAXIMUM
     401                 : #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
     402                 : #  endif
     403                 : #  if (defined __cplusplus && ! defined _STDLIB_H \
     404                 :        && ! ((defined YYMALLOC || defined malloc) \
     405                 :              && (defined YYFREE || defined free)))
     406                 : #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
     407                 : #   ifndef _STDLIB_H
     408                 : #    define _STDLIB_H 1
     409                 : #   endif
     410                 : #  endif
     411                 : #  ifndef YYMALLOC
     412                 : #   define YYMALLOC malloc
     413                 : #   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
     414                 :      || defined __cplusplus || defined _MSC_VER)
     415                 : void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
     416                 : #   endif
     417                 : #  endif
     418                 : #  ifndef YYFREE
     419                 : #   define YYFREE free
     420                 : #   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
     421                 :      || defined __cplusplus || defined _MSC_VER)
     422                 : void free (void *); /* INFRINGES ON USER NAME SPACE */
     423                 : #   endif
     424                 : #  endif
     425                 : # endif
     426                 : #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
     427                 : 
     428                 : 
     429                 : #if (! defined yyoverflow \
     430                 :      && (! defined __cplusplus \
     431                 :          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
     432                 : 
     433                 : /* A type that is properly aligned for any stack member.  */
     434                 : union yyalloc
     435                 : {
     436                 :   yytype_int16 yyss;
     437                 :   YYSTYPE yyvs;
     438                 :   };
     439                 : 
     440                 : /* The size of the maximum gap between one aligned stack and the next.  */
     441                 : # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
     442                 : 
     443                 : /* The size of an array large to enough to hold all stacks, each with
     444                 :    N elements.  */
     445                 : # define YYSTACK_BYTES(N) \
     446                 :      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
     447                 :       + YYSTACK_GAP_MAXIMUM)
     448                 : 
     449                 : /* Copy COUNT objects from FROM to TO.  The source and destination do
     450                 :    not overlap.  */
     451                 : # ifndef YYCOPY
     452                 : #  if defined __GNUC__ && 1 < __GNUC__
     453                 : #   define YYCOPY(To, From, Count) \
     454                 :       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
     455                 : #  else
     456                 : #   define YYCOPY(To, From, Count)              \
     457                 :       do                                        \
     458                 :         {                                       \
     459                 :           YYSIZE_T yyi;                         \
     460                 :           for (yyi = 0; yyi < (Count); yyi++)        \
     461                 :             (To)[yyi] = (From)[yyi];            \
     462                 :         }                                       \
     463                 :       while (YYID (0))
     464                 : #  endif
     465                 : # endif
     466                 : 
     467                 : /* Relocate STACK from its old location to the new one.  The
     468                 :    local variables YYSIZE and YYSTACKSIZE give the old and new number of
     469                 :    elements in the stack, and YYPTR gives the new location of the
     470                 :    stack.  Advance YYPTR to a properly aligned location for the next
     471                 :    stack.  */
     472                 : # define YYSTACK_RELOCATE(Stack)                                        \
     473                 :     do                                                                  \
     474                 :       {                                                                 \
     475                 :         YYSIZE_T yynewbytes;                                            \
     476                 :         YYCOPY (&yyptr->Stack, Stack, yysize);                           \
     477                 :         Stack = &yyptr->Stack;                                           \
     478                 :         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
     479                 :         yyptr += yynewbytes / sizeof (*yyptr);                          \
     480                 :       }                                                                 \
     481                 :     while (YYID (0))
     482                 : 
     483                 : #endif
     484                 : 
     485                 : /* YYFINAL -- State number of the termination state.  */
     486                 : #define YYFINAL  39
     487                 : /* YYLAST -- Last index in YYTABLE.  */
     488                 : #define YYLAST   68
     489                 : 
     490                 : /* YYNTOKENS -- Number of terminals.  */
     491                 : #define YYNTOKENS  24
     492                 : /* YYNNTS -- Number of nonterminals.  */
     493                 : #define YYNNTS  10
     494                 : /* YYNRULES -- Number of rules.  */
     495                 : #define YYNRULES  30
     496                 : /* YYNRULES -- Number of states.  */
     497                 : #define YYNSTATES  55
     498                 : 
     499                 : /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
     500                 : #define YYUNDEFTOK  2
     501                 : #define YYMAXUTOK   278
     502                 : 
     503                 : #define YYTRANSLATE(YYX)                                                \
     504                 :   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
     505                 : 
     506                 : /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
     507                 : static const yytype_uint8 yytranslate[] =
     508                 : {
     509                 :        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     510                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     511                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     512                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     513                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     514                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     515                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     516                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     517                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     518                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     519                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     520                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     521                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     522                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     523                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     524                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     525                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     526                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     527                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     528                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     529                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     530                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     531                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     532                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     533                 :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     534                 :        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
     535                 :        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
     536                 :       15,    16,    17,    18,    19,    20,    21,    22,    23
     537                 : };
     538                 : 
     539                 : #if YYDEBUG
     540                 : /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
     541                 :    YYRHS.  */
     542                 : static const yytype_uint8 yyprhs[] =
     543                 : {
     544                 :        0,     0,     3,     5,     8,    10,    13,    18,    20,    22,
     545                 :       25,    28,    31,    34,    37,    41,    45,    49,    53,    55,
     546                 :       57,    60,    64,    66,    67,    70,    73,    77,    79,    81,
     547                 :       85
     548                 : };
     549                 : 
     550                 : /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
     551                 : static const yytype_int8 yyrhs[] =
     552                 : {
     553                 :       25,     0,    -1,    26,    -1,    25,    26,    -1,     1,    -1,
     554                 :       28,     3,    -1,    15,     8,    28,     3,    -1,    27,    -1,
     555                 :        3,    -1,    16,     3,    -1,    18,     3,    -1,    21,     3,
     556                 :       -1,    19,     3,    -1,    20,     3,    -1,    17,    10,     3,
     557                 :       -1,    12,    13,     3,    -1,    22,    13,     3,    -1,    23,
     558                 :       14,     3,    -1,    30,    -1,    32,    -1,    11,    28,    -1,
     559                 :       31,    29,    28,    -1,    14,    -1,    -1,    32,    32,    -1,
     560                 :       30,    32,    -1,     6,     8,     7,    -1,    33,    -1,     8,
     561                 :       -1,     4,    28,     5,    -1,     9,    -1
     562                 : };
     563                 : 
     564                 : /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
     565                 : static const yytype_uint8 yyrline[] =
     566                 : {
     567                 :        0,   139,   139,   140,   141,   146,   154,   160,   161,   165,
     568                 :      166,   167,   168,   169,   170,   171,   172,   173,   177,   178,
     569                 :      179,   188,   199,   200,   204,   205,   209,   214,   215,   221,
     570                 :      225
     571                 : };
     572                 : #endif
     573                 : 
     574                 : #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
     575                 : /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
     576                 :    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
     577                 : static const char *const yytname[] =
     578                 : {
     579                 :   "$end", "error", "$undefined", "TK_EOL", "TK_LPAREN", "TK_RPAREN",
     580                 :   "TK_LBRACK", "TK_RBRACK", "TK_IDENTIFIER", "TK_PRIMITIVE",
     581                 :   "STRING_LITERAL", "TK_REDUCE", "TK_TIMEOUT", "NUMERICAL_CONSTANT",
     582                 :   "TK_ALGORITHM_NAME", "TK_DEF", "TK_TIME", "TK_LOAD", "TK_ELABORATE",
     583                 :   "TK_TRACE", "TK_SINGLE_STEP", "TK_DEBUG", "TK_MAX_COUNT",
     584                 :   "TK_SET_BRACKET_ABSTRACTION", "$accept", "program", "stmnt",
     585                 :   "interpreter_command", "expression", "abstraction_algorithm",
     586                 :   "application", "bracket_abstraction", "term", "constant", 0
     587                 : };
     588                 : #endif
     589                 : 
     590                 : # ifdef YYPRINT
     591                 : /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
     592                 :    token YYLEX-NUM.  */
     593                 : static const yytype_uint16 yytoknum[] =
     594                 : {
     595                 :        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
     596                 :      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
     597                 :      275,   276,   277,   278
     598                 : };
     599                 : # endif
     600                 : 
     601                 : /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
     602                 : static const yytype_uint8 yyr1[] =
     603                 : {
     604                 :        0,    24,    25,    25,    25,    26,    26,    26,    26,    27,
     605                 :       27,    27,    27,    27,    27,    27,    27,    27,    28,    28,
     606                 :       28,    28,    29,    29,    30,    30,    31,    32,    32,    32,
     607                 :       33
     608                 : };
     609                 : 
     610                 : /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
     611                 : static const yytype_uint8 yyr2[] =
     612                 : {
     613                 :        0,     2,     1,     2,     1,     2,     4,     1,     1,     2,
     614                 :        2,     2,     2,     2,     3,     3,     3,     3,     1,     1,
     615                 :        2,     3,     1,     0,     2,     2,     3,     1,     1,     3,
     616                 :        1
     617                 : };
     618                 : 
     619                 : /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
     620                 :    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
     621                 :    means the default is an error.  */
     622                 : static const yytype_uint8 yydefact[] =
     623                 : {
     624                 :        0,     4,     8,     0,     0,    28,    30,     0,     0,     0,
     625                 :        0,     0,     0,     0,     0,     0,     0,     0,     0,     2,
     626                 :        7,     0,    18,    23,    19,    27,     0,     0,    20,     0,
     627                 :        0,     9,     0,    10,    12,    13,    11,     0,     0,     1,
     628                 :        3,     5,    25,    22,     0,    24,    29,    26,    15,     0,
     629                 :       14,    16,    17,    21,     6
     630                 : };
     631                 : 
     632                 : /* YYDEFGOTO[NTERM-NUM].  */
     633                 : static const yytype_int8 yydefgoto[] =
     634                 : {
     635                 :       -1,    18,    19,    20,    21,    44,    22,    23,    24,    25
     636                 : };
     637                 : 
     638                 : /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
     639                 :    STATE-NUM.  */
     640                 : #define YYPACT_NINF -22
     641                 : static const yytype_int8 yypact[] =
     642                 : {
     643                 :       27,   -22,   -22,    47,    -1,   -22,   -22,    47,    -4,     4,
     644                 :       12,     6,    23,    26,    29,    31,    24,    38,     2,   -22,
     645                 :      -22,    37,    53,    40,    53,   -22,    54,    56,   -22,    57,
     646                 :       47,   -22,    61,   -22,   -22,   -22,   -22,    62,    63,   -22,
     647                 :      -22,   -22,   -22,   -22,    47,   -22,   -22,   -22,   -22,    64,
     648                 :      -22,   -22,   -22,   -22,   -22
     649                 : };
     650                 : 
     651                 : /* YYPGOTO[NTERM-NUM].  */
     652                 : static const yytype_int8 yypgoto[] =
     653                 : {
     654                 :      -22,   -22,    50,   -22,    -3,   -22,   -22,   -22,   -21,   -22
     655                 : };
     656                 : 
     657                 : /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
     658                 :    positive, shift that token.  If negative, reduce the rule which
     659                 :    number is the opposite.  If zero, do what YYDEFACT says.
     660                 :    If YYTABLE_NINF, syntax error.  */
     661                 : #define YYTABLE_NINF -1
     662                 : static const yytype_uint8 yytable[] =
     663                 : {
     664                 :       26,    42,    39,    45,    28,     2,     3,    27,     4,    29,
     665                 :        5,     6,    30,     7,     8,    31,    32,     9,    10,    11,
     666                 :       12,    13,    14,    15,    16,    17,    33,    49,     1,    34,
     667                 :        2,     3,    35,     4,    36,     5,     6,    37,     7,     8,
     668                 :       41,    53,     9,    10,    11,    12,    13,    14,    15,    16,
     669                 :       17,     3,    38,     4,    43,     5,     6,     3,     7,    46,
     670                 :       48,     5,     6,    47,    50,    51,    52,    54,    40
     671                 : };
     672                 : 
     673                 : static const yytype_uint8 yycheck[] =
     674                 : {
     675                 :        3,    22,     0,    24,     7,     3,     4,     8,     6,    13,
     676                 :        8,     9,     8,    11,    12,     3,    10,    15,    16,    17,
     677                 :       18,    19,    20,    21,    22,    23,     3,    30,     1,     3,
     678                 :        3,     4,     3,     6,     3,     8,     9,    13,    11,    12,
     679                 :        3,    44,    15,    16,    17,    18,    19,    20,    21,    22,
     680                 :       23,     4,    14,     6,    14,     8,     9,     4,    11,     5,
     681                 :        3,     8,     9,     7,     3,     3,     3,     3,    18
     682                 : };
     683                 : 
     684                 : /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
     685                 :    symbol of state STATE-NUM.  */
     686                 : static const yytype_uint8 yystos[] =
     687                 : {
     688                 :        0,     1,     3,     4,     6,     8,     9,    11,    12,    15,
     689                 :       16,    17,    18,    19,    20,    21,    22,    23,    25,    26,
     690                 :       27,    28,    30,    31,    32,    33,    28,     8,    28,    13,
     691                 :        8,     3,    10,     3,     3,     3,     3,    13,    14,     0,
     692                 :       26,     3,    32,    14,    29,    32,     5,     7,     3,    28,
     693                 :        3,     3,     3,    28,     3
     694                 : };
     695                 : 
     696                 : #define yyerrok         (yyerrstatus = 0)
     697                 : #define yyclearin       (yychar = YYEMPTY)
     698                 : #define YYEMPTY         (-2)
     699                 : #define YYEOF           0
     700                 : 
     701                 : #define YYACCEPT        goto yyacceptlab
     702                 : #define YYABORT         goto yyabortlab
     703                 : #define YYERROR         goto yyerrorlab
     704                 : 
     705                 : 
     706                 : /* Like YYERROR except do call yyerror.  This remains here temporarily
     707                 :    to ease the transition to the new meaning of YYERROR, for GCC.
     708                 :    Once GCC version 2 has supplanted version 1, this can go.  */
     709                 : 
     710                 : #define YYFAIL          goto yyerrlab
     711                 : 
     712                 : #define YYRECOVERING()  (!!yyerrstatus)
     713                 : 
     714                 : #define YYBACKUP(Token, Value)                                  \
     715                 : do                                                              \
     716                 :   if (yychar == YYEMPTY && yylen == 1)                          \
     717                 :     {                                                           \
     718                 :       yychar = (Token);                                         \
     719                 :       yylval = (Value);                                         \
     720                 :       yytoken = YYTRANSLATE (yychar);                           \
     721                 :       YYPOPSTACK (1);                                           \
     722                 :       goto yybackup;                                            \
     723                 :     }                                                           \
     724                 :   else                                                          \
     725                 :     {                                                           \
     726                 :       yyerror (YY_("syntax error: cannot back up")); \
     727                 :       YYERROR;                                                  \
     728                 :     }                                                           \
     729                 : while (YYID (0))
     730                 : 
     731                 : 
     732                 : #define YYTERROR        1
     733                 : #define YYERRCODE       256
     734                 : 
     735                 : 
     736                 : /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
     737                 :    If N is 0, then set CURRENT to the empty location which ends
     738                 :    the previous symbol: RHS[0] (always defined).  */
     739                 : 
     740                 : #define YYRHSLOC(Rhs, K) ((Rhs)[K])
     741                 : #ifndef YYLLOC_DEFAULT
     742                 : # define YYLLOC_DEFAULT(Current, Rhs, N)                                \
     743                 :     do                                                                  \
     744                 :       if (YYID (N))                                                    \
     745                 :         {                                                               \
     746                 :           (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
     747                 :           (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
     748                 :           (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
     749                 :           (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
     750                 :         }                                                               \
     751                 :       else                                                              \
     752                 :         {                                                               \
     753                 :           (Current).first_line   = (Current).last_line   =              \
     754                 :             YYRHSLOC (Rhs, 0).last_line;                                \
     755                 :           (Current).first_column = (Current).last_column =              \
     756                 :             YYRHSLOC (Rhs, 0).last_column;                              \
     757                 :         }                                                               \
     758                 :     while (YYID (0))
     759                 : #endif
     760                 : 
     761                 : 
     762                 : /* YY_LOCATION_PRINT -- Print the location on the stream.
     763                 :    This macro was not mandated originally: define only if we know
     764                 :    we won't break user code: when these are the locations we know.  */
     765                 : 
     766                 : #ifndef YY_LOCATION_PRINT
     767                 : # if YYLTYPE_IS_TRIVIAL
     768                 : #  define YY_LOCATION_PRINT(File, Loc)                  \
     769                 :      fprintf (File, "%d.%d-%d.%d",                    \
     770                 :               (Loc).first_line, (Loc).first_column,     \
     771                 :               (Loc).last_line,  (Loc).last_column)
     772                 : # else
     773                 : #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
     774                 : # endif
     775                 : #endif
     776                 : 
     777                 : 
     778                 : /* YYLEX -- calling `yylex' with the right arguments.  */
     779                 : 
     780                 : #ifdef YYLEX_PARAM
     781                 : # define YYLEX yylex (YYLEX_PARAM)
     782                 : #else
     783                 : # define YYLEX yylex ()
     784                 : #endif
     785                 : 
     786                 : /* Enable debugging if requested.  */
     787                 : #if YYDEBUG
     788                 : 
     789                 : # ifndef YYFPRINTF
     790                 : #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
     791                 : #  define YYFPRINTF fprintf
     792                 : # endif
     793                 : 
     794                 : # define YYDPRINTF(Args)                        \
     795                 : do {                                            \
     796                 :   if (yydebug)                                  \
     797                 :     YYFPRINTF Args;                             \
     798                 : } while (YYID (0))
     799                 : 
     800                 : # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
     801                 : do {                                                                      \
     802                 :   if (yydebug)                                                            \
     803                 :     {                                                                     \
     804                 :       YYFPRINTF (stderr, "%s ", Title);                                         \
     805                 :       yy_symbol_print (stderr,                                            \
     806                 :                   Type, Value); \
     807                 :       YYFPRINTF (stderr, "\n");                                                 \
     808                 :     }                                                                     \
     809                 : } while (YYID (0))
     810                 : 
     811                 : 
     812                 : /*--------------------------------.
     813                 : | Print this symbol on YYOUTPUT.  |
     814                 : `--------------------------------*/
     815                 : 
     816                 : /*ARGSUSED*/
     817                 : #if (defined __STDC__ || defined __C99__FUNC__ \
     818                 :      || defined __cplusplus || defined _MSC_VER)
     819                 : static void
     820                 : yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
     821                 : #else
     822                 : static void
     823                 : yy_symbol_value_print (yyoutput, yytype, yyvaluep)
     824                 :     FILE *yyoutput;
     825                 :     int yytype;
     826                 :     YYSTYPE const * const yyvaluep;
     827                 : #endif
     828                 : {
     829                 :   if (!yyvaluep)
     830                 :     return;
     831                 : # ifdef YYPRINT
     832                 :   if (yytype < YYNTOKENS)
     833                 :     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
     834                 : # else
     835                 :   YYUSE (yyoutput);
     836                 : # endif
     837                 :   switch (yytype)
     838                 :     {
     839                 :       default:
     840                 :         break;
     841                 :     }
     842                 : }
     843                 : 
     844                 : 
     845                 : /*--------------------------------.
     846                 : | Print this symbol on YYOUTPUT.  |
     847                 : `--------------------------------*/
     848                 : 
     849                 : #if (defined __STDC__ || defined __C99__FUNC__ \
     850                 :      || defined __cplusplus || defined _MSC_VER)
     851                 : static void
     852                 : yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
     853                 : #else
     854                 : static void
     855                 : yy_symbol_print (yyoutput, yytype, yyvaluep)
     856                 :     FILE *yyoutput;
     857                 :     int yytype;
     858                 :     YYSTYPE const * const yyvaluep;
     859                 : #endif
     860                 : {
     861                 :   if (yytype < YYNTOKENS)
     862                 :     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
     863                 :   else
     864                 :     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
     865                 : 
     866                 :   yy_symbol_value_print (yyoutput, yytype, yyvaluep);
     867                 :   YYFPRINTF (yyoutput, ")");
     868                 : }
     869                 : 
     870                 : /*------------------------------------------------------------------.
     871                 : | yy_stack_print -- Print the state stack from its BOTTOM up to its |
     872                 : | TOP (included).                                                   |
     873                 : `------------------------------------------------------------------*/
     874                 : 
     875                 : #if (defined __STDC__ || defined __C99__FUNC__ \
     876                 :      || defined __cplusplus || defined _MSC_VER)
     877                 : static void
     878                 : yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
     879                 : #else
     880                 : static void
     881                 : yy_stack_print (bottom, top)
     882                 :     yytype_int16 *bottom;
     883                 :     yytype_int16 *top;
     884                 : #endif
     885                 : {
     886                 :   YYFPRINTF (stderr, "Stack now");
     887                 :   for (; bottom <= top; ++bottom)
     888                 :     YYFPRINTF (stderr, " %d", *bottom);
     889                 :   YYFPRINTF (stderr, "\n");
     890                 : }
     891                 : 
     892                 : # define YY_STACK_PRINT(Bottom, Top)                            \
     893                 : do {                                                            \
     894                 :   if (yydebug)                                                  \
     895                 :     yy_stack_print ((Bottom), (Top));                           \
     896                 : } while (YYID (0))
     897                 : 
     898                 : 
     899                 : /*------------------------------------------------.
     900                 : | Report that the YYRULE is going to be reduced.  |
     901                 : `------------------------------------------------*/
     902                 : 
     903                 : #if (defined __STDC__ || defined __C99__FUNC__ \
     904                 :      || defined __cplusplus || defined _MSC_VER)
     905                 : static void
     906                 : yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
     907                 : #else
     908                 : static void
     909                 : yy_reduce_print (yyvsp, yyrule)
     910                 :     YYSTYPE *yyvsp;
     911                 :     int yyrule;
     912                 : #endif
     913                 : {
     914                 :   int yynrhs = yyr2[yyrule];
     915                 :   int yyi;
     916                 :   unsigned long int yylno = yyrline[yyrule];
     917                 :   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
     918                 :              yyrule - 1, yylno);
     919                 :   /* The symbols being reduced.  */
     920                 :   for (yyi = 0; yyi < yynrhs; yyi++)
     921                 :     {
     922                 :       fprintf (stderr, "   $%d = ", yyi + 1);
     923                 :       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
     924                 :                        &(yyvsp[(yyi + 1) - (yynrhs)])
     925                 :                                        );
     926                 :       fprintf (stderr, "\n");
     927                 :     }
     928                 : }
     929                 : 
     930                 : # define YY_REDUCE_PRINT(Rule)          \
     931                 : do {                                    \
     932                 :   if (yydebug)                          \
     933                 :     yy_reduce_print (yyvsp, Rule); \
     934                 : } while (YYID (0))
     935                 : 
     936                 : /* Nonzero means print parse trace.  It is left uninitialized so that
     937                 :    multiple parsers can coexist.  */
     938                 : int yydebug;
     939                 : #else /* !YYDEBUG */
     940                 : # define YYDPRINTF(Args)
     941                 : # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
     942                 : # define YY_STACK_PRINT(Bottom, Top)
     943                 : # define YY_REDUCE_PRINT(Rule)
     944                 : #endif /* !YYDEBUG */
     945                 : 
     946                 : 
     947                 : /* YYINITDEPTH -- initial size of the parser's stacks.  */
     948                 : #ifndef YYINITDEPTH
     949                 : # define YYINITDEPTH 200
     950                 : #endif
     951                 : 
     952                 : /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
     953                 :    if the built-in stack extension method is used).
     954                 : 
     955                 :    Do not make this value too large; the results are undefined if
     956                 :    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
     957                 :    evaluated with infinite-precision integer arithmetic.  */
     958                 : 
     959                 : #ifndef YYMAXDEPTH
     960                 : # define YYMAXDEPTH 10000
     961                 : #endif
     962                 : 
     963                 : 
     964                 : 
     965                 : #if YYERROR_VERBOSE
     966                 : 
     967                 : # ifndef yystrlen
     968                 : #  if defined __GLIBC__ && defined _STRING_H
     969                 : #   define yystrlen strlen
     970                 : #  else
     971                 : /* Return the length of YYSTR.  */
     972                 : #if (defined __STDC__ || defined __C99__FUNC__ \
     973                 :      || defined __cplusplus || defined _MSC_VER)
     974                 : static YYSIZE_T
     975                 : yystrlen (const char *yystr)
     976                 : #else
     977                 : static YYSIZE_T
     978                 : yystrlen (yystr)
     979                 :     const char *yystr;
     980                 : #endif
     981                 : {
     982                 :   YYSIZE_T yylen;
     983                 :   for (yylen = 0; yystr[yylen]; yylen++)
     984                 :     continue;
     985                 :   return yylen;
     986                 : }
     987                 : #  endif
     988                 : # endif
     989                 : 
     990                 : # ifndef yystpcpy
     991                 : #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
     992                 : #   define yystpcpy stpcpy
     993                 : #  else
     994                 : /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
     995                 :    YYDEST.  */
     996                 : #if (defined __STDC__ || defined __C99__FUNC__ \
     997                 :      || defined __cplusplus || defined _MSC_VER)
     998                 : static char *
     999                 : yystpcpy (char *yydest, const char *yysrc)
    1000                 : #else
    1001                 : static char *
    1002                 : yystpcpy (yydest, yysrc)
    1003                 :     char *yydest;
    1004                 :     const char *yysrc;
    1005                 : #endif
    1006              51 : {
    1007              51 :   char *yyd = yydest;
    1008              51 :   const char *yys = yysrc;
    1009                 : 
    1010             733 :   while ((*yyd++ = *yys++) != '\0')
    1011                 :     continue;
    1012                 : 
    1013              51 :   return yyd - 1;
    1014                 : }
    1015                 : #  endif
    1016                 : # endif
    1017                 : 
    1018                 : # ifndef yytnamerr
    1019                 : /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
    1020                 :    quotes and backslashes, so that it's suitable for yyerror.  The
    1021                 :    heuristic is that double-quoting is unnecessary unless the string
    1022                 :    contains an apostrophe, a comma, or backslash (other than
    1023                 :    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
    1024                 :    null, do not copy; instead, return the length of what the result
    1025                 :    would have been.  */
    1026                 : static YYSIZE_T
    1027                 : yytnamerr (char *yyres, const char *yystr)
    1028              51 : {
    1029              51 :   if (*yystr == '"')
    1030                 :     {
    1031               0 :       YYSIZE_T yyn = 0;
    1032               0 :       char const *yyp = yystr;
    1033                 : 
    1034                 :       for (;;)
    1035               0 :         switch (*++yyp)
    1036                 :           {
    1037                 :           case '\'':
    1038                 :           case ',':
    1039               0 :             goto do_not_strip_quotes;
    1040                 : 
    1041                 :           case '\\':
    1042               0 :             if (*++yyp != '\\')
    1043               0 :               goto do_not_strip_quotes;
    1044                 :             /* Fall through.  */
    1045                 :           default:
    1046               0 :             if (yyres)
    1047               0 :               yyres[yyn] = *yyp;
    1048               0 :             yyn++;
    1049                 :             break;
    1050                 : 
    1051                 :           case '"':
    1052               0 :             if (yyres)
    1053               0 :               yyres[yyn] = '\0';
    1054               0 :             return yyn;
    1055               0 :           }
    1056              51 :     do_not_strip_quotes: ;
    1057                 :     }
    1058                 : 
    1059              51 :   if (! yyres)
    1060              42 :     return yystrlen (yystr);
    1061                 : 
    1062               9 :   return yystpcpy (yyres, yystr) - yyres;
    1063                 : }
    1064                 : # endif
    1065                 : 
    1066                 : /* Copy into YYRESULT an error message about the unexpected token
    1067                 :    YYCHAR while in state YYSTATE.  Return the number of bytes copied,
    1068                 :    including the terminating null byte.  If YYRESULT is null, do not
    1069                 :    copy anything; just return the number of bytes that would be
    1070                 :    copied.  As a special case, return 0 if an ordinary "syntax error"
    1071                 :    message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
    1072                 :    size calculation.  */
    1073                 : static YYSIZE_T
    1074                 : yysyntax_error (char *yyresult, int yystate, int yychar)
    1075              12 : {
    1076              12 :   int yyn = yypact[yystate];
    1077                 : 
    1078              12 :   if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
    1079               0 :     return 0;
    1080                 :   else
    1081                 :     {
    1082              12 :       int yytype = YYTRANSLATE (yychar);
    1083              12 :       YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
    1084              12 :       YYSIZE_T yysize = yysize0;
    1085                 :       YYSIZE_T yysize1;
    1086              12 :       int yysize_overflow = 0;
    1087                 :       enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
    1088                 :       char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
    1089                 :       int yyx;
    1090                 : 
    1091                 : # if 0
    1092                 :       /* This is so xgettext sees the translatable formats that are
    1093                 :          constructed on the fly.  */
    1094                 :       YY_("syntax error, unexpected %s");
    1095                 :       YY_("syntax error, unexpected %s, expecting %s");
    1096                 :       YY_("syntax error, unexpected %s, expecting %s or %s");
    1097                 :       YY_("syntax error, unexpected %s, expecting %s or %s or %s");
    1098                 :       YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
    1099                 : # endif
    1100                 :       char *yyfmt;
    1101                 :       char const *yyf;
    1102                 :       static char const yyunexpected[] = "syntax error, unexpected %s";
    1103                 :       static char const yyexpecting[] = ", expecting %s";
    1104                 :       static char const yyor[] = " or %s";
    1105                 :       char yyformat[sizeof yyunexpected
    1106                 :                     + sizeof yyexpecting - 1
    1107                 :                     + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
    1108                 :                        * (sizeof yyor - 1))];
    1109              12 :       char const *yyprefix = yyexpecting;
    1110                 : 
    1111                 :       /* Start YYX at -YYN if negative to avoid negative indexes in
    1112                 :          YYCHECK.  */
    1113              12 :       int yyxbegin = yyn < 0 ? -yyn : 0;
    1114                 : 
    1115                 :       /* Stay within bounds of both yycheck and yytname.  */
    1116              12 :       int yychecklim = YYLAST - yyn + 1;
    1117              12 :       int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
    1118              12 :       int yycount = 1;
    1119                 : 
    1120              12 :       yyarg[0] = yytname[yytype];
    1121              12 :       yyfmt = yystpcpy (yyformat, yyunexpected);
    1122                 : 
    1123             214 :       for (yyx = yyxbegin; yyx < yyxend; ++yyx)
    1124             208 :         if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
    1125                 :           {
    1126              36 :             if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
    1127                 :               {
    1128               6 :                 yycount = 1;
    1129               6 :                 yysize = yysize0;
    1130               6 :                 yyformat[sizeof yyunexpected - 1] = '\0';
    1131               6 :                 break;
    1132                 :               }
    1133              30 :             yyarg[yycount++] = yytname[yyx];
    1134              30 :             yysize1 = yysize + yytnamerr (0, yytname[yyx]);
    1135              30 :             yysize_overflow |= (yysize1 < yysize);
    1136              30 :             yysize = yysize1;
    1137              30 :             yyfmt = yystpcpy (yyfmt, yyprefix);
    1138              30 :             yyprefix = yyor;
    1139                 :           }
    1140                 : 
    1141              12 :       yyf = YY_(yyformat);
    1142              12 :       yysize1 = yysize + yystrlen (yyf);
    1143              12 :       yysize_overflow |= (yysize1 < yysize);
    1144              12 :       yysize = yysize1;
    1145                 : 
    1146              12 :       if (yysize_overflow)
    1147               0 :         return YYSIZE_MAXIMUM;
    1148                 : 
    1149              12 :       if (yyresult)
    1150                 :         {
    1151                 :           /* Avoid sprintf, as that infringes on the user's name space.
    1152                 :              Don't have undefined behavior even if the translation
    1153                 :              produced a string with the wrong number of "%s"s.  */
    1154               6 :           char *yyp = yyresult;
    1155               6 :           int yyi = 0;
    1156             207 :           while ((*yyp = *yyf) != '\0')
    1157                 :             {
    1158             204 :               if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
    1159                 :                 {
    1160               9 :                   yyp += yytnamerr (yyp, yyarg[yyi++]);
    1161               9 :                   yyf += 2;
    1162                 :                 }
    1163                 :               else
    1164                 :                 {
    1165             186 :                   yyp++;
    1166             186 :                   yyf++;
    1167                 :                 }
    1168                 :             }
    1169                 :         }
    1170              12 :       return yysize;
    1171                 :     }
    1172                 : }
    1173                 : #endif /* YYERROR_VERBOSE */
    1174                 : 
    1175                 : 
    1176                 : /*-----------------------------------------------.
    1177                 : | Release the memory associated to this symbol.  |
    1178                 : `-----------------------------------------------*/
    1179                 : 
    1180                 : /*ARGSUSED*/
    1181                 : #if (defined __STDC__ || defined __C99__FUNC__ \
    1182                 :      || defined __cplusplus || defined _MSC_VER)
    1183                 : static void
    1184                 : yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
    1185                 : #else
    1186                 : static void
    1187                 : yydestruct (yymsg, yytype, yyvaluep)
    1188                 :     const char *yymsg;
    1189                 :     int yytype;
    1190                 :     YYSTYPE *yyvaluep;
    1191                 : #endif
    1192              91 : {
    1193                 :   YYUSE (yyvaluep);
    1194                 : 
    1195              91 :   if (!yymsg)
    1196               0 :     yymsg = "Deleting";
    1197                 :   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
    1198                 : 
    1199                 :   switch (yytype)
    1200                 :     {
    1201                 : 
    1202                 :       default:
    1203                 :         break;
    1204                 :     }
    1205              91 : }
    1206                 : 
    1207                 : 
    1208                 : /* Prevent warnings from -Wmissing-prototypes.  */
    1209                 : 
    1210                 : #ifdef YYPARSE_PARAM
    1211                 : #if defined __STDC__ || defined __cplusplus
    1212                 : int yyparse (void *YYPARSE_PARAM);
    1213                 : #else
    1214                 : int yyparse ();
    1215                 : #endif
    1216                 : #else /* ! YYPARSE_PARAM */
    1217                 : #if defined __STDC__ || defined __cplusplus
    1218                 : int yyparse (void);
    1219                 : #else
    1220                 : int yyparse ();
    1221                 : #endif
    1222                 : #endif /* ! YYPARSE_PARAM */
    1223                 : 
    1224                 : 
    1225                 : 
    1226                 : /* The look-ahead symbol.  */
    1227                 : int yychar;
    1228                 : 
    1229                 : /* The semantic value of the look-ahead symbol.  */
    1230                 : YYSTYPE yylval;
    1231                 : 
    1232                 : /* Number of syntax errors so far.  */
    1233                 : int yynerrs;
    1234                 : 
    1235                 : 
    1236                 : 
    1237                 : /*----------.
    1238                 : | yyparse.  |
    1239                 : `----------*/
    1240                 : 
    1241                 : #ifdef YYPARSE_PARAM
    1242                 : #if (defined __STDC__ || defined __C99__FUNC__ \
    1243                 :      || defined __cplusplus || defined _MSC_VER)
    1244                 : int
    1245                 : yyparse (void *YYPARSE_PARAM)
    1246                 : #else
    1247                 : int
    1248                 : yyparse (YYPARSE_PARAM)
    1249                 :     void *YYPARSE_PARAM;
    1250                 : #endif
    1251                 : #else /* ! YYPARSE_PARAM */
    1252                 : #if (defined __STDC__ || defined __C99__FUNC__ \
    1253                 :      || defined __cplusplus || defined _MSC_VER)
    1254                 : int
    1255                 : yyparse (void)
    1256                 : #else
    1257                 : int
    1258                 : yyparse ()
    1259                 : 
    1260                 : #endif
    1261                 : #endif
    1262              72 : {
    1263                 :   
    1264                 :   int yystate;
    1265                 :   int yyn;
    1266                 :   int yyresult;
    1267                 :   /* Number of tokens to shift before error messages enabled.  */
    1268                 :   int yyerrstatus;
    1269                 :   /* Look-ahead token as an internal (translated) token number.  */
    1270              72 :   int yytoken = 0;
    1271                 : #if YYERROR_VERBOSE
    1272                 :   /* Buffer for error messages, and its allocated size.  */
    1273                 :   char yymsgbuf[128];
    1274              72 :   char *yymsg = yymsgbuf;
    1275              72 :   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
    1276                 : #endif
    1277                 : 
    1278                 :   /* Three stacks and their tools:
    1279                 :      `yyss': related to states,
    1280                 :      `yyvs': related to semantic values,
    1281                 :      `yyls': related to locations.
    1282                 : 
    1283                 :      Refer to the stacks thru separate pointers, to allow yyoverflow
    1284                 :      to reallocate them elsewhere.  */
    1285                 : 
    1286                 :   /* The state stack.  */
    1287                 :   yytype_int16 yyssa[YYINITDEPTH];
    1288              72 :   yytype_int16 *yyss = yyssa;
    1289                 :   yytype_int16 *yyssp;
    1290                 : 
    1291                 :   /* The semantic value stack.  */
    1292                 :   YYSTYPE yyvsa[YYINITDEPTH];
    1293              72 :   YYSTYPE *yyvs = yyvsa;
    1294                 :   YYSTYPE *yyvsp;
    1295                 : 
    1296                 : 
    1297                 : 
    1298                 : #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
    1299                 : 
    1300              72 :   YYSIZE_T yystacksize = YYINITDEPTH;
    1301                 : 
    1302                 :   /* The variables used to return semantic value and location from the
    1303                 :      action routines.  */
    1304                 :   YYSTYPE yyval;
    1305                 : 
    1306                 : 
    1307                 :   /* The number of symbols on the RHS of the reduced rule.
    1308                 :      Keep to zero when no symbol should be popped.  */
    1309              72 :   int yylen = 0;
    1310                 : 
    1311                 :   YYDPRINTF ((stderr, "Starting parse\n"));
    1312                 : 
    1313              72 :   yystate = 0;
    1314              72 :   yyerrstatus = 0;
    1315              72 :   yynerrs = 0;
    1316              72 :   yychar = YYEMPTY;             /* Cause a token to be read.  */
    1317                 : 
    1318                 :   /* Initialize stack pointers.
    1319                 :      Waste one element of value and location stack
    1320                 :      so that they stay on the same level as the state stack.
    1321                 :      The wasted elements are never initialized.  */
    1322                 : 
    1323              72 :   yyssp = yyss;
    1324              72 :   yyvsp = yyvs;
    1325                 : 
    1326              72 :   goto yysetstate;
    1327                 : 
    1328                 : /*------------------------------------------------------------.
    1329                 : | yynewstate -- Push a new state, which is found in yystate.  |
    1330                 : `------------------------------------------------------------*/
    1331          422128 :  yynewstate:
    1332                 :   /* In all cases, when you get here, the value and location stacks
    1333                 :      have just been pushed.  So pushing a state here evens the stacks.  */
    1334          422128 :   yyssp++;
    1335                 : 
    1336          422200 :  yysetstate:
    1337          422200 :   *yyssp = yystate;
    1338                 : 
    1339          422200 :   if (yyss + yystacksize - 1 <= yyssp)
    1340                 :     {
    1341                 :       /* Get the current used size of the three stacks, in elements.  */
    1342               0 :       YYSIZE_T yysize = yyssp - yyss + 1;
    1343                 : 
    1344                 : #ifdef yyoverflow
    1345                 :       {
    1346                 :         /* Give user a chance to reallocate the stack.  Use copies of
    1347                 :            these so that the &'s don't force the real ones into
    1348                 :            memory.  */
    1349                 :         YYSTYPE *yyvs1 = yyvs;
    1350                 :         yytype_int16 *yyss1 = yyss;
    1351                 : 
    1352                 : 
    1353                 :         /* Each stack pointer address is followed by the size of the
    1354                 :            data in use in that stack, in bytes.  This used to be a
    1355                 :            conditional around just the two extra args, but that might
    1356                 :            be undefined if yyoverflow is a macro.  */
    1357                 :         yyoverflow (YY_("memory exhausted"),
    1358                 :                     &yyss1, yysize * sizeof (*yyssp),
    1359                 :                     &yyvs1, yysize * sizeof (*yyvsp),
    1360                 : 
    1361                 :                     &yystacksize);
    1362                 : 
    1363                 :         yyss = yyss1;
    1364                 :         yyvs = yyvs1;
    1365                 :       }
    1366                 : #else /* no yyoverflow */
    1367                 : # ifndef YYSTACK_RELOCATE
    1368                 :       goto yyexhaustedlab;
    1369                 : # else
    1370                 :       /* Extend the stack our own way.  */
    1371               0 :       if (YYMAXDEPTH <= yystacksize)
    1372               0 :         goto yyexhaustedlab;
    1373               0 :       yystacksize *= 2;
    1374               0 :       if (YYMAXDEPTH < yystacksize)
    1375               0 :         yystacksize = YYMAXDEPTH;
    1376                 : 
    1377                 :       {
    1378               0 :         yytype_int16 *yyss1 = yyss;
    1379                 :         union yyalloc *yyptr =
    1380               0 :           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
    1381               0 :         if (! yyptr)
    1382               0 :           goto yyexhaustedlab;
    1383               0 :         YYSTACK_RELOCATE (yyss);
    1384               0 :         YYSTACK_RELOCATE (yyvs);
    1385                 : 
    1386                 : #  undef YYSTACK_RELOCATE
    1387               0 :         if (yyss1 != yyssa)
    1388               0 :           YYSTACK_FREE (yyss1);
    1389                 :       }
    1390                 : # endif
    1391                 : #endif /* no yyoverflow */
    1392                 : 
    1393               0 :       yyssp = yyss + yysize - 1;
    1394               0 :       yyvsp = yyvs + yysize - 1;
    1395                 : 
    1396                 : 
    1397                 :       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
    1398                 :                   (unsigned long int) yystacksize));
    1399                 : 
    1400               0 :       if (yyss + yystacksize - 1 <= yyssp)
    1401               0 :         YYABORT;
    1402                 :     }
    1403                 : 
    1404                 :   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
    1405                 : 
    1406                 :   goto yybackup;
    1407                 : 
    1408                 : /*-----------.
    1409                 : | yybackup.  |
    1410                 : `-----------*/
    1411          422200 : yybackup:
    1412                 : 
    1413                 :   /* Do appropriate processing given the current state.  Read a
    1414                 :      look-ahead token if we need one and don't already have one.  */
    1415                 : 
    1416                 :   /* First try to decide what to do without reference to look-ahead token.  */
    1417          422200 :   yyn = yypact[yystate];
    1418          422200 :   if (yyn == YYPACT_NINF)
    1419          267873 :     goto yydefault;
    1420                 : 
    1421                 :   /* Not known => get a look-ahead token if don't already have one.  */
    1422                 : 
    1423                 :   /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol.  */
    1424          154327 :   if (yychar == YYEMPTY)
    1425                 :     {
    1426                 :       YYDPRINTF ((stderr, "Reading a token: "));
    1427          132113 :       yychar = YYLEX;
    1428                 :     }
    1429                 : 
    1430          154327 :   if (yychar <= YYEOF)
    1431                 :     {
    1432              73 :       yychar = yytoken = YYEOF;
    1433                 :       YYDPRINTF ((stderr, "Now at end of input.\n"));
    1434                 :     }
    1435                 :   else
    1436                 :     {
    1437          154254 :       yytoken = YYTRANSLATE (yychar);
    1438                 :       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
    1439                 :     }
    1440                 : 
    1441                 :   /* If the proper action on seeing token YYTOKEN is to reduce or to
    1442                 :      detect an error, take that action.  */
    1443          154327 :   yyn += yytoken;
    1444          154327 :   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
    1445                 :     goto yydefault;
    1446          132109 :   yyn = yytable[yyn];
    1447          132109 :   if (yyn <= 0)
    1448                 :     {
    1449               0 :       if (yyn == 0 || yyn == YYTABLE_NINF)
    1450                 :         goto yyerrlab;
    1451               0 :       yyn = -yyn;
    1452               0 :       goto yyreduce;
    1453                 :     }
    1454                 : 
    1455          132109 :   if (yyn == YYFINAL)
    1456              71 :     YYACCEPT;
    1457                 : 
    1458                 :   /* Count tokens shifted since error; after three, turn off error
    1459                 :      status.  */
    1460          132038 :   if (yyerrstatus)
    1461              14 :     yyerrstatus--;
    1462                 : 
    1463                 :   /* Shift the look-ahead token.  */
    1464                 :   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
    1465                 : 
    1466                 :   /* Discard the shifted token unless it is eof.  */
    1467          132038 :   if (yychar != YYEOF)
    1468          132038 :     yychar = YYEMPTY;
    1469                 : 
    1470          132038 :   yystate = yyn;
    1471          132038 :   *++yyvsp = yylval;
    1472                 : 
    1473          132038 :   goto yynewstate;
    1474                 : 
    1475                 : 
    1476                 : /*-----------------------------------------------------------.
    1477                 : | yydefault -- do the default action for the current state.  |
    1478                 : `-----------------------------------------------------------*/
    1479          290091 : yydefault:
    1480          290091 :   yyn = yydefact[yystate];
    1481          290091 :   if (yyn == 0)
    1482              12 :     goto yyerrlab;
    1483                 :   goto yyreduce;
    1484                 : 
    1485                 : 
    1486                 : /*-----------------------------.
    1487                 : | yyreduce -- Do a reduction.  |
    1488                 : `-----------------------------*/
    1489          290079 : yyreduce:
    1490                 :   /* yyn is the number of a rule to reduce with.  */
    1491          290079 :   yylen = yyr2[yyn];
    1492                 : 
    1493                 :   /* If YYLEN is nonzero, implement the default value of the action:
    1494                 :      `$$ = $1'.
    1495                 : 
    1496                 :      Otherwise, the following line sets YYVAL to garbage.
    1497                 :      This behavior is undocumented and Bison
    1498                 :      users should not rely upon it.  Assigning to YYVAL
    1499                 :      unconditionally makes the parser a bit smaller, and it avoids a
    1500                 :      GCC warning that YYVAL may be used uninitialized.  */
    1501          290079 :   yyval = yyvsp[1-yylen];
    1502                 : 
    1503                 : 
    1504                 :   YY_REDUCE_PRINT (yyn);
    1505          290079 :   switch (yyn)
    1506                 :     {
    1507                 :         case 2:
    1508                 : #line 139 "grammar.y"
    1509                 :     { top_level_cleanup(0); ;}
    1510                 :     break;
    1511                 : 
    1512                 :   case 3:
    1513                 : #line 140 "grammar.y"
    1514                 :     { top_level_cleanup(0); ;}
    1515                 :     break;
    1516                 : 
    1517                 :   case 4:
    1518                 : #line 142 "grammar.y"
    1519                 :     { top_level_cleanup(1); ;}
    1520                 :     break;
    1521                 : 
    1522                 :   case 5:
    1523                 : #line 147 "grammar.y"
    1524                 :     {
    1525                 :                         print_graph((yyvsp[(1) - (2)].node), 0, 0); 
    1526                 :                         (yyval.node) = reduce_tree((yyvsp[(1) - (2)].node));
    1527                 :                         if (!reduction_interrupted)
    1528                 :                                 print_graph((yyval.node)->left, 0, 0);
    1529                 :                         free_node((yyval.node));
    1530                 :                 ;}
    1531                 :     break;
    1532                 : 
    1533                 :   case 6:
    1534                 : #line 155 "grammar.y"
    1535                 :     {
    1536                 :                         abbreviation_add((yyvsp[(2) - (4)].identifier), (yyvsp[(3) - (4)].node));
    1537                 :                         ++(yyvsp[(3) - (4)].node)->refcnt;
    1538                 :                         free_node((yyvsp[(3) - (4)].node));
    1539                 :                 ;}
    1540                 :     break;
    1541                 : 
    1542                 :   case 8:
    1543                 : #line 161 "grammar.y"
    1544                 :     { (yyval.node) = NULL; /* blank lines */ ;}
    1545                 :     break;
    1546                 : 
    1547                 :   case 9:
    1548                 : #line 165 "grammar.y"
    1549                 :     { reduction_timer ^= 1; ;}
    1550                 :     break;
    1551                 : 
    1552                 :   case 10:
    1553                 : #line 166 "grammar.y"
    1554                 :     { elaborate_output ^= 1; ;}
    1555                 :     break;
    1556                 : 
    1557                 :   case 11:
    1558                 : #line 167 "grammar.y"
    1559                 :     { debug_reduction ^= 1; ;}
    1560                 :     break;
    1561                 : 
    1562                 :   case 12:
    1563                 : #line 168 "grammar.y"
    1564                 :     { trace_reduction ^= 1; ;}
    1565                 :     break;
    1566                 : 
    1567                 :   case 13:
    1568                 : #line 169 "grammar.y"
    1569                 :     { single_step ^= 1; ;}
    1570                 :     break;
    1571                 : 
    1572                 :   case 14:
    1573                 : #line 170 "grammar.y"
    1574                 :     { push_and_open((yyvsp[(2) - (3)].string_constant)); ;}
    1575                 :     break;
    1576                 : 
    1577                 :   case 15:
    1578                 : #line 171 "grammar.y"
    1579                 :     { reduction_timeout = (yyvsp[(2) - (3)].numerical_constant); ;}
    1580                 :     break;
    1581                 : 
    1582                 :   case 16:
    1583                 : #line 172 "grammar.y"
    1584                 :     { max_reduction_count = (yyvsp[(2) - (3)].numerical_constant); ;}
    1585                 :     break;
    1586                 : 
    1587                 :   case 17:
    1588                 : #line 173 "grammar.y"
    1589                 :     { default_bracket_abstraction = determine_bracket_abstraction((yyvsp[(2) - (3)].identifier)); ;}
    1590                 :     break;
    1591                 : 
    1592                 :   case 18:
    1593                 : #line 177 "grammar.y"
    1594                 :     { (yyval.node) = (yyvsp[(1) - (1)].node); ;}
    1595                 :     break;
    1596                 : 
    1597                 :   case 19:
    1598                 : #line 178 "grammar.y"
    1599                 :     { (yyval.node) = (yyvsp[(1) - (1)].node); ;}
    1600                 :     break;
    1601                 : 
    1602                 :   case 20:
    1603                 : #line 180 "grammar.y"
    1604                 :     {
    1605                 :                         struct node *tmp;
    1606                 :                         tmp = reduce_tree((yyvsp[(2) - (2)].node));
    1607                 :                         --tmp->left->refcnt;
    1608                 :                         (yyval.node) = tmp->left;
    1609                 :                         tmp->left = NULL;
    1610                 :                         free_node(tmp);
    1611                 :                 ;}
    1612                 :     break;
    1613                 : 
    1614                 :   case 21:
    1615                 : #line 189 "grammar.y"
    1616                 :     {
    1617                 :                         (yyval.node) = execute_bracket_abstraction((yyvsp[(2) - (3)].bafunc), (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
    1618                 :                         ++(yyvsp[(1) - (3)].node)->refcnt;
    1619                 :                         free_node((yyvsp[(1) - (3)].node));
    1620                 :                         ++(yyvsp[(3) - (3)].node)->refcnt;
    1621                 :                         free_node((yyvsp[(3) - (3)].node));
    1622                 :                 ;}
    1623                 :     break;
    1624                 : 
    1625                 :   case 22:
    1626                 : #line 199 "grammar.y"
    1627                 :     { (yyval.bafunc) = determine_bracket_abstraction((yyvsp[(1) - (1)].identifier)); ;}
    1628                 :     break;
    1629                 : 
    1630                 :   case 23:
    1631                 : #line 200 "grammar.y"
    1632                 :     { (yyval.bafunc) = default_bracket_abstraction; ;}
    1633                 :     break;
    1634                 : 
    1635                 :   case 24:
    1636                 : #line 204 "grammar.y"
    1637                 :     { (yyval.node) = new_application((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].node)); ;}
    1638                 :     break;
    1639                 : 
    1640                 :   case 25:
    1641                 : #line 205 "grammar.y"
    1642                 :     { (yyval.node) = new_application((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].node)); ;}
    1643                 :     break;
    1644                 : 
    1645                 :   case 26:
    1646                 : #line 210 "grammar.y"
    1647                 :     { (yyval.node) = new_term((yyvsp[(2) - (3)].identifier)); ;}
    1648                 :     break;
    1649                 : 
    1650                 :   case 27:
    1651                 : #line 214 "grammar.y"
    1652                 :     { (yyval.node) = (yyvsp[(1) - (1)].node); ;}
    1653                 :     break;
    1654                 : 
    1655                 :   case 28:
    1656                 : #line 216 "grammar.y"
    1657                 :     {
    1658                 :                         (yyval.node) = abbreviation_lookup((yyvsp[(1) - (1)].identifier));
    1659                 :                         if (!(yyval.node))
    1660                 :                                 (yyval.node) = new_term((yyvsp[(1) - (1)].identifier));
    1661                 :                 ;}
    1662                 :     break;
    1663                 : 
    1664                 :   case 29:
    1665                 : #line 221 "grammar.y"
    1666                 :     { (yyval.node) = (yyvsp[(2) - (3)].node); ;}
    1667                 :     break;
    1668                 : 
    1669                 :   case 30:
    1670                 : #line 225 "grammar.y"
    1671                 :     { (yyval.node) = new_combinator((yyvsp[(1) - (1)].cn)); ;}
    1672                 :     break;
    1673                 : 
    1674                 : 
    1675                 : /* Line 1267 of yacc.c.  */
    1676                 : #line 1677 "y.tab.c"
    1677                 :       default: break;
    1678                 :     }
    1679                 :   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
    1680                 : 
    1681          290078 :   YYPOPSTACK (yylen);
    1682          290078 :   yylen = 0;
    1683                 :   YY_STACK_PRINT (yyss, yyssp);
    1684                 : 
    1685          290078 :   *++yyvsp = yyval;
    1686                 : 
    1687                 : 
    1688                 :   /* Now `shift' the result of the reduction.  Determine what state
    1689                 :      that goes to, based on the state we popped back to and the rule
    1690                 :      number reduced by.  */
    1691                 : 
    1692          290078 :   yyn = yyr1[yyn];
    1693                 : 
    1694          290078 :   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
    1695          394305 :   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
    1696          104227 :     yystate = yytable[yystate];
    1697                 :   else
    1698          185851 :     yystate = yydefgoto[yyn - YYNTOKENS];
    1699                 : 
    1700          290078 :   goto yynewstate;
    1701                 : 
    1702                 : 
    1703                 : /*------------------------------------.
    1704                 : | yyerrlab -- here on detecting error |
    1705                 : `------------------------------------*/
    1706              12 : yyerrlab:
    1707                 :   /* If not already recovering from an error, report this error.  */
    1708              12 :   if (!yyerrstatus)
    1709                 :     {
    1710               6 :       ++yynerrs;
    1711                 : #if ! YYERROR_VERBOSE
    1712                 :       yyerror (YY_("syntax error"));
    1713                 : #else
    1714                 :       {
    1715               6 :         YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
    1716               6 :         if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
    1717                 :           {
    1718               0 :             YYSIZE_T yyalloc = 2 * yysize;
    1719               0 :             if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
    1720               0 :               yyalloc = YYSTACK_ALLOC_MAXIMUM;
    1721               0 :             if (yymsg != yymsgbuf)
    1722               0 :               YYSTACK_FREE (yymsg);
    1723               0 :             yymsg = (char *) YYSTACK_ALLOC (yyalloc);
    1724               0 :             if (yymsg)
    1725               0 :               yymsg_alloc = yyalloc;
    1726                 :             else
    1727                 :               {
    1728               0 :                 yymsg = yymsgbuf;
    1729               0 :                 yymsg_alloc = sizeof yymsgbuf;
    1730                 :               }
    1731                 :           }
    1732                 : 
    1733              12 :         if (0 < yysize && yysize <= yymsg_alloc)
    1734                 :           {
    1735               6 :             (void) yysyntax_error (yymsg, yystate, yychar);
    1736               6 :             yyerror (yymsg);
    1737                 :           }
    1738                 :         else
    1739                 :           {
    1740               0 :             yyerror (YY_("syntax error"));
    1741               0 :             if (yysize != 0)
    1742               0 :               goto yyexhaustedlab;
    1743                 :           }
    1744                 :       }
    1745                 : #endif
    1746                 :     }
    1747                 : 
    1748                 : 
    1749                 : 
    1750              12 :   if (yyerrstatus == 3)
    1751                 :     {
    1752                 :       /* If just tried and failed to reuse look-ahead token after an
    1753                 :          error, discard it.  */
    1754                 : 
    1755               4 :       if (yychar <= YYEOF)
    1756                 :         {
    1757                 :           /* Return failure if at end of input.  */
    1758               0 :           if (yychar == YYEOF)
    1759               0 :             YYABORT;
    1760                 :         }
    1761                 :       else
    1762                 :         {
    1763               4 :           yydestruct ("Error: discarding",
    1764                 :                       yytoken, &yylval);
    1765               4 :           yychar = YYEMPTY;
    1766                 :         }
    1767                 :     }
    1768                 : 
    1769                 :   /* Else will try to reuse look-ahead token after shifting the error
    1770                 :      token.  */
    1771              12 :   goto yyerrlab1;
    1772                 : 
    1773                 : 
    1774                 : /*---------------------------------------------------.
    1775                 : | yyerrorlab -- error raised explicitly by YYERROR.  |
    1776                 : `---------------------------------------------------*/
    1777                 : yyerrorlab:
    1778                 : 
    1779                 :   /* Pacify compilers like GCC when the user code never invokes
    1780                 :      YYERROR and the label yyerrorlab therefore never appears in user
    1781                 :      code.  */
    1782                 :   if (/*CONSTCOND*/ 0)
    1783                 :      goto yyerrorlab;
    1784                 : 
    1785                 :   /* Do not reclaim the symbols of the rule which action triggered
    1786                 :      this YYERROR.  */
    1787                 :   YYPOPSTACK (yylen);
    1788                 :   yylen = 0;
    1789                 :   YY_STACK_PRINT (yyss, yyssp);
    1790                 :   yystate = *yyssp;
    1791                 :   goto yyerrlab1;
    1792                 : 
    1793                 : 
    1794                 : /*-------------------------------------------------------------.
    1795                 : | yyerrlab1 -- common code for both syntax error and YYERROR.  |
    1796                 : `-------------------------------------------------------------*/
    1797              12 : yyerrlab1:
    1798              12 :   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
    1799                 : 
    1800                 :   for (;;)
    1801                 :     {
    1802              28 :       yyn = yypact[yystate];
    1803              28 :       if (yyn != YYPACT_NINF)
    1804                 :         {
    1805              28 :           yyn += YYTERROR;
    1806              28 :           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
    1807                 :             {
    1808              12 :               yyn = yytable[yyn];
    1809              12 :               if (0 < yyn)
    1810              12 :                 break;
    1811                 :             }
    1812                 :         }
    1813                 : 
    1814                 :       /* Pop the current state because it cannot handle the error token.  */
    1815              16 :       if (yyssp == yyss)
    1816               0 :         YYABORT;
    1817                 : 
    1818                 : 
    1819              16 :       yydestruct ("Error: popping",
    1820                 :                   yystos[yystate], yyvsp);
    1821              16 :       YYPOPSTACK (1);
    1822              16 :       yystate = *yyssp;
    1823                 :       YY_STACK_PRINT (yyss, yyssp);
    1824              16 :     }
    1825                 : 
    1826              12 :   if (yyn == YYFINAL)
    1827               0 :     YYACCEPT;
    1828                 : 
    1829              12 :   *++yyvsp = yylval;
    1830                 : 
    1831                 : 
    1832                 :   /* Shift the error token.  */
    1833                 :   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
    1834                 : 
    1835              12 :   yystate = yyn;
    1836              12 :   goto yynewstate;
    1837                 : 
    1838                 : 
    1839                 : /*-------------------------------------.
    1840                 : | yyacceptlab -- YYACCEPT comes here.  |
    1841                 : `-------------------------------------*/
    1842              71 : yyacceptlab:
    1843              71 :   yyresult = 0;
    1844              71 :   goto yyreturn;
    1845                 : 
    1846                 : /*-----------------------------------.
    1847                 : | yyabortlab -- YYABORT comes here.  |
    1848                 : `-----------------------------------*/
    1849               0 : yyabortlab:
    1850               0 :   yyresult = 1;
    1851               0 :   goto yyreturn;
    1852                 : 
    1853                 : #ifndef yyoverflow
    1854                 : /*-------------------------------------------------.
    1855                 : | yyexhaustedlab -- memory exhaustion comes here.  |
    1856                 : `-------------------------------------------------*/
    1857               0 : yyexhaustedlab:
    1858               0 :   yyerror (YY_("memory exhausted"));
    1859               0 :   yyresult = 2;
    1860                 :   /* Fall through.  */
    1861                 : #endif
    1862                 : 
    1863              71 : yyreturn:
    1864              71 :   if (yychar != YYEOF && yychar != YYEMPTY)
    1865               0 :      yydestruct ("Cleanup: discarding lookahead",
    1866                 :                  yytoken, &yylval);
    1867                 :   /* Do not reclaim the symbols of the rule which action triggered
    1868                 :      this YYABORT or YYACCEPT.  */
    1869              71 :   YYPOPSTACK (yylen);
    1870                 :   YY_STACK_PRINT (yyss, yyssp);
    1871             213 :   while (yyssp != yyss)
    1872                 :     {
    1873              71 :       yydestruct ("Cleanup: popping",
    1874                 :                   yystos[*yyssp], yyvsp);
    1875              71 :       YYPOPSTACK (1);
    1876                 :     }
    1877                 : #ifndef yyoverflow
    1878              71 :   if (yyss != yyssa)
    1879               0 :     YYSTACK_FREE (yyss);
    1880                 : #endif
    1881                 : #if YYERROR_VERBOSE
    1882              71 :   if (yymsg != yymsgbuf)
    1883               0 :     YYSTACK_FREE (yymsg);
    1884                 : #endif
    1885                 :   /* Make sure YYID is used.  */
    1886              71 :   return YYID (yyresult);
    1887                 : }
    1888                 : 
    1889                 : 
    1890                 : #line 228 "grammar.y"
    1891                 : 
    1892                 : 
    1893                 : int
    1894                 : main(int ac, char **av)
    1895                 : {
    1896                 :         int c, r;
    1897                 :         struct filename_node *p, *load_files = NULL, *load_tail = NULL;
    1898                 :         struct hashtable *h = init_hashtable(64, 10);
    1899                 :         struct node *(*dba)(struct node *, struct node *);
    1900                 :         extern int yyparse();
    1901                 : 
    1902                 :         setup_abbreviation_table(h);
    1903                 :         setup_atom_table(h);
    1904                 : 
    1905                 :         while (-1 != (c = getopt(ac, av, "deL:mN:pstT:C:B:x")))
    1906                 :         {
    1907                 :                 switch (c)
    1908                 :                 {
    1909                 :                 case 'd':
    1910                 :                         debug_reduction = 1;
    1911                 :                         break;
    1912                 :                 case 'e':
    1913                 :                         elaborate_output = 1;
    1914                 :                         break;
    1915                 :                 case 'L':
    1916                 :                         p = malloc(sizeof(*p));
    1917                 :                         p->filename = Atom_string(optarg);
    1918                 :                         p->next = NULL;
    1919                 :                         if (load_tail)
    1920                 :                                 load_tail->next = p;
    1921                 :                         load_tail = p;
    1922                 :                         if (!load_files)
    1923                 :                                 load_files = p;
    1924                 :                         break;
    1925                 :                 case 'm':
    1926                 :                         memory_info = 1;
    1927                 :                         break;
    1928                 :                 case 'p':
    1929                 :                         prompting = 0;
    1930                 :                         break;
    1931                 :                 case 's':
    1932                 :                         single_step = 1;
    1933                 :                         break;
    1934                 :                 case 'T':
    1935                 :                         reduction_timeout = strtol(optarg, NULL, 10);
    1936                 :                         break;
    1937                 :                 case 't':
    1938                 :                         trace_reduction = 1;
    1939                 :                         break;
    1940                 :                 case 'x':
    1941                 :                         usage(av[0]);
    1942                 :                         exit(0);
    1943                 :                         break;
    1944                 :                 case 'B':
    1945                 :                         dba = determine_bracket_abstraction(optarg);
    1946                 :                         if (dba) default_bracket_abstraction = dba;
    1947                 :                         else {
    1948                 :                                 fprintf(stderr, "Unknown bracket abstraction algoritm \"%s\"\n", optarg);
    1949                 :                                 usage(av[0]);
    1950                 :                         }
    1951                 :                         break;
    1952                 :                 case 'C':
    1953                 :                         /* Turn *off* selected combinators: they become mere identifiers */
    1954                 :                         switch(optarg[0])
    1955                 :                         {
    1956                 :                         case 'S':
    1957                 :                                 S_as_combinator = 0;
    1958                 :                                 break;
    1959                 :                         case 'K':
    1960                 :                                 K_as_combinator = 0;
    1961                 :                                 break;
    1962                 :                         case 'I':
    1963                 :                                 I_as_combinator = 0;
    1964                 :                                 break;
    1965                 :                         case 'B':
    1966                 :                                 B_as_combinator = 0;
    1967                 :                                 break;
    1968                 :                         case 'C':
    1969                 :                                 C_as_combinator = 0;
    1970                 :                                 break;
    1971                 :                         case 'W':
    1972                 :                                 W_as_combinator = 0;
    1973                 :                                 break;
    1974                 :                         case 'M':
    1975                 :                                 M_as_combinator = 0;
    1976                 :                                 break;
    1977                 :                         case 'T':
    1978                 :                                 T_as_combinator = 0;
    1979                 :                                 break;
    1980                 :                         default:
    1981                 :                                 fprintf(stderr, "Unknown primitive combinator \"%s\"\n", optarg);
    1982                 :                                 usage(av[0]);
    1983                 :                                 break;
    1984                 :                         }
    1985                 :                         break;
    1986                 :                 case 'N':
    1987                 :                         max_reduction_count = strtol(optarg, NULL, 10);
    1988                 :                         if (max_reduction_count < 0) max_reduction_count = 0;
    1989                 :                         break;
    1990                 :                 }
    1991                 :         }
    1992                 : 
    1993                 :         init_node_allocation(memory_info);
    1994                 : 
    1995                 :         if (load_files)
    1996                 :         {
    1997                 :                 struct filename_node *t, *z;
    1998                 :                 int old_prompt = prompting;
    1999                 :                 prompting = 0;
    2000                 :                 for (z = load_files; z; z = t)
    2001                 :                 {
    2002                 :                         FILE *fin;
    2003                 : 
    2004                 :                         t = z->next;
    2005                 : 
    2006                 :                         printf("load file named \"%s\"\n",
    2007                 :                                 z->filename);
    2008                 : 
    2009                 :                         if (!(fin = fopen(z->filename, "r")))
    2010                 :                         {
    2011                 :                                 fprintf(stderr, "Problem reading \"%s\": %s\n",
    2012                 :                                         z->filename, strerror(errno));
    2013                 :                                 continue;
    2014                 :                         }
    2015                 : 
    2016                 :                         set_yyin(z->filename);
    2017                 : 
    2018                 :                         r = yyparse();
    2019                 : 
    2020                 :                         reset_yyin();
    2021                 : 
    2022                 :                         if (r)
    2023                 :                                 printf("Problem with file \"%s\"\n", z->filename);
    2024                 : 
    2025                 :                         free(z);
    2026                 :                         fin = NULL;
    2027                 :                 }
    2028                 :                 prompting = old_prompt;
    2029                 :         }
    2030                 : 
    2031                 :         set_yyin_stdin();
    2032                 : 
    2033                 :         do {
    2034                 :                 if (prompting) printf("CL> ");
    2035                 :                 r =  yyparse();
    2036                 :         } while (r);
    2037                 :         if (prompting) printf("\n");
    2038                 : 
    2039                 :         if (memory_info) fprintf(stderr, "Memory usage indicators:\n");
    2040                 :         free_all_nodes(memory_info);
    2041                 :         free_hashtable(h);
    2042                 :         free_all_spine_stacks(memory_info);
    2043                 : 
    2044                 :         return r;
    2045                 : }
    2046                 : 
    2047                 : void top_level_cleanup(int syntax_error_occurred)
    2048                 : {
    2049                 :         reset_node_allocation();
    2050                 :         reduction_interrupted = 0;
    2051                 :         if (prompting && !syntax_error_occurred) printf("CL> ");
    2052                 : }
    2053                 : 
    2054                 : int
    2055                 : yyerror(char *s1)
    2056                 : {
    2057                 :     fprintf(stderr, "%s\n", s1);
    2058                 : 
    2059                 :     return 0;
    2060                 : }
    2061                 : 
    2062                 : 
    2063                 : void
    2064                 : sigint_handler(int signo)
    2065                 : {
    2066                 :         /* the "return value" of 1 or 2 comes out in the
    2067                 :          * call to sigsetjmp() in reduce_tree().
    2068                 :          */
    2069                 :         siglongjmp(in_reduce_graph, signo == SIGINT? 1: 2);
    2070                 : }
    2071                 : 
    2072                 : /*
    2073                 :  * Function reduce_tree() exists to wrap reduce_graph()
    2074                 :  * at the topmost level.  It wraps with setting signal handlers,
    2075                 :  * taking before & after timestamps, setting jmp_buf structs, etc.
    2076                 :  */
    2077                 : struct node *
    2078                 : reduce_tree(struct node *real_root)
    2079                 : {
    2080                 :         void (*old_sigint_handler)(int);
    2081                 :         void (*old_sigalm_handler)(int);
    2082                 :         struct timeval before, after;
    2083                 :         int cc;
    2084                 :         struct node *new_root = new_application(real_root, NULL);
    2085                 : 
    2086                 :         /* new_root - points to a "dummy" node, necessary for I and
    2087                 :          * K reductions, if the expression is something like "I x" or
    2088                 :          * K a b. */
    2089                 :         ++new_root->refcnt;
    2090                 :         MARK_RIGHT_BRANCH_TRAVERSED(new_root);
    2091                 : 
    2092                 :         old_sigint_handler = signal(SIGINT, sigint_handler);
    2093                 :         old_sigalm_handler = signal(SIGALRM, sigint_handler);
    2094                 : 
    2095                 :         if (!(cc = sigsetjmp(in_reduce_graph, 1)))
    2096                 :         {
    2097                 :                 alarm(reduction_timeout);
    2098                 :                 gettimeofday(&before, NULL);
    2099                 :                 reduce_graph(new_root);
    2100                 :                 alarm(0);
    2101                 :                 gettimeofday(&after, NULL);
    2102                 :         } else {
    2103                 :                 const char *phrase = "Unset";
    2104                 :                 alarm(0);
    2105                 :                 gettimeofday(&after, NULL);
    2106                 :                 switch (cc)
    2107                 :                 {
    2108                 :                 case 1:
    2109                 :                         phrase = "Interrupt";
    2110                 :                         reduction_interrupted = 1;
    2111                 :                         break;
    2112                 :                 case 2:
    2113                 :                         reduction_interrupted = 1;
    2114                 :                         phrase = "Timeout";
    2115                 :                         break;
    2116                 :                 case 3:
    2117                 :                         phrase = "Terminated";
    2118                 :                         reduction_interrupted = 1;
    2119                 :                         break;
    2120                 :                 case 4:
    2121                 :                         phrase = "Reduction limit";
    2122                 :                         reduction_interrupted = 0;
    2123                 :                         break;
    2124                 :                 default:
    2125                 :                         phrase = "Unknown";
    2126                 :                         break;
    2127                 :                 }
    2128                 :                 printf("%s\n", phrase);
    2129                 :                 ++interpreter_interrupted;
    2130                 :         }
    2131                 : 
    2132                 :         signal(SIGINT, old_sigint_handler);
    2133                 :         signal(SIGALRM, old_sigalm_handler);
    2134                 : 
    2135                 :         if (reduction_timer)
    2136                 :                 printf("elapsed time %.3f seconds\n", elapsed_time(before, after));
    2137                 : 
    2138                 :         return new_root;
    2139                 : }
    2140                 : 
    2141                 : /*
    2142                 :  * Function execute_bracket_abstraction() exists to wrap various bracket
    2143                 :  * abstraction functions.  It wraps with setting signal handlers,
    2144                 :  * taking before & after timestamps, setting jmp_buf structs, etc.
    2145                 :  */
    2146                 : struct node *
    2147                 : execute_bracket_abstraction(
    2148                 :         struct node *(*bafunc)(struct node *, struct node *),
    2149                 :         struct node *abstracted_var,
    2150                 :         struct node *root
    2151                 : )
    2152                 : {
    2153                 :         struct node *r = NULL;
    2154                 :         void (*old_sigint_handler)(int);
    2155                 :         void (*old_sigalm_handler)(int);
    2156                 :         struct timeval before, after;
    2157                 :         int cc;
    2158                 : 
    2159                 :         old_sigint_handler = signal(SIGINT, sigint_handler);
    2160                 :         old_sigalm_handler = signal(SIGALRM, sigint_handler);
    2161                 : 
    2162                 :         if (!(cc = sigsetjmp(in_reduce_graph, 1)))
    2163                 :         {
    2164                 :                 alarm(reduction_timeout);
    2165                 :                 gettimeofday(&before, NULL);
    2166                 :                 r = (bafunc)(abstracted_var, root);
    2167                 :                 alarm(0);
    2168                 :                 gettimeofday(&after, NULL);
    2169                 :         } else {
    2170                 :                 const char *phrase = "Unset";
    2171                 :                 alarm(0);
    2172                 :                 gettimeofday(&after, NULL);
    2173                 :                 switch (cc)
    2174                 :                 {
    2175                 :                 case 1: phrase = "Interrupt"; break;
    2176                 :                 case 2: phrase = "Timeout";   break;
    2177                 :                 case 3: phrase = "Terminated";break;
    2178                 :                 default:
    2179                 :                         phrase = "Unknown";
    2180                 :                         break;
    2181                 :                 }
    2182                 :                 printf("%s\n", phrase);
    2183                 :         }
    2184                 : 
    2185                 :         signal(SIGINT, old_sigint_handler);
    2186                 :         signal(SIGALRM, old_sigalm_handler);
    2187                 : 
    2188                 :         if (reduction_timer)
    2189                 :                 printf("elapsed time %.3f seconds\n", elapsed_time(before, after));
    2190                 : 
    2191                 :         return r;
    2192                 : }
    2193                 : 
    2194                 : /* utility function elapsed_time() */
    2195                 : float
    2196                 : elapsed_time(struct timeval before, struct timeval after)
    2197                 : {
    2198                 :         float r = 0.0;
    2199                 : 
    2200                 :         if (before.tv_usec > after.tv_usec)
    2201                 :         {
    2202                 :                 after.tv_usec += 1000000;
    2203                 :                 --after.tv_sec;
    2204                 :         }
    2205                 : 
    2206                 :         r = (float)(after.tv_sec - before.tv_sec)
    2207                 :                 + (1.0E-6)*(float)(after.tv_usec - before.tv_usec);
    2208                 : 
    2209                 :         return r;
    2210                 : }
    2211                 : 
    2212                 : void
    2213                 : usage(char *progname)
    2214                 : {
    2215                 :         fprintf(stderr, "%s: Combinatory Logic like language interpreter\n",
    2216                 :                 progname);
    2217                 :         fprintf(stderr, "Flags:\n"
    2218                 :                 "-d             debug reductions\n"
    2219                 :                 "-e             elaborate output\n"
    2220                 :                 "-L  filename   Load and interpret a filenamed filename\n"
    2221                 :                 "-m             on exit, print memory usage summary\n"
    2222                 :                 "-N number      perform up to number reductions\n"
    2223                 :                 "-s             single-step reductions\n"
    2224                 :                 "-T number      evaluate an expression for up to number seconds\n"
    2225                 :                 "-t             trace reductions\n"
    2226                 :                 "-C combinator  treat combinator as a non-primitive. Combinator one of S, K, I, B, C, W, M, T\n"
    2227                 :                 "-B algoritm    Use algorithm as default for bracket abstraction.  One of curry, tromp, grz, btmk\n"
    2228                 :                 ""
    2229                 :         );
    2230                 : }
    2231                 : 

Generated by: LTP GCOV extension version 1.6