Home | History | Annotate | Download | only in tests
      1 #! /bin/sh
      2 ## --------------------- ##
      3 ## M4sh Initialization.  ##
      4 ## --------------------- ##
      5 
      6 # Be Bourne compatible
      7 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
      8   emulate sh
      9   NULLCMD=:
     10   # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
     11   # is contrary to our usage.  Disable this feature.
     12   alias -g '${1+"$@"}'='"$@"'
     13 elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
     14   set -o posix
     15 fi
     16 DUALCASE=1; export DUALCASE # for MKS sh
     17 
     18 # Support unset when possible.
     19 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
     20   as_unset=unset
     21 else
     22   as_unset=false
     23 fi
     24 
     25 
     26 # Work around bugs in pre-3.0 UWIN ksh.
     27 $as_unset ENV MAIL MAILPATH
     28 PS1='$ '
     29 PS2='> '
     30 PS4='+ '
     31 
     32 # NLS nuisances.
     33 for as_var in \
     34   LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
     35   LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
     36   LC_TELEPHONE LC_TIME
     37 do
     38   if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
     39     eval $as_var=C; export $as_var
     40   else
     41     $as_unset $as_var
     42   fi
     43 done
     44 
     45 # Required to use basename.
     46 if expr a : '\(a\)' >/dev/null 2>&1; then
     47   as_expr=expr
     48 else
     49   as_expr=false
     50 fi
     51 
     52 if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
     53   as_basename=basename
     54 else
     55   as_basename=false
     56 fi
     57 
     58 
     59 # Name of the executable.
     60 as_me=`$as_basename "$0" ||
     61 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
     62 	 X"$0" : 'X\(//\)$' \| \
     63 	 X"$0" : 'X\(/\)$' \| \
     64 	 .     : '\(.\)' 2>/dev/null ||
     65 echo X/"$0" |
     66     sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
     67   	  /^X\/\(\/\/\)$/{ s//\1/; q; }
     68   	  /^X\/\(\/\).*/{ s//\1/; q; }
     69   	  s/.*/./; q'`
     70 
     71 
     72 # PATH needs CR, and LINENO needs CR and PATH.
     73 # Avoid depending upon Character Ranges.
     74 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
     75 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
     76 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
     77 as_cr_digits='0123456789'
     78 as_cr_alnum=$as_cr_Letters$as_cr_digits
     79 
     80 # The user is always right.
     81 if test "${PATH_SEPARATOR+set}" != set; then
     82   echo "#! /bin/sh" >conf$$.sh
     83   echo  "exit 0"   >>conf$$.sh
     84   chmod +x conf$$.sh
     85   if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
     86     PATH_SEPARATOR=';'
     87   else
     88     PATH_SEPARATOR=:
     89   fi
     90   rm -f conf$$.sh
     91 fi
     92 
     93 
     94   as_lineno_1=$LINENO
     95   as_lineno_2=$LINENO
     96   as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
     97   test "x$as_lineno_1" != "x$as_lineno_2" &&
     98   test "x$as_lineno_3"  = "x$as_lineno_2"  || {
     99   # Find who we are.  Look in the path if we contain no path at all
    100   # relative or not.
    101   case $0 in
    102     *[\\/]* ) as_myself=$0 ;;
    103     *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
    104 for as_dir in $PATH
    105 do
    106   IFS=$as_save_IFS
    107   test -z "$as_dir" && as_dir=.
    108   test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
    109 done
    110 
    111        ;;
    112   esac
    113   # We did not find ourselves, most probably we were run as `sh COMMAND'
    114   # in which case we are not to be found in the path.
    115   if test "x$as_myself" = x; then
    116     as_myself=$0
    117   fi
    118   if test ! -f "$as_myself"; then
    119     { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
    120    { (exit 1); exit 1; }; }
    121   fi
    122   case $CONFIG_SHELL in
    123   '')
    124     as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
    125 for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
    126 do
    127   IFS=$as_save_IFS
    128   test -z "$as_dir" && as_dir=.
    129   for as_base in sh bash ksh sh5; do
    130 	 case $as_dir in
    131 	 /*)
    132 	   if ("$as_dir/$as_base" -c '
    133   as_lineno_1=$LINENO
    134   as_lineno_2=$LINENO
    135   as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
    136   test "x$as_lineno_1" != "x$as_lineno_2" &&
    137   test "x$as_lineno_3"  = "x$as_lineno_2" ') 2>/dev/null; then
    138 	     $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
    139 	     $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
    140 	     CONFIG_SHELL=$as_dir/$as_base
    141 	     export CONFIG_SHELL
    142 	     exec "$CONFIG_SHELL" "$0" ${1+"$@"}
    143 	   fi;;
    144 	 esac
    145        done
    146 done
    147 ;;
    148   esac
    149 
    150   # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
    151   # uniformly replaced by the line number.  The first 'sed' inserts a
    152   # line-number line before each line; the second 'sed' does the real
    153   # work.  The second script uses 'N' to pair each line-number line
    154   # with the numbered line, and appends trailing '-' during
    155   # substitution so that $LINENO is not a special case at line end.
    156   # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
    157   # second 'sed' script.  Blame Lee E. McMahon for sed's syntax.  :-)
    158   sed '=' <$as_myself |
    159     sed '
    160       N
    161       s,$,-,
    162       : loop
    163       s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
    164       t loop
    165       s,-$,,
    166       s,^['$as_cr_digits']*\n,,
    167     ' >$as_me.lineno &&
    168   chmod +x $as_me.lineno ||
    169     { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
    170    { (exit 1); exit 1; }; }
    171 
    172   # Don't try to exec as it changes $[0], causing all sort of problems
    173   # (the dirname of $[0] is not the place where we might find the
    174   # original and so on.  Autoconf is especially sensible to this).
    175   . ./$as_me.lineno
    176   # Exit status is that of the last command.
    177   exit
    178 }
    179 
    180 
    181 case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
    182   *c*,-n*) ECHO_N= ECHO_C='
    183 ' ECHO_T='	' ;;
    184   *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
    185   *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
    186 esac
    187 
    188 if expr a : '\(a\)' >/dev/null 2>&1; then
    189   as_expr=expr
    190 else
    191   as_expr=false
    192 fi
    193 
    194 rm -f conf$$ conf$$.exe conf$$.file
    195 echo >conf$$.file
    196 if ln -s conf$$.file conf$$ 2>/dev/null; then
    197   # We could just check for DJGPP; but this test a) works b) is more generic
    198   # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
    199   if test -f conf$$.exe; then
    200     # Don't use ln at all; we don't have any links
    201     as_ln_s='cp -p'
    202   else
    203     as_ln_s='ln -s'
    204   fi
    205 elif ln conf$$.file conf$$ 2>/dev/null; then
    206   as_ln_s=ln
    207 else
    208   as_ln_s='cp -p'
    209 fi
    210 rm -f conf$$ conf$$.exe conf$$.file
    211 
    212 if mkdir -p . 2>/dev/null; then
    213   as_mkdir_p=:
    214 else
    215   test -d ./-p && rmdir ./-p
    216   as_mkdir_p=false
    217 fi
    218 
    219 as_executable_p="test -f"
    220 
    221 # Sed expression to map a string onto a valid CPP name.
    222 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
    223 
    224 # Sed expression to map a string onto a valid variable name.
    225 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
    226 
    227 
    228 # IFS
    229 # We need space, tab and new line, in precisely that order.
    230 as_nl='
    231 '
    232 IFS=" 	$as_nl"
    233 
    234 # CDPATH.
    235 $as_unset CDPATH
    236 
    237 
    238 SHELL=${CONFIG_SHELL-/bin/sh}
    239 
    240 # How were we run?
    241 at_cli_args="$@"
    242 
    243 # Load the config file.
    244 for at_file in atconfig atlocal
    245 do
    246   test -r $at_file || continue
    247   . ./$at_file || { echo "$as_me: error: invalid content: $at_file" >&2
    248    { (exit 1); exit 1; }; }
    249 done
    250 
    251 # atconfig delivers paths relative to the directory the test suite is
    252 # in, but the groups themselves are run in testsuite-dir/group-dir.
    253 if test -n "$at_top_srcdir"; then
    254   builddir=../..
    255   for at_dir in srcdir top_srcdir top_builddir
    256   do
    257     at_val=`eval echo '${'at_$at_dir'}'`
    258     eval "$at_dir=\$at_val/../.."
    259   done
    260 fi
    261 
    262 # Not all shells have the 'times' builtin; the subshell is needed to make
    263 # sure we discard the 'times: not found' message from the shell.
    264 at_times_p=false
    265 (times) >/dev/null 2>&1 && at_times_p=:
    266 
    267 # CLI Arguments to pass to the debugging scripts.
    268 at_debug_args=
    269 # -e sets to true
    270 at_errexit_p=false
    271 # Shall we be verbose?
    272 at_verbose=:
    273 at_quiet=echo
    274 
    275 # Shall we keep the debug scripts?  Must be `:' when the suite is
    276 # run by a debug script, so that the script doesn't remove itself.
    277 at_debug_p=false
    278 # Display help message?
    279 at_help_p=false
    280 # List test groups?
    281 at_list_p=false
    282 # Test groups to run
    283 at_groups=
    284 
    285 # The directory we are in.
    286 at_dir=`pwd`
    287 # The directory the whole suite works in.
    288 # Should be absolutely to let the user `cd' at will.
    289 at_suite_dir=$at_dir/$as_me.dir
    290 # The file containing the suite.
    291 at_suite_log=$at_dir/$as_me.log
    292 # The file containing the location of the last AT_CHECK.
    293 at_check_line_file=$at_suite_dir/at-check-line
    294 # The file containing the exit status of the last command.
    295 at_status_file=$at_suite_dir/at-status
    296 # The files containing the output of the tested commands.
    297 at_stdout=$at_suite_dir/at-stdout
    298 at_stder1=$at_suite_dir/at-stder1
    299 at_stderr=$at_suite_dir/at-stderr
    300 # The file containing dates.
    301 at_times_file=$at_suite_dir/at-times
    302 
    303 # List of the tested programs.
    304 at_tested='bison'
    305 # List of the all the test groups.
    306 at_groups_all=' banner-1 1 2 3 4 5 6 7 8 9 10 banner-2 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 banner-3 31 32 33 34 banner-4 35 36 37 38 39 40 banner-5 41 42 43 44 45 banner-6 46 47 48 49 banner-7 50 51 52 53 54 55 56 57 banner-8 58 59 60 61 62 63 64 65 66 67 68 69 banner-9 70 71 72 73 74 75 76 77 78 79 80 81 82 83 banner-10 84 85 86 87 88 89 90 91 92 93 94 95 96 97 banner-11 98 99 100 101 102 banner-12 103 104 banner-13 105 106 107 108 109 banner-14 110 111 112 banner-15 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 banner-16 131 132 banner-17 133 134 135 136 137 138 139 140 141 banner-18 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158'
    307 # As many dots as there are digits in the last test group number.
    308 # Used to normalize the test group numbers so that `ls' lists them in
    309 # numerical order.
    310 at_format='...'
    311 # Description of all the test groups.
    312 at_help_all='1;input.at:28;Invalid dollar-n;;
    313 2;input.at:46;Invalid @n;;
    314 3;input.at:64;Type Clashes;;
    315 4;input.at:89;Unused values;;
    316 5;input.at:157;Incompatible Aliases;;
    317 6;input.at:198;Torturing the Scanner;;
    318 7;input.at:357;Typed symbol aliases;;
    319 8;input.at:393;Require 1.0;;
    320 9;input.at:394;Require 2.3;;
    321 10;input.at:396;Require 100.0;;
    322 11;output.at:43;Output files:  -dv ;;
    323 12;output.at:46;Output files:  -dv >&-;;
    324 13;output.at:48;Output files:  -dv -o foo.c ;;
    325 14;output.at:50;Output files:  -dv -o foo.tab.c ;;
    326 15;output.at:52;Output files:  -dv -y ;;
    327 16;output.at:54;Output files:  -dv -b bar ;;
    328 17;output.at:56;Output files:  -dv -g -o foo.c ;;
    329 18;output.at:60;Output files: %defines %verbose  ;;
    330 19;output.at:62;Output files: %defines %verbose %yacc  ;;
    331 20;output.at:65;Output files: %defines %verbose %yacc  ;;
    332 21;output.at:69;Output files: %file-prefix="bar" %defines %verbose  ;;
    333 22;output.at:71;Output files: %output="bar.c" %defines %verbose %yacc  ;;
    334 23;output.at:75;Output files: %file-prefix="baz" %output="bar.c" %defines %verbose %yacc  ;;
    335 24;output.at:80;Output files: %defines %verbose  ;;
    336 25;output.at:83;Output files: %defines %verbose  -o foo.c ;;
    337 26;output.at:87;Output files:  --defines=foo.hpp -o foo.c++ ;;
    338 27;output.at:91;Output files:  -o foo.c++ --graph=foo.gph ;;
    339 28;output.at:105;Output files: %skeleton "lalr1.cc" %defines %verbose  ;;
    340 29;output.at:109;Output files: %skeleton "lalr1.cc" %defines %verbose  ;;
    341 30;output.at:114;Output files: %skeleton "lalr1.cc" %defines %verbose -o subdir/foo.cc ;;
    342 31;sets.at:66;Nullable;;
    343 32;sets.at:151;Broken Closure;;
    344 33;sets.at:193;Firsts;;
    345 34;sets.at:269;Accept;;
    346 35;reduce.at:26;Useless Terminals;;
    347 36;reduce.at:70;Useless Nonterminals;;
    348 37;reduce.at:125;Useless Rules;report;
    349 38;reduce.at:212;Reduced Automaton;report;
    350 39;reduce.at:301;Underivable Rules;report;
    351 40;reduce.at:342;Empty Language;;
    352 41;synclines.at:95;Prologue synch line;;
    353 42;synclines.at:115;%union synch line;;
    354 43;synclines.at:138;Postprologue synch line;;
    355 44;synclines.at:157;Action synch line;;
    356 45;synclines.at:175;Epilogue synch line;;
    357 46;headers.at:27;%union and --defines;;
    358 47;headers.at:77;Invalid CPP guards: input/input;;
    359 48;headers.at:78;Invalid CPP guards: 9foo;;
    360 49;headers.at:87;export YYLTYPE;;
    361 50;actions.at:25;Mid-rule actions;;
    362 51;actions.at:91;Exotic Dollars;;
    363 52;actions.at:527;Printers and Destructors : ;;
    364 53;actions.at:528;Printers and Destructors with union: ;;
    365 54;actions.at:533;Printers and Destructors : %defines %skeleton "lalr1.cc";c++;
    366 55;actions.at:534;Printers and Destructors with union: %defines %skeleton "lalr1.cc";c++;
    367 56;actions.at:536;Printers and Destructors : %glr-parser;;
    368 57;actions.at:537;Printers and Destructors with union: %glr-parser;;
    369 58;conflicts.at:32;S/R in initial;;
    370 59;conflicts.at:52;%nonassoc and eof;;
    371 60;conflicts.at:128;Unresolved SR Conflicts;report;
    372 61;conflicts.at:235;Resolved SR Conflicts;report;
    373 62;conflicts.at:357;Defaulted Conflicted Reduction;report;
    374 63;conflicts.at:476;%expect not enough;;
    375 64;conflicts.at:496;%expect right;;
    376 65;conflicts.at:513;%expect too much;;
    377 66;conflicts.at:533;%expect with reduce conflicts;;
    378 67;conflicts.at:553;%no-default-prec without %prec;;
    379 68;conflicts.at:579;%no-default-prec with %prec;;
    380 69;conflicts.at:603;%default-prec;;
    381 70;calc.at:550;Calculator ;;
    382 71;calc.at:552;Calculator %defines;;
    383 72;calc.at:553;Calculator %locations;;
    384 73;calc.at:554;Calculator %name-prefix="calc";;
    385 74;calc.at:555;Calculator %verbose;;
    386 75;calc.at:556;Calculator %yacc;;
    387 76;calc.at:557;Calculator %error-verbose;;
    388 77;calc.at:559;Calculator %pure-parser %locations;;
    389 78;calc.at:560;Calculator %error-verbose %locations;;
    390 79;calc.at:562;Calculator %error-verbose %locations %defines %name-prefix="calc" %verbose %yacc;;
    391 80;calc.at:564;Calculator %debug;;
    392 81;calc.at:565;Calculator %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc;;
    393 82;calc.at:567;Calculator %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc;;
    394 83;calc.at:569;Calculator %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count};;
    395 84;calc.at:586;Calculator %glr-parser ;;
    396 85;calc.at:588;Calculator %glr-parser %defines;;
    397 86;calc.at:589;Calculator %glr-parser %locations;;
    398 87;calc.at:590;Calculator %glr-parser %name-prefix="calc";;
    399 88;calc.at:591;Calculator %glr-parser %verbose;;
    400 89;calc.at:592;Calculator %glr-parser %yacc;;
    401 90;calc.at:593;Calculator %glr-parser %error-verbose;;
    402 91;calc.at:595;Calculator %glr-parser %pure-parser %locations;;
    403 92;calc.at:596;Calculator %glr-parser %error-verbose %locations;;
    404 93;calc.at:598;Calculator %glr-parser %error-verbose %locations %defines %name-prefix="calc" %verbose %yacc;;
    405 94;calc.at:600;Calculator %glr-parser %debug;;
    406 95;calc.at:601;Calculator %glr-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc;;
    407 96;calc.at:603;Calculator %glr-parser %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc;;
    408 97;calc.at:605;Calculator %glr-parser %pure-parser %error-verbose %debug %locations %defines %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count};;
    409 98;calc.at:621;Calculator %skeleton "lalr1.cc" %defines %locations ;c++;
    410 99;calc.at:622;Calculator %skeleton "lalr1.cc" %defines %locations %error-verbose %name-prefix="calc" %verbose %yacc;c++;
    411 100;calc.at:624;Calculator %skeleton "lalr1.cc" %defines %locations %error-verbose %debug %name-prefix="calc" %verbose %yacc;c++;
    412 101;calc.at:626;Calculator %skeleton "lalr1.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc;c++;
    413 102;calc.at:628;Calculator %skeleton "lalr1.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count};c++;
    414 103;calc.at:651;Calculator %skeleton "glr.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc;c++;
    415 104;calc.at:653;Calculator %skeleton "glr.cc" %defines %locations %pure-parser %error-verbose %debug %name-prefix="calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count};c++;
    416 105;torture.at:140;Big triangle;;
    417 106;torture.at:232;Big horizontal;;
    418 107;torture.at:368;Many look-ahead tokens;;
    419 108;torture.at:445;Exploding the Stack Size with Alloca;;
    420 109;torture.at:471;Exploding the Stack Size with Malloc;;
    421 110;existing.at:26;GNU AWK Grammar;;
    422 111;existing.at:364;GNU Cim Grammar;;
    423 112;existing.at:980;GNU pic Grammar;;
    424 113;regression.at:28;Trivial grammars;;
    425 114;regression.at:57;Early token definitions;;
    426 115;regression.at:95;Braces parsing;;
    427 116;regression.at:117;Duplicate string;;
    428 117;regression.at:143;Rule Line Numbers;report;
    429 118;regression.at:287;Mixing %token styles;;
    430 119;regression.at:310;Invalid inputs;;
    431 120;regression.at:336;Invalid inputs with {};;
    432 121;regression.at:363;Token definitions;;
    433 122;regression.at:416;Characters Escapes;;
    434 123;regression.at:447;Web2c Report;report;
    435 124;regression.at:624;Web2c Actions;report;
    436 125;regression.at:866;Dancer ;;
    437 126;regression.at:867;Dancer %glr-parser;;
    438 127;regression.at:868;Dancer %skeleton "lalr1.cc";c++;
    439 128;regression.at:963;Expecting two tokens ;;
    440 129;regression.at:964;Expecting two tokens %glr-parser;;
    441 130;regression.at:965;Expecting two tokens %skeleton "lalr1.cc";c++;
    442 131;c++.at:102;Doxygen Public Documentation;;
    443 132;c++.at:103;Doxygen Private Documentation;;
    444 133;cxx-type.at:412;GLR: Resolve ambiguity, impure, no locations;;
    445 134;cxx-type.at:419;GLR: Resolve ambiguity, impure, locations;;
    446 135;cxx-type.at:425;GLR: Resolve ambiguity, pure, no locations;;
    447 136;cxx-type.at:432;GLR: Resolve ambiguity, pure, locations;;
    448 137;cxx-type.at:439;GLR: Merge conflicting parses, impure, no locations;;
    449 138;cxx-type.at:446;GLR: Merge conflicting parses, impure, locations;;
    450 139;cxx-type.at:453;GLR: Merge conflicting parses, pure, no locations;;
    451 140;cxx-type.at:459;GLR: Merge conflicting parses, pure, locations;;
    452 141;cxx-type.at:466;GLR: Verbose messages, resolve ambiguity, impure, no locations;;
    453 142;glr-regression.at:25;Badly Collapsed GLR States;;
    454 143;glr-regression.at:116;Improper handling of embedded actions and dollar(-N) in GLR parsers;;
    455 144;glr-regression.at:232;Improper merging of GLR delayed action sets;;
    456 145;glr-regression.at:337;Duplicate representation of merged trees;;
    457 146;glr-regression.at:432;User destructor for unresolved GLR semantic value;;
    458 147;glr-regression.at:502;User destructor after an error during a split parse;;
    459 148;glr-regression.at:566;Duplicated user destructor for lookahead;;
    460 149;glr-regression.at:644;Incorrectly initialized location for empty right-hand side in GLR;;
    461 150;glr-regression.at:740;No users destructors if stack 0 deleted;;
    462 151;glr-regression.at:820;Corrupted semantic options if user action cuts parse;;
    463 152;glr-regression.at:881;Undesirable destructors if user action cuts parse;;
    464 153;glr-regression.at:947;Leaked semantic values if user action cuts parse;;
    465 154;glr-regression.at:1078;Incorrect lookahead during deterministic GLR;;
    466 155;glr-regression.at:1212;Incorrect lookahead during nondeterministic GLR;;
    467 156;glr-regression.at:1429;Leaked semantic values when reporting ambiguity;;
    468 157;glr-regression.at:1519;Leaked lookahead after nondeterministic parse syntax error;;
    469 158;glr-regression.at:1585;Uninitialized location when reporting ambiguity;;
    470 '
    471 
    472 at_keywords=
    473 at_prev=
    474 for at_option
    475 do
    476   # If the previous option needs an argument, assign it.
    477   if test -n "$at_prev"; then
    478     at_option=$at_prev=$at_option
    479     at_prev=
    480   fi
    481 
    482   at_optarg=`expr "x$at_option" : 'x[^=]*=\(.*\)'`
    483 
    484   # Accept the important Cygnus configure options, so we can diagnose typos.
    485 
    486   case $at_option in
    487     --help | -h )
    488 	at_help_p=:
    489 	;;
    490 
    491     --list | -l )
    492 	at_list_p=:
    493 	;;
    494 
    495     --version | -V )
    496 	echo "$as_me (GNU Bison 2.3)"
    497 	exit 0
    498 	;;
    499 
    500     --clean | -c )
    501 	rm -rf $at_suite_dir $at_suite_log
    502 	exit 0
    503 	;;
    504 
    505     --debug | -d )
    506 	at_debug_p=:
    507 	;;
    508 
    509     --errexit | -e )
    510 	at_debug_p=:
    511 	at_errexit_p=:
    512 	;;
    513 
    514     --verbose | -v )
    515 	at_verbose=echo; at_quiet=:
    516 	;;
    517 
    518     --trace | -x )
    519 	at_traceon='set -vx'; at_traceoff='set +vx'
    520 	;;
    521 
    522     [0-9] | [0-9][0-9] | [0-9][0-9][0-9] | [0-9][0-9][0-9][0-9])
    523 	at_groups="$at_groups$at_option "
    524 	;;
    525 
    526     # Ranges
    527     [0-9]- | [0-9][0-9]- | [0-9][0-9][0-9]- | [0-9][0-9][0-9][0-9]-)
    528 	at_range_start=`echo $at_option |tr -d '-'`
    529 	at_range=`echo " $at_groups_all " | \
    530 	  sed -e 's,^.* '$at_range_start' ,'$at_range_start' ,'`
    531 	at_groups="$at_groups$at_range "
    532 	;;
    533 
    534     -[0-9] | -[0-9][0-9] | -[0-9][0-9][0-9] | -[0-9][0-9][0-9][0-9])
    535 	at_range_end=`echo $at_option |tr -d '-'`
    536 	at_range=`echo " $at_groups_all " | \
    537 	  sed -e 's, '$at_range_end' .*$, '$at_range_end','`
    538 	at_groups="$at_groups$at_range "
    539 	;;
    540 
    541     [0-9]-[0-9] | [0-9]-[0-9][0-9] | [0-9]-[0-9][0-9][0-9] | \
    542     [0-9]-[0-9][0-9][0-9][0-9] | [0-9][0-9]-[0-9][0-9] | \
    543     [0-9][0-9]-[0-9][0-9][0-9] | [0-9][0-9]-[0-9][0-9][0-9][0-9] | \
    544     [0-9][0-9][0-9]-[0-9][0-9][0-9] | \
    545     [0-9][0-9][0-9]-[0-9][0-9][0-9][0-9] | \
    546     [0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9] )
    547 	at_range_start=`echo $at_option |sed 's,-.*,,'`
    548 	at_range_end=`echo $at_option |sed 's,.*-,,'`
    549 	# FIXME: Maybe test to make sure start <= end?
    550 	at_range=`echo " $at_groups_all " | \
    551 	  sed -e 's,^.* '$at_range_start' ,'$at_range_start' ,' \
    552 	      -e 's, '$at_range_end' .*$, '$at_range_end','`
    553 	at_groups="$at_groups$at_range "
    554 	;;
    555 
    556     # Keywords.
    557     --keywords | -k )
    558 	at_prev=--keywords
    559 	;;
    560     --keywords=* )
    561 	at_keywords="$at_keywords,$at_optarg"
    562 	;;
    563 
    564     *=*)
    565   	at_envvar=`expr "x$at_option" : 'x\([^=]*\)='`
    566   	# Reject names that are not valid shell variable names.
    567   	expr "x$at_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
    568   	  { echo "$as_me: error: invalid variable name: $at_envvar" >&2
    569    { (exit 1); exit 1; }; }
    570   	at_value=`echo "$at_optarg" | sed "s/'/'\\\\\\\\''/g"`
    571   	eval "$at_envvar='$at_value'"
    572   	export $at_envvar
    573 	# Propagate to debug scripts.
    574   	at_debug_args="$at_debug_args $at_option"
    575   	;;
    576 
    577      *) echo "$as_me: invalid option: $at_option" >&2
    578 	echo "Try \`$0 --help' for more information." >&2
    579 	exit 1
    580 	;;
    581   esac
    582 done
    583 
    584 # Process the --keywords
    585 if test -n "$at_keywords"; then
    586   at_groups_selected=$at_help_all
    587   for at_keyword in `IFS=,; set X $at_keywords; shift; echo ${1+$@}`
    588   do
    589     # It is on purpose that we match the test group titles too.
    590     at_groups_selected=`echo "$at_groups_selected" |
    591 			grep -i "^[^;]*;[^;]*.*[; ]$at_keyword[ ;]"`
    592   done
    593   at_groups_selected=`echo "$at_groups_selected" | sed 's/;.*//'`
    594   # Smash the end of lines.
    595   at_groups_selected=`echo $at_groups_selected`
    596   at_groups="$at_groups$at_groups_selected "
    597 fi
    598 
    599 # Selected test groups.
    600 test -z "$at_groups" && at_groups=$at_groups_all
    601 
    602 # Help message.
    603 if $at_help_p; then
    604   cat <<_ATEOF
    605 Usage: $0 [OPTION]... [VARIABLE=VALUE]... [TESTS]
    606 
    607 Run all the tests, or the selected TESTS, and save a detailed log file.
    608 Upon failure, create debugging scripts.
    609 
    610 You should not change environment variables unless explicitly passed
    611 as command line arguments.  Set \`AUTOTEST_PATH' to select the executables
    612 to exercise.  Each relative directory is expanded as build and source
    613 directories relatively to the top level of this distribution.  E.g.,
    614 
    615   $ $0 AUTOTEST_PATH=bin
    616 
    617 possibly amounts into
    618 
    619   PATH=/tmp/foo-1.0/bin:/src/foo-1.0/bin:\$PATH
    620 _ATEOF
    621 cat <<_ATEOF
    622 
    623 Operation modes:
    624   -h, --help     print the help message, then exit
    625   -V, --version  print version number, then exit
    626   -c, --clean    remove all the files this test suite might create and exit
    627   -l, --list     describes all the tests, or the selected TESTS
    628 _ATEOF
    629 cat <<_ATEOF
    630 
    631 Execution tuning:
    632   -k, --keywords=KEYWORDS
    633 	         select the tests matching all the comma separated KEYWORDS
    634 	         accumulates
    635   -e, --errexit  abort as soon as a test fails; implies --debug
    636   -v, --verbose  force more detailed output
    637 	         default for debugging scripts
    638   -d, --debug    inhibit clean up and debug script creation
    639 	         default for debugging scripts
    640   -x, --trace    enable tests shell tracing
    641 _ATEOF
    642 cat <<_ATEOF
    643 
    644 Report bugs to <bug-bison@gnu.org>.
    645 _ATEOF
    646   exit 0
    647 fi
    648 
    649 # List of tests.
    650 if $at_list_p; then
    651   cat <<_ATEOF
    652 GNU Bison 2.3 test suite test groups:
    653 
    654  NUM: FILENAME:LINE      TEST-GROUP-NAME
    655       KEYWORDS
    656 
    657 _ATEOF
    658   # "  1 42  45 " => "^(1|42|45);".
    659   at_groups_pattern=`echo "$at_groups" | sed 's/^  *//;s/  *$//;s/  */|/g'`
    660   echo "$at_help_all" |
    661     awk 'BEGIN { FS = ";" }
    662 	 { if ($1 !~ /^('"$at_groups_pattern"')$/) next }
    663 	 { if ($1) printf " %3d: %-18s %s\n", $1, $2, $3
    664 	   if ($4) printf "      %s\n", $4 } '
    665   exit 0
    666 fi
    667 
    668 # Don't take risks: use only absolute directories in PATH.
    669 #
    670 # For stand-alone test suites, AUTOTEST_PATH is relative to `.'.
    671 #
    672 # For embedded test suites, AUTOTEST_PATH is relative to the top level
    673 # of the package.  Then expand it into build/src parts, since users
    674 # may create executables in both places.
    675 #
    676 # There might be directories that don't exist, but don't redirect
    677 # builtins' (eg., cd) stderr directly: Ultrix's sh hates that.
    678 AUTOTEST_PATH=`echo $AUTOTEST_PATH | tr ':' $PATH_SEPARATOR`
    679 at_path=
    680 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
    681 for as_dir in $AUTOTEST_PATH $PATH
    682 do
    683   IFS=$as_save_IFS
    684   test -z "$as_dir" && as_dir=.
    685   case $as_dir in
    686   [\\/]* | ?:[\\/]* )
    687     at_path=$at_path$PATH_SEPARATOR$as_dir
    688     ;;
    689   * )
    690     if test -z "$at_top_builddir"; then
    691       # Stand-alone test suite.
    692       at_path=$at_path$PATH_SEPARATOR$as_dir
    693     else
    694       # Embedded test suite.
    695       at_path=$at_path$PATH_SEPARATOR$at_top_builddir/$as_dir
    696       at_path=$at_path$PATH_SEPARATOR$at_top_srcdir/$as_dir
    697     fi
    698     ;;
    699 esac
    700 done
    701 
    702 
    703 # Now build and simplify PATH.
    704 PATH=
    705 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
    706 for as_dir in $at_path
    707 do
    708   IFS=$as_save_IFS
    709   test -z "$as_dir" && as_dir=.
    710   as_dir=`(cd "$as_dir" && pwd) 2>/dev/null`
    711 test -d "$as_dir" || continue
    712 case $PATH in
    713 	          $as_dir                 | \
    714 	          $as_dir$PATH_SEPARATOR* | \
    715   *$PATH_SEPARATOR$as_dir                 | \
    716   *$PATH_SEPARATOR$as_dir$PATH_SEPARATOR* ) ;;
    717 
    718   '') PATH=$as_dir ;;
    719    *) PATH=$PATH$PATH_SEPARATOR$as_dir ;;
    720 esac
    721 done
    722 
    723 export PATH
    724 
    725 # Setting up the FDs.
    726 # 5 is the log file.  Not to be overwritten if `-d'.
    727 
    728 $at_debug_p && at_suite_log=/dev/null
    729 exec 5>$at_suite_log
    730 
    731 # Banners and logs.
    732 cat <<\_ASBOX
    733 ## ------------------------- ##
    734 ## GNU Bison 2.3 test suite. ##
    735 ## ------------------------- ##
    736 _ASBOX
    737 {
    738   cat <<\_ASBOX
    739 ## ------------------------- ##
    740 ## GNU Bison 2.3 test suite. ##
    741 ## ------------------------- ##
    742 _ASBOX
    743   echo
    744 
    745   echo "$as_me: command line was:"
    746   echo "  $ $0 $at_cli_args"
    747   echo
    748 
    749   # Try to find a few ChangeLogs in case it might help determining the
    750   # exact version.  Use the relative dir: if the top dir is a symlink,
    751   # find will not follow it (and options to follow the links are not
    752   # portable), which would result in no output here.
    753   if test -n "$at_top_srcdir"; then
    754     cat <<\_ASBOX
    755 ## ----------- ##
    756 ## ChangeLogs. ##
    757 ## ----------- ##
    758 _ASBOX
    759     echo
    760     for at_file in `find "$at_top_srcdir" -name ChangeLog -print`
    761     do
    762       echo "$as_me: $at_file:"
    763       sed 's/^/| /;10q' $at_file
    764       echo
    765     done
    766 
    767     {
    768 cat <<_ASUNAME
    769 ## --------- ##
    770 ## Platform. ##
    771 ## --------- ##
    772 
    773 hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
    774 uname -m = `(uname -m) 2>/dev/null || echo unknown`
    775 uname -r = `(uname -r) 2>/dev/null || echo unknown`
    776 uname -s = `(uname -s) 2>/dev/null || echo unknown`
    777 uname -v = `(uname -v) 2>/dev/null || echo unknown`
    778 
    779 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
    780 /bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
    781 
    782 /bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
    783 /usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
    784 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
    785 hostinfo               = `(hostinfo) 2>/dev/null               || echo unknown`
    786 /bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
    787 /usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
    788 /bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
    789 
    790 _ASUNAME
    791 
    792 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
    793 for as_dir in $PATH
    794 do
    795   IFS=$as_save_IFS
    796   test -z "$as_dir" && as_dir=.
    797   echo "PATH: $as_dir"
    798 done
    799 
    800 }
    801     echo
    802   fi
    803 
    804   # Contents of the config files.
    805   for at_file in atconfig atlocal
    806   do
    807     test -r $at_file || continue
    808     echo "$as_me: $at_file:"
    809     sed 's/^/| /' $at_file
    810     echo
    811   done
    812 
    813   cat <<\_ASBOX
    814 ## ---------------- ##
    815 ## Tested programs. ##
    816 ## ---------------- ##
    817 _ASBOX
    818   echo
    819 } >&5
    820 
    821 # Report what programs are being tested.
    822 for at_program in : $at_tested
    823 do
    824   test "$at_program" = : && continue
    825   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
    826 for as_dir in $PATH
    827 do
    828   IFS=$as_save_IFS
    829   test -z "$as_dir" && as_dir=.
    830   test -f $as_dir/$at_program && break
    831 done
    832 
    833   if test -f $as_dir/$at_program; then
    834     {
    835       echo "local.at:216: $as_dir/$at_program --version"
    836       $as_dir/$at_program --version
    837       echo
    838     } >&5 2>&1
    839   else
    840     { { echo "$as_me:$LINENO: error: cannot find $at_program" >&5
    841 echo "$as_me: error: cannot find $at_program" >&2;}
    842    { (exit 1); exit 1; }; }
    843   fi
    844 done
    845 
    846 {
    847   cat <<\_ASBOX
    848 ## ------------------ ##
    849 ## Running the tests. ##
    850 ## ------------------ ##
    851 _ASBOX
    852 } >&5
    853 
    854 at_start_date=`date`
    855 at_start_time=`(date +%s) 2>/dev/null`
    856 echo "$as_me: starting at: $at_start_date" >&5
    857 at_xpass_list=
    858 at_xfail_list=
    859 at_pass_list=
    860 at_fail_list=
    861 at_skip_list=
    862 at_group_count=0
    863 
    864 # Create the master directory if it doesn't already exist.
    865 test -d $at_suite_dir ||
    866   mkdir $at_suite_dir ||
    867   { { echo "$as_me:$LINENO: error: cannot create $at_suite_dir" >&5
    868 echo "$as_me: error: cannot create $at_suite_dir" >&2;}
    869    { (exit 1); exit 1; }; }
    870 
    871 # Can we diff with `/dev/null'?  DU 5.0 refuses.
    872 if diff /dev/null /dev/null >/dev/null 2>&1; then
    873   at_devnull=/dev/null
    874 else
    875   at_devnull=$at_suite_dir/devnull
    876   cp /dev/null $at_devnull
    877 fi
    878 
    879 # Use `diff -u' when possible.
    880 if diff -u $at_devnull $at_devnull >/dev/null 2>&1; then
    881   at_diff='diff -u'
    882 else
    883   at_diff=diff
    884 fi
    885 
    886 
    887 for at_group in $at_groups
    888 do
    889   # Be sure to come back to the top test directory.
    890   cd $at_suite_dir
    891 
    892   case $at_group in
    893     banner-*)
    894       at_group_log=$at_suite_log
    895       ;;
    896 
    897     *)
    898       # Skip tests we already run (using --keywords makes it easy to get
    899       # duplication).
    900       case " $at_pass_test $at_skip_test $at_fail_test " in
    901 	*" $at_group "* ) continue;;
    902       esac
    903 
    904       # Normalize the test group number.
    905       at_group_normalized=`expr "00000$at_group" : ".*\($at_format\)"`
    906 
    907       # Create a fresh directory for the next test group, and enter.
    908       at_group_dir=$at_suite_dir/$at_group_normalized
    909       at_group_log=$at_group_dir/$as_me.log
    910       rm -rf $at_group_dir
    911       mkdir $at_group_dir ||
    912 	{ { echo "$as_me:$LINENO: error: cannot create $at_group_dir" >&5
    913 echo "$as_me: error: cannot create $at_group_dir" >&2;}
    914    { (exit 1); exit 1; }; }
    915       cd $at_group_dir
    916       ;;
    917   esac
    918 
    919   echo 0 > $at_status_file
    920 
    921   # Clearly separate the test groups when verbose.
    922   test $at_group_count != 0 && $at_verbose
    923 
    924   # In verbose mode, append to the log file *and* show on
    925   # the standard output; in quiet mode only write to the log
    926   if test $at_verbose = echo; then
    927     at_tee_pipe="tee -a $at_group_log"
    928   else
    929     at_tee_pipe="cat >> $at_group_log"
    930   fi
    931 
    932   case $at_group in
    933 
    934   banner-1 ) # Banner 1. input.at:19
    935     cat <<\_ATEOF
    936 
    937 Input Processing.
    938 
    939 _ATEOF
    940     ;;
    941 
    942   1 ) # 1. input.at:28: Invalid dollar-n
    943     at_setup_line='input.at:28'
    944     at_desc='Invalid dollar-n'
    945     $at_quiet $ECHO_N "  1: Invalid dollar-n                             $ECHO_C"
    946     at_xfail=no
    947     (
    948       echo "1. input.at:28: testing ..."
    949       $at_traceon
    950 
    951 
    952 cat >input.y <<'_ATEOF'
    953 %%
    954 exp: { $$ = $1 ; };
    955 _ATEOF
    956 
    957 
    958 $at_traceoff
    959 echo "input.at:37: bison input.y"
    960 echo input.at:37 >$at_check_line_file
    961 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
    962 at_status=$?
    963 grep '^ *+' $at_stder1 >&2
    964 grep -v '^ *+' $at_stder1 >$at_stderr
    965 at_failed=false
    966 echo >>$at_stderr; echo "input.y:2.13-14: integer out of range: \`\$1'
    967 " | $at_diff - $at_stderr || at_failed=:
    968 $at_diff $at_devnull $at_stdout || at_failed=:
    969 case $at_status in
    970    77) echo 77 > $at_status_file
    971             exit 77;;
    972    1) ;;
    973    *) echo "input.at:37: exit code was $at_status, expected 1"
    974       at_failed=:;;
    975 esac
    976 if $at_failed; then
    977 
    978   echo 1 > $at_status_file
    979   exit 1
    980 fi
    981 
    982 $at_traceon
    983 
    984 
    985       $at_traceoff
    986       $at_times_p && times >$at_times_file
    987     ) 5>&1 2>&1 | eval $at_tee_pipe
    988     at_status=`cat $at_status_file`
    989     ;;
    990 
    991   2 ) # 2. input.at:46: Invalid @n
    992     at_setup_line='input.at:46'
    993     at_desc='Invalid @n'
    994     $at_quiet $ECHO_N "  2: Invalid @n                                   $ECHO_C"
    995     at_xfail=no
    996     (
    997       echo "2. input.at:46: testing ..."
    998       $at_traceon
    999 
   1000 
   1001 cat >input.y <<'_ATEOF'
   1002 %%
   1003 exp: { @$ = @1 ; };
   1004 _ATEOF
   1005 
   1006 
   1007 $at_traceoff
   1008 echo "input.at:55: bison input.y"
   1009 echo input.at:55 >$at_check_line_file
   1010 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   1011 at_status=$?
   1012 grep '^ *+' $at_stder1 >&2
   1013 grep -v '^ *+' $at_stder1 >$at_stderr
   1014 at_failed=false
   1015 echo >>$at_stderr; echo "input.y:2.13-14: integer out of range: \`@1'
   1016 " | $at_diff - $at_stderr || at_failed=:
   1017 $at_diff $at_devnull $at_stdout || at_failed=:
   1018 case $at_status in
   1019    77) echo 77 > $at_status_file
   1020             exit 77;;
   1021    1) ;;
   1022    *) echo "input.at:55: exit code was $at_status, expected 1"
   1023       at_failed=:;;
   1024 esac
   1025 if $at_failed; then
   1026 
   1027   echo 1 > $at_status_file
   1028   exit 1
   1029 fi
   1030 
   1031 $at_traceon
   1032 
   1033 
   1034       $at_traceoff
   1035       $at_times_p && times >$at_times_file
   1036     ) 5>&1 2>&1 | eval $at_tee_pipe
   1037     at_status=`cat $at_status_file`
   1038     ;;
   1039 
   1040   3 ) # 3. input.at:64: Type Clashes
   1041     at_setup_line='input.at:64'
   1042     at_desc='Type Clashes'
   1043     $at_quiet $ECHO_N "  3: Type Clashes                                 $ECHO_C"
   1044     at_xfail=no
   1045     (
   1046       echo "3. input.at:64: testing ..."
   1047       $at_traceon
   1048 
   1049 
   1050 cat >input.y <<'_ATEOF'
   1051 %token foo
   1052 %type <bar> exp
   1053 %%
   1054 exp: foo {} foo
   1055    | foo
   1056    | /* Empty. */
   1057    ;
   1058 _ATEOF
   1059 
   1060 
   1061 $at_traceoff
   1062 echo "input.at:80: bison input.y"
   1063 echo input.at:80 >$at_check_line_file
   1064 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   1065 at_status=$?
   1066 grep '^ *+' $at_stder1 >&2
   1067 grep -v '^ *+' $at_stder1 >$at_stderr
   1068 at_failed=false
   1069 echo >>$at_stderr; echo "input.y:4.6-15: warning: type clash on default action: <bar> != <>
   1070 input.y:5.6-8: warning: type clash on default action: <bar> != <>
   1071 input.y:6.5: warning: empty rule for typed nonterminal, and no action
   1072 " | $at_diff - $at_stderr || at_failed=:
   1073 $at_diff $at_devnull $at_stdout || at_failed=:
   1074 case $at_status in
   1075    77) echo 77 > $at_status_file
   1076             exit 77;;
   1077    0) ;;
   1078    *) echo "input.at:80: exit code was $at_status, expected 0"
   1079       at_failed=:;;
   1080 esac
   1081 if $at_failed; then
   1082 
   1083   echo 1 > $at_status_file
   1084   exit 1
   1085 fi
   1086 
   1087 $at_traceon
   1088 
   1089 
   1090       $at_traceoff
   1091       $at_times_p && times >$at_times_file
   1092     ) 5>&1 2>&1 | eval $at_tee_pipe
   1093     at_status=`cat $at_status_file`
   1094     ;;
   1095 
   1096   4 ) # 4. input.at:89: Unused values
   1097     at_setup_line='input.at:89'
   1098     at_desc='Unused values'
   1099     $at_quiet $ECHO_N "  4: Unused values                                $ECHO_C"
   1100     at_xfail=no
   1101     (
   1102       echo "4. input.at:89: testing ..."
   1103       $at_traceon
   1104 
   1105 
   1106 cat >input.y <<'_ATEOF'
   1107 %token <integer> INT
   1108 %type <integer> a b c d e f g h i j k l
   1109 %destructor { destroy ($$); } INT a b c d e f g h i j k l
   1110 %%
   1111 start:
   1112   'a' a { $2 } | 'b' b { $2 } | 'c' c { $2 } | 'd' d { $2 } | 'e' e { $2 }
   1113 | 'f' f { $2 } | 'g' g { $2 } | 'h' h { $2 } | 'i' i { $2 } | 'j' j { $2 }
   1114 | 'k' k { $2 } | 'l' l { $2 }
   1115 ;
   1116 
   1117 a: INT | INT { } INT { } INT { };
   1118 b: INT | /* empty */;
   1119 c: INT | INT { $1 } INT { } INT { };
   1120 d: INT | INT { } INT { $1 } INT { };
   1121 e: INT | INT { } INT {  } INT { $1 };
   1122 f: INT | INT { } INT {  } INT { $$ = $1 + $3 + $5; };
   1123 g: INT | INT { $$ } INT { $$ } INT { };
   1124 h: INT | INT { $$ } INT { $$ = $2 } INT { };
   1125 i: INT | INT INT { } { $$ = $1 + $2; };
   1126 j: INT | INT INT { $<integer>$ = 1; } { $$ = $1 + $2; };
   1127 k: INT | INT INT { $$; } { $$ = $3; } { };
   1128 l: INT | INT { $$ = $1; } INT { $$ = $2 + $3; } INT { $$ = $4 + $5; };
   1129 
   1130 _ATEOF
   1131 
   1132 
   1133 $at_traceoff
   1134 echo "input.at:148: bison input.y"
   1135 echo input.at:148 >$at_check_line_file
   1136 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   1137 at_status=$?
   1138 grep '^ *+' $at_stder1 >&2
   1139 grep -v '^ *+' $at_stder1 >$at_stderr
   1140 at_failed=false
   1141 echo >>$at_stderr; echo "input.y:11.10-32: warning: unset value: \$\$
   1142 input.y:11.10-32: warning: unused value: \$1
   1143 input.y:11.10-32: warning: unused value: \$3
   1144 input.y:11.10-32: warning: unused value: \$5
   1145 input.y:12.9: warning: empty rule for typed nonterminal, and no action
   1146 input.y:13.10-35: warning: unset value: \$\$
   1147 input.y:13.10-35: warning: unused value: \$3
   1148 input.y:13.10-35: warning: unused value: \$5
   1149 input.y:14.10-35: warning: unset value: \$\$
   1150 input.y:14.10-35: warning: unused value: \$3
   1151 input.y:14.10-35: warning: unused value: \$5
   1152 input.y:15.10-36: warning: unset value: \$\$
   1153 input.y:15.10-36: warning: unused value: \$3
   1154 input.y:15.10-36: warning: unused value: \$5
   1155 input.y:17.10-38: warning: unset value: \$\$
   1156 input.y:17.10-38: warning: unused value: \$1
   1157 input.y:17.10-38: warning: unused value: \$2
   1158 input.y:17.10-38: warning: unused value: \$3
   1159 input.y:17.10-38: warning: unused value: \$4
   1160 input.y:17.10-38: warning: unused value: \$5
   1161 input.y:18.10-43: warning: unset value: \$\$
   1162 input.y:18.10-43: warning: unused value: \$1
   1163 input.y:18.10-43: warning: unused value: \$3
   1164 input.y:18.10-43: warning: unused value: \$4
   1165 input.y:18.10-43: warning: unused value: \$5
   1166 input.y:20.10-55: warning: unused value: \$3
   1167 input.y:21.10-41: warning: unset value: \$\$
   1168 input.y:21.10-41: warning: unused value: \$1
   1169 input.y:21.10-41: warning: unused value: \$2
   1170 input.y:21.10-41: warning: unused value: \$4
   1171 " | $at_diff - $at_stderr || at_failed=:
   1172 $at_diff $at_devnull $at_stdout || at_failed=:
   1173 case $at_status in
   1174    77) echo 77 > $at_status_file
   1175             exit 77;;
   1176    0) ;;
   1177    *) echo "input.at:148: exit code was $at_status, expected 0"
   1178       at_failed=:;;
   1179 esac
   1180 if $at_failed; then
   1181 
   1182   echo 1 > $at_status_file
   1183   exit 1
   1184 fi
   1185 
   1186 $at_traceon
   1187 
   1188 
   1189       $at_traceoff
   1190       $at_times_p && times >$at_times_file
   1191     ) 5>&1 2>&1 | eval $at_tee_pipe
   1192     at_status=`cat $at_status_file`
   1193     ;;
   1194 
   1195   5 ) # 5. input.at:157: Incompatible Aliases
   1196     at_setup_line='input.at:157'
   1197     at_desc='Incompatible Aliases'
   1198     $at_quiet $ECHO_N "  5: Incompatible Aliases                         $ECHO_C"
   1199     at_xfail=no
   1200     (
   1201       echo "5. input.at:157: testing ..."
   1202       $at_traceon
   1203 
   1204 
   1205 cat >input.y <<'_ATEOF'
   1206 %token foo "foo"
   1207 
   1208 %type <bar>       foo
   1209 %printer {bar}    foo
   1210 %destructor {bar} foo
   1211 %left             foo
   1212 
   1213 %type <baz>       "foo"
   1214 %printer {baz}    "foo"
   1215 %destructor {baz} "foo"
   1216 %left             "foo"
   1217 
   1218 %%
   1219 exp: foo;
   1220 _ATEOF
   1221 
   1222 
   1223 $at_traceoff
   1224 echo "input.at:185: bison input.y"
   1225 echo input.at:185 >$at_check_line_file
   1226 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   1227 at_status=$?
   1228 grep '^ *+' $at_stder1 >&2
   1229 grep -v '^ *+' $at_stder1 >$at_stderr
   1230 at_failed=false
   1231 echo >>$at_stderr; echo "input.y:8.7-11: %type redeclaration for foo
   1232 input.y:3.7-11: first declaration
   1233 input.y:10.13-17: %destructor redeclaration for foo
   1234 input.y:5.13-17: first declaration
   1235 input.y:9.10-14: %printer redeclaration for foo
   1236 input.y:10.13-17: first declaration
   1237 input.y:11.1-5: %left redeclaration for foo
   1238 input.y:6.1-5: first declaration
   1239 " | $at_diff - $at_stderr || at_failed=:
   1240 $at_diff $at_devnull $at_stdout || at_failed=:
   1241 case $at_status in
   1242    77) echo 77 > $at_status_file
   1243             exit 77;;
   1244    1) ;;
   1245    *) echo "input.at:185: exit code was $at_status, expected 1"
   1246       at_failed=:;;
   1247 esac
   1248 if $at_failed; then
   1249 
   1250   echo 1 > $at_status_file
   1251   exit 1
   1252 fi
   1253 
   1254 $at_traceon
   1255 
   1256 
   1257       $at_traceoff
   1258       $at_times_p && times >$at_times_file
   1259     ) 5>&1 2>&1 | eval $at_tee_pipe
   1260     at_status=`cat $at_status_file`
   1261     ;;
   1262 
   1263   6 ) # 6. input.at:198: Torturing the Scanner
   1264     at_setup_line='input.at:198'
   1265     at_desc='Torturing the Scanner'
   1266     $at_quiet $ECHO_N "  6: Torturing the Scanner                        $ECHO_C"
   1267     at_xfail=no
   1268     (
   1269       echo "6. input.at:198: testing ..."
   1270       $at_traceon
   1271 
   1272 
   1273 
   1274 cat >input.y <<'_ATEOF'
   1275 _ATEOF
   1276 
   1277 $at_traceoff
   1278 echo "input.at:204: bison input.y"
   1279 echo input.at:204 >$at_check_line_file
   1280 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   1281 at_status=$?
   1282 grep '^ *+' $at_stder1 >&2
   1283 grep -v '^ *+' $at_stder1 >$at_stderr
   1284 at_failed=false
   1285 echo >>$at_stderr; echo "input.y:1.1: syntax error, unexpected end of file
   1286 " | $at_diff - $at_stderr || at_failed=:
   1287 $at_diff $at_devnull $at_stdout || at_failed=:
   1288 case $at_status in
   1289    77) echo 77 > $at_status_file
   1290             exit 77;;
   1291    1) ;;
   1292    *) echo "input.at:204: exit code was $at_status, expected 1"
   1293       at_failed=:;;
   1294 esac
   1295 if $at_failed; then
   1296 
   1297   echo 1 > $at_status_file
   1298   exit 1
   1299 fi
   1300 
   1301 $at_traceon
   1302 
   1303 
   1304 
   1305 cat >input.y <<'_ATEOF'
   1306 {}
   1307 _ATEOF
   1308 
   1309 $at_traceoff
   1310 echo "input.at:212: bison input.y"
   1311 echo input.at:212 >$at_check_line_file
   1312 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   1313 at_status=$?
   1314 grep '^ *+' $at_stder1 >&2
   1315 grep -v '^ *+' $at_stder1 >$at_stderr
   1316 at_failed=false
   1317 echo >>$at_stderr; echo "input.y:1.1-2: syntax error, unexpected {...}
   1318 " | $at_diff - $at_stderr || at_failed=:
   1319 $at_diff $at_devnull $at_stdout || at_failed=:
   1320 case $at_status in
   1321    77) echo 77 > $at_status_file
   1322             exit 77;;
   1323    1) ;;
   1324    *) echo "input.at:212: exit code was $at_status, expected 1"
   1325       at_failed=:;;
   1326 esac
   1327 if $at_failed; then
   1328 
   1329   echo 1 > $at_status_file
   1330   exit 1
   1331 fi
   1332 
   1333 $at_traceon
   1334 
   1335 
   1336 
   1337 cat >input.y <<'_ATEOF'
   1338 %{
   1339 #ifdef HAVE_CONFIG_H
   1340 # include <config.h>
   1341   /* We don't need perfect functions for these tests. */
   1342 # undef malloc
   1343 # undef memcmp
   1344 # undef realloc
   1345 #endif
   1346 %}
   1347 
   1348 %{
   1349 /* This is seen in GCC: a %{ and %} in middle of a comment. */
   1350 const char *foo = "So %{ and %} can be here too.";
   1351 
   1352 #if 0
   1353 /* These examples test Bison while not stressing C compilers too much.
   1354    Many C compilers mishandle backslash-newlines, so this part of the
   1355    test is inside "#if 0".  The comment and string are written so that
   1356    the "#endif" will be seen regardless of the C compiler bugs that we
   1357    know about, namely:
   1358 
   1359      HP C (as of late 2002) mishandles *\[newline]\[newline]/ within a
   1360      comment.
   1361 
   1362      The Apple Darwin compiler (as of late 2002) mishandles
   1363      \\[newline]' within a character constant.
   1364 
   1365    */
   1366 
   1367 /\
   1368 * A comment with backslash-newlines in it. %} *\
   1369 \
   1370 /
   1371 /* { Close the above comment, if the C compiler mishandled it.  */
   1372 
   1373 char str[] = "\\
   1374 " A string with backslash-newlines in it %{ %} \\
   1375 \
   1376 "";
   1377 
   1378 char apostrophe = '\'';
   1379 #endif
   1380 
   1381 #include <stdio.h>
   1382 %}
   1383 /* %{ and %} can be here too. */
   1384 
   1385 %{
   1386 /* Exercise pre-prologue dependency to %union.  */
   1387 typedef int value;
   1388 %}
   1389 
   1390 /* Exercise M4 quoting: ']]', 0.  */
   1391 
   1392 /* Also exercise %union. */
   1393 %union
   1394 {
   1395   value ival; /* A comment to exercise an old bug. */
   1396 };
   1397 
   1398 
   1399 /* Exercise post-prologue dependency to %union.  */
   1400 %{
   1401 static YYSTYPE value_as_yystype (value val);
   1402 
   1403 /* Exercise quotes in declarations.  */
   1404 char quote[] = "]],";
   1405 %}
   1406 
   1407 %{
   1408 static void yyerror (const char *s);
   1409 static int yylex (void);
   1410 %}
   1411 
   1412 %type <ival> '['
   1413 
   1414 /* Exercise quotes in strings.  */
   1415 %token FAKE "fake [] \a\b\f\n\r\t\v\"\'\?\\\u005B\U0000005c ??!??'??(??)??-??/??<??=??> \x1\1"
   1416 
   1417 %%
   1418 /* Exercise M4 quoting: ']]', [, 1.  */
   1419 exp: '[' '\1' two '$' '@' '{' oline output.or.oline.opt
   1420   {
   1421     /* Exercise quotes in braces.  */
   1422     char tmp[] = "[%c],\n";
   1423     printf (tmp, $1);
   1424   }
   1425 ;
   1426 
   1427 two: '\x000000000000000000000000000000000000000000000000000000000000000000002';
   1428 oline: '@' 'o' 'l' 'i' 'n' 'e' '@' '_' '_' 'o' 'l' 'i' 'n' 'e' '_' '_';
   1429 output.or.oline.opt: ;|oline;;|output;;;
   1430 output: '#' 'o' 'u' 't' 'p' 'u' 't' ' ';
   1431 %%
   1432 /* Exercise M4 quoting: ']]', [, 2.  */
   1433 
   1434 static YYSTYPE
   1435 value_as_yystype (value val)
   1436 {
   1437   YYSTYPE res;
   1438   res.ival = val;
   1439   return res;
   1440 }
   1441 
   1442 static int
   1443 yylex (void)
   1444 {
   1445   static const char *input = "[\1\2$@{@oline@__oline__\
   1446 #output "; /* "
   1447   */
   1448   yylval = value_as_yystype (*input);
   1449   return *input++;
   1450 }
   1451 
   1452 static void
   1453 yyerror (const char *msg)
   1454 {
   1455   fprintf (stderr, "%s\n", msg);
   1456 }
   1457 _ATEOF
   1458 
   1459 
   1460 
   1461 # Pacify Emacs'font-lock-mode: "
   1462 
   1463 cat >main.c <<'_ATEOF'
   1464 typedef int value;
   1465 #include "input.h"
   1466 
   1467 int yyparse (void);
   1468 
   1469 int
   1470 main (void)
   1471 {
   1472   return yyparse ();
   1473 }
   1474 _ATEOF
   1475 
   1476 
   1477 $at_traceoff
   1478 echo "input.at:342: bison -d -v -o input.c input.y"
   1479 echo input.at:342 >$at_check_line_file
   1480 ( $at_traceon; bison -d -v -o input.c input.y ) >$at_stdout 2>$at_stder1
   1481 at_status=$?
   1482 grep '^ *+' $at_stder1 >&2
   1483 grep -v '^ *+' $at_stder1 >$at_stderr
   1484 at_failed=false
   1485 $at_diff $at_devnull $at_stderr || at_failed=:
   1486 $at_diff $at_devnull $at_stdout || at_failed=:
   1487 case $at_status in
   1488    77) echo 77 > $at_status_file
   1489             exit 77;;
   1490    0) ;;
   1491    *) echo "input.at:342: exit code was $at_status, expected 0"
   1492       at_failed=:;;
   1493 esac
   1494 if $at_failed; then
   1495 
   1496   echo 1 > $at_status_file
   1497   exit 1
   1498 fi
   1499 
   1500 $at_traceon
   1501 
   1502 $at_traceoff
   1503 echo "input.at:343: \$CC \$CFLAGS \$CPPFLAGS -o input.o -c input.c"
   1504 echo input.at:343 >$at_check_line_file
   1505 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -o input.o -c input.c ) >$at_stdout 2>$at_stder1
   1506 at_status=$?
   1507 grep '^ *+' $at_stder1 >&2
   1508 grep -v '^ *+' $at_stder1 >$at_stderr
   1509 at_failed=false
   1510 echo stderr:; cat $at_stderr
   1511 echo stdout:; cat $at_stdout
   1512 case $at_status in
   1513    77) echo 77 > $at_status_file
   1514             exit 77;;
   1515    0) ;;
   1516    *) echo "input.at:343: exit code was $at_status, expected 0"
   1517       at_failed=:;;
   1518 esac
   1519 if $at_failed; then
   1520 
   1521   echo 1 > $at_status_file
   1522   exit 1
   1523 fi
   1524 
   1525 $at_traceon
   1526 
   1527 $at_traceoff
   1528 echo "input.at:344: \$CC \$CFLAGS \$CPPFLAGS -o main.o -c main.c"
   1529 echo input.at:344 >$at_check_line_file
   1530 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -o main.o -c main.c ) >$at_stdout 2>$at_stder1
   1531 at_status=$?
   1532 grep '^ *+' $at_stder1 >&2
   1533 grep -v '^ *+' $at_stder1 >$at_stderr
   1534 at_failed=false
   1535 echo stderr:; cat $at_stderr
   1536 echo stdout:; cat $at_stdout
   1537 case $at_status in
   1538    77) echo 77 > $at_status_file
   1539             exit 77;;
   1540    0) ;;
   1541    *) echo "input.at:344: exit code was $at_status, expected 0"
   1542       at_failed=:;;
   1543 esac
   1544 if $at_failed; then
   1545 
   1546   echo 1 > $at_status_file
   1547   exit 1
   1548 fi
   1549 
   1550 $at_traceon
   1551 
   1552 $at_traceoff
   1553 echo "input.at:345: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.o main.o \$LIBS"
   1554 echo input.at:345 >$at_check_line_file
   1555 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.o main.o $LIBS ) >$at_stdout 2>$at_stder1
   1556 at_status=$?
   1557 grep '^ *+' $at_stder1 >&2
   1558 grep -v '^ *+' $at_stder1 >$at_stderr
   1559 at_failed=false
   1560 echo stderr:; cat $at_stderr
   1561 echo stdout:; cat $at_stdout
   1562 case $at_status in
   1563    77) echo 77 > $at_status_file
   1564             exit 77;;
   1565    0) ;;
   1566    *) echo "input.at:345: exit code was $at_status, expected 0"
   1567       at_failed=:;;
   1568 esac
   1569 if $at_failed; then
   1570 
   1571   echo 1 > $at_status_file
   1572   exit 1
   1573 fi
   1574 
   1575 $at_traceon
   1576 
   1577 $at_traceoff
   1578 echo "input.at:348: \$PREPARSER ./input"
   1579 echo input.at:348 >$at_check_line_file
   1580 ( $at_traceon; $PREPARSER ./input ) >$at_stdout 2>$at_stder1
   1581 at_status=$?
   1582 grep '^ *+' $at_stder1 >&2
   1583 grep -v '^ *+' $at_stder1 >$at_stderr
   1584 at_failed=false
   1585 $at_diff $at_devnull $at_stderr || at_failed=:
   1586 echo >>$at_stdout; echo "[[],
   1587 " | $at_diff - $at_stdout || at_failed=:
   1588 case $at_status in
   1589    77) echo 77 > $at_status_file
   1590             exit 77;;
   1591    0) ;;
   1592    *) echo "input.at:348: exit code was $at_status, expected 0"
   1593       at_failed=:;;
   1594 esac
   1595 if $at_failed; then
   1596 
   1597   echo 1 > $at_status_file
   1598   exit 1
   1599 fi
   1600 
   1601 $at_traceon
   1602 
   1603 
   1604       $at_traceoff
   1605       $at_times_p && times >$at_times_file
   1606     ) 5>&1 2>&1 | eval $at_tee_pipe
   1607     at_status=`cat $at_status_file`
   1608     ;;
   1609 
   1610   7 ) # 7. input.at:357: Typed symbol aliases
   1611     at_setup_line='input.at:357'
   1612     at_desc='Typed symbol aliases'
   1613     $at_quiet $ECHO_N "  7: Typed symbol aliases                         $ECHO_C"
   1614     at_xfail=no
   1615     (
   1616       echo "7. input.at:357: testing ..."
   1617       $at_traceon
   1618 
   1619 
   1620 # Bison 2.0 broke typed symbol aliases - ensure they work.
   1621 
   1622 cat >input.y <<'_ATEOF'
   1623 %{
   1624 #ifdef HAVE_CONFIG_H
   1625 # include <config.h>
   1626   /* We don't need perfect functions for these tests. */
   1627 # undef malloc
   1628 # undef memcmp
   1629 # undef realloc
   1630 #endif
   1631 %}
   1632 
   1633 %union
   1634 {
   1635   int val;
   1636 };
   1637 %token <val> MY_TOKEN "MY TOKEN"
   1638 %type <val> exp
   1639 %%
   1640 exp: "MY TOKEN";
   1641 %%
   1642 _ATEOF
   1643 
   1644 
   1645 
   1646 $at_traceoff
   1647 echo "input.at:373: bison -o input.c input.y"
   1648 echo input.at:373 >$at_check_line_file
   1649 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   1650 at_status=$?
   1651 grep '^ *+' $at_stder1 >&2
   1652 grep -v '^ *+' $at_stder1 >$at_stderr
   1653 at_failed=false
   1654 $at_diff $at_devnull $at_stderr || at_failed=:
   1655 $at_diff $at_devnull $at_stdout || at_failed=:
   1656 case $at_status in
   1657    77) echo 77 > $at_status_file
   1658             exit 77;;
   1659    0) ;;
   1660    *) echo "input.at:373: exit code was $at_status, expected 0"
   1661       at_failed=:;;
   1662 esac
   1663 if $at_failed; then
   1664 
   1665   echo 1 > $at_status_file
   1666   exit 1
   1667 fi
   1668 
   1669 $at_traceon
   1670 
   1671 
   1672       $at_traceoff
   1673       $at_times_p && times >$at_times_file
   1674     ) 5>&1 2>&1 | eval $at_tee_pipe
   1675     at_status=`cat $at_status_file`
   1676     ;;
   1677 
   1678   8 ) # 8. input.at:393: Require 1.0
   1679     at_setup_line='input.at:393'
   1680     at_desc='Require 1.0'
   1681     $at_quiet $ECHO_N "  8: Require 1.0                                  $ECHO_C"
   1682     at_xfail=no
   1683     (
   1684       echo "8. input.at:393: testing ..."
   1685       $at_traceon
   1686 
   1687 cat >input.y <<'_ATEOF'
   1688 %{
   1689 #ifdef HAVE_CONFIG_H
   1690 # include <config.h>
   1691   /* We don't need perfect functions for these tests. */
   1692 # undef malloc
   1693 # undef memcmp
   1694 # undef realloc
   1695 #endif
   1696 %}
   1697 
   1698 %require "1.0";
   1699 %%
   1700 empty_file:;
   1701 _ATEOF
   1702 
   1703 
   1704 $at_traceoff
   1705 echo "input.at:393: bison -o input.c input.y"
   1706 echo input.at:393 >$at_check_line_file
   1707 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   1708 at_status=$?
   1709 grep '^ *+' $at_stder1 >&2
   1710 grep -v '^ *+' $at_stder1 >$at_stderr
   1711 at_failed=false
   1712 echo stderr:; cat $at_stderr
   1713 $at_diff $at_devnull $at_stdout || at_failed=:
   1714 case $at_status in
   1715    77) echo 77 > $at_status_file
   1716             exit 77;;
   1717    0) ;;
   1718    *) echo "input.at:393: exit code was $at_status, expected 0"
   1719       at_failed=:;;
   1720 esac
   1721 if $at_failed; then
   1722 
   1723   echo 1 > $at_status_file
   1724   exit 1
   1725 fi
   1726 
   1727 $at_traceon
   1728 
   1729       $at_traceoff
   1730       $at_times_p && times >$at_times_file
   1731     ) 5>&1 2>&1 | eval $at_tee_pipe
   1732     at_status=`cat $at_status_file`
   1733     ;;
   1734 
   1735   9 ) # 9. input.at:394: Require 2.3
   1736     at_setup_line='input.at:394'
   1737     at_desc='Require 2.3'
   1738     $at_quiet $ECHO_N "  9: Require 2.3                                  $ECHO_C"
   1739     at_xfail=no
   1740     (
   1741       echo "9. input.at:394: testing ..."
   1742       $at_traceon
   1743 
   1744 cat >input.y <<'_ATEOF'
   1745 %{
   1746 #ifdef HAVE_CONFIG_H
   1747 # include <config.h>
   1748   /* We don't need perfect functions for these tests. */
   1749 # undef malloc
   1750 # undef memcmp
   1751 # undef realloc
   1752 #endif
   1753 %}
   1754 
   1755 %require "2.3";
   1756 %%
   1757 empty_file:;
   1758 _ATEOF
   1759 
   1760 
   1761 $at_traceoff
   1762 echo "input.at:394: bison -o input.c input.y"
   1763 echo input.at:394 >$at_check_line_file
   1764 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   1765 at_status=$?
   1766 grep '^ *+' $at_stder1 >&2
   1767 grep -v '^ *+' $at_stder1 >$at_stderr
   1768 at_failed=false
   1769 echo stderr:; cat $at_stderr
   1770 $at_diff $at_devnull $at_stdout || at_failed=:
   1771 case $at_status in
   1772    77) echo 77 > $at_status_file
   1773             exit 77;;
   1774    0) ;;
   1775    *) echo "input.at:394: exit code was $at_status, expected 0"
   1776       at_failed=:;;
   1777 esac
   1778 if $at_failed; then
   1779 
   1780   echo 1 > $at_status_file
   1781   exit 1
   1782 fi
   1783 
   1784 $at_traceon
   1785 
   1786       $at_traceoff
   1787       $at_times_p && times >$at_times_file
   1788     ) 5>&1 2>&1 | eval $at_tee_pipe
   1789     at_status=`cat $at_status_file`
   1790     ;;
   1791 
   1792   10 ) # 10. input.at:396: Require 100.0
   1793     at_setup_line='input.at:396'
   1794     at_desc='Require 100.0'
   1795     $at_quiet $ECHO_N " 10: Require 100.0                                $ECHO_C"
   1796     at_xfail=no
   1797     (
   1798       echo "10. input.at:396: testing ..."
   1799       $at_traceon
   1800 
   1801 cat >input.y <<'_ATEOF'
   1802 %{
   1803 #ifdef HAVE_CONFIG_H
   1804 # include <config.h>
   1805   /* We don't need perfect functions for these tests. */
   1806 # undef malloc
   1807 # undef memcmp
   1808 # undef realloc
   1809 #endif
   1810 %}
   1811 
   1812 %require "100.0";
   1813 %%
   1814 empty_file:;
   1815 _ATEOF
   1816 
   1817 
   1818 $at_traceoff
   1819 echo "input.at:396: bison -o input.c input.y"
   1820 echo input.at:396 >$at_check_line_file
   1821 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   1822 at_status=$?
   1823 grep '^ *+' $at_stder1 >&2
   1824 grep -v '^ *+' $at_stder1 >$at_stderr
   1825 at_failed=false
   1826 echo stderr:; cat $at_stderr
   1827 $at_diff $at_devnull $at_stdout || at_failed=:
   1828 case $at_status in
   1829    77) echo 77 > $at_status_file
   1830             exit 77;;
   1831    63) ;;
   1832    *) echo "input.at:396: exit code was $at_status, expected 63"
   1833       at_failed=:;;
   1834 esac
   1835 if $at_failed; then
   1836 
   1837   echo 1 > $at_status_file
   1838   exit 1
   1839 fi
   1840 
   1841 $at_traceon
   1842 
   1843       $at_traceoff
   1844       $at_times_p && times >$at_times_file
   1845     ) 5>&1 2>&1 | eval $at_tee_pipe
   1846     at_status=`cat $at_status_file`
   1847     ;;
   1848 
   1849 
   1850   banner-2 ) # Banner 2. output.at:19
   1851     cat <<\_ATEOF
   1852 
   1853 Output file names.
   1854 
   1855 _ATEOF
   1856     ;;
   1857 
   1858   11 ) # 11. output.at:43: Output files:  -dv
   1859     at_setup_line='output.at:43'
   1860     at_desc='Output files:  -dv '
   1861     $at_quiet $ECHO_N " 11: Output files:  -dv                           $ECHO_C"
   1862     at_xfail=no
   1863     (
   1864       echo "11. output.at:43: testing ..."
   1865       $at_traceon
   1866 
   1867 case "foo.y" in
   1868   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   1869 esac
   1870 cat >foo.y <<'_ATEOF'
   1871 
   1872 %%
   1873 foo: {};
   1874 _ATEOF
   1875 
   1876 
   1877 $at_traceoff
   1878 echo "output.at:43: bison -dv foo.y "
   1879 echo output.at:43 >$at_check_line_file
   1880 ( $at_traceon; bison -dv foo.y  ) >$at_stdout 2>$at_stder1
   1881 at_status=$?
   1882 grep '^ *+' $at_stder1 >&2
   1883 grep -v '^ *+' $at_stder1 >$at_stderr
   1884 at_failed=false
   1885 $at_diff $at_devnull $at_stderr || at_failed=:
   1886 $at_diff $at_devnull $at_stdout || at_failed=:
   1887 case $at_status in
   1888    77) echo 77 > $at_status_file
   1889             exit 77;;
   1890    0) ;;
   1891    *) echo "output.at:43: exit code was $at_status, expected 0"
   1892       at_failed=:;;
   1893 esac
   1894 if $at_failed; then
   1895 
   1896   echo 1 > $at_status_file
   1897   exit 1
   1898 fi
   1899 
   1900 $at_traceon
   1901 
   1902 $at_traceoff
   1903 echo "output.at:43: ls foo.output foo.tab.c foo.tab.h"
   1904 echo output.at:43 >$at_check_line_file
   1905 ( $at_traceon; ls foo.output foo.tab.c foo.tab.h ) >$at_stdout 2>$at_stder1
   1906 at_status=$?
   1907 grep '^ *+' $at_stder1 >&2
   1908 grep -v '^ *+' $at_stder1 >$at_stderr
   1909 at_failed=false
   1910 $at_diff $at_devnull $at_stderr || at_failed=:
   1911 echo stdout:; cat $at_stdout
   1912 case $at_status in
   1913    77) echo 77 > $at_status_file
   1914             exit 77;;
   1915    0) ;;
   1916    *) echo "output.at:43: exit code was $at_status, expected 0"
   1917       at_failed=:;;
   1918 esac
   1919 if $at_failed; then
   1920 
   1921   echo 1 > $at_status_file
   1922   exit 1
   1923 fi
   1924 
   1925 $at_traceon
   1926 
   1927 
   1928       $at_traceoff
   1929       $at_times_p && times >$at_times_file
   1930     ) 5>&1 2>&1 | eval $at_tee_pipe
   1931     at_status=`cat $at_status_file`
   1932     ;;
   1933 
   1934   12 ) # 12. output.at:46: Output files:  -dv >&-
   1935     at_setup_line='output.at:46'
   1936     at_desc='Output files:  -dv >&-'
   1937     $at_quiet $ECHO_N " 12: Output files:  -dv >&-                       $ECHO_C"
   1938     at_xfail=no
   1939     (
   1940       echo "12. output.at:46: testing ..."
   1941       $at_traceon
   1942 
   1943 case "foo.y" in
   1944   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   1945 esac
   1946 cat >foo.y <<'_ATEOF'
   1947 
   1948 %%
   1949 foo: {};
   1950 _ATEOF
   1951 
   1952 
   1953 $at_traceoff
   1954 echo "output.at:46: bison -dv foo.y >&-"
   1955 echo output.at:46 >$at_check_line_file
   1956 ( $at_traceon; bison -dv foo.y >&- ) >$at_stdout 2>$at_stder1
   1957 at_status=$?
   1958 grep '^ *+' $at_stder1 >&2
   1959 grep -v '^ *+' $at_stder1 >$at_stderr
   1960 at_failed=false
   1961 $at_diff $at_devnull $at_stderr || at_failed=:
   1962 $at_diff $at_devnull $at_stdout || at_failed=:
   1963 case $at_status in
   1964    77) echo 77 > $at_status_file
   1965             exit 77;;
   1966    0) ;;
   1967    *) echo "output.at:46: exit code was $at_status, expected 0"
   1968       at_failed=:;;
   1969 esac
   1970 if $at_failed; then
   1971 
   1972   echo 1 > $at_status_file
   1973   exit 1
   1974 fi
   1975 
   1976 $at_traceon
   1977 
   1978 $at_traceoff
   1979 echo "output.at:46: ls foo.output foo.tab.c foo.tab.h"
   1980 echo output.at:46 >$at_check_line_file
   1981 ( $at_traceon; ls foo.output foo.tab.c foo.tab.h ) >$at_stdout 2>$at_stder1
   1982 at_status=$?
   1983 grep '^ *+' $at_stder1 >&2
   1984 grep -v '^ *+' $at_stder1 >$at_stderr
   1985 at_failed=false
   1986 $at_diff $at_devnull $at_stderr || at_failed=:
   1987 echo stdout:; cat $at_stdout
   1988 case $at_status in
   1989    77) echo 77 > $at_status_file
   1990             exit 77;;
   1991    0) ;;
   1992    *) echo "output.at:46: exit code was $at_status, expected 0"
   1993       at_failed=:;;
   1994 esac
   1995 if $at_failed; then
   1996 
   1997   echo 1 > $at_status_file
   1998   exit 1
   1999 fi
   2000 
   2001 $at_traceon
   2002 
   2003 
   2004       $at_traceoff
   2005       $at_times_p && times >$at_times_file
   2006     ) 5>&1 2>&1 | eval $at_tee_pipe
   2007     at_status=`cat $at_status_file`
   2008     ;;
   2009 
   2010   13 ) # 13. output.at:48: Output files:  -dv -o foo.c
   2011     at_setup_line='output.at:48'
   2012     at_desc='Output files:  -dv -o foo.c '
   2013     $at_quiet $ECHO_N " 13: Output files:  -dv -o foo.c                  $ECHO_C"
   2014     at_xfail=no
   2015     (
   2016       echo "13. output.at:48: testing ..."
   2017       $at_traceon
   2018 
   2019 case "foo.y" in
   2020   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2021 esac
   2022 cat >foo.y <<'_ATEOF'
   2023 
   2024 %%
   2025 foo: {};
   2026 _ATEOF
   2027 
   2028 
   2029 $at_traceoff
   2030 echo "output.at:48: bison -dv -o foo.c foo.y "
   2031 echo output.at:48 >$at_check_line_file
   2032 ( $at_traceon; bison -dv -o foo.c foo.y  ) >$at_stdout 2>$at_stder1
   2033 at_status=$?
   2034 grep '^ *+' $at_stder1 >&2
   2035 grep -v '^ *+' $at_stder1 >$at_stderr
   2036 at_failed=false
   2037 $at_diff $at_devnull $at_stderr || at_failed=:
   2038 $at_diff $at_devnull $at_stdout || at_failed=:
   2039 case $at_status in
   2040    77) echo 77 > $at_status_file
   2041             exit 77;;
   2042    0) ;;
   2043    *) echo "output.at:48: exit code was $at_status, expected 0"
   2044       at_failed=:;;
   2045 esac
   2046 if $at_failed; then
   2047 
   2048   echo 1 > $at_status_file
   2049   exit 1
   2050 fi
   2051 
   2052 $at_traceon
   2053 
   2054 $at_traceoff
   2055 echo "output.at:48: ls foo.c foo.h foo.output"
   2056 echo output.at:48 >$at_check_line_file
   2057 ( $at_traceon; ls foo.c foo.h foo.output ) >$at_stdout 2>$at_stder1
   2058 at_status=$?
   2059 grep '^ *+' $at_stder1 >&2
   2060 grep -v '^ *+' $at_stder1 >$at_stderr
   2061 at_failed=false
   2062 $at_diff $at_devnull $at_stderr || at_failed=:
   2063 echo stdout:; cat $at_stdout
   2064 case $at_status in
   2065    77) echo 77 > $at_status_file
   2066             exit 77;;
   2067    0) ;;
   2068    *) echo "output.at:48: exit code was $at_status, expected 0"
   2069       at_failed=:;;
   2070 esac
   2071 if $at_failed; then
   2072 
   2073   echo 1 > $at_status_file
   2074   exit 1
   2075 fi
   2076 
   2077 $at_traceon
   2078 
   2079 
   2080       $at_traceoff
   2081       $at_times_p && times >$at_times_file
   2082     ) 5>&1 2>&1 | eval $at_tee_pipe
   2083     at_status=`cat $at_status_file`
   2084     ;;
   2085 
   2086   14 ) # 14. output.at:50: Output files:  -dv -o foo.tab.c
   2087     at_setup_line='output.at:50'
   2088     at_desc='Output files:  -dv -o foo.tab.c '
   2089     $at_quiet $ECHO_N " 14: Output files:  -dv -o foo.tab.c              $ECHO_C"
   2090     at_xfail=no
   2091     (
   2092       echo "14. output.at:50: testing ..."
   2093       $at_traceon
   2094 
   2095 case "foo.y" in
   2096   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2097 esac
   2098 cat >foo.y <<'_ATEOF'
   2099 
   2100 %%
   2101 foo: {};
   2102 _ATEOF
   2103 
   2104 
   2105 $at_traceoff
   2106 echo "output.at:50: bison -dv -o foo.tab.c foo.y "
   2107 echo output.at:50 >$at_check_line_file
   2108 ( $at_traceon; bison -dv -o foo.tab.c foo.y  ) >$at_stdout 2>$at_stder1
   2109 at_status=$?
   2110 grep '^ *+' $at_stder1 >&2
   2111 grep -v '^ *+' $at_stder1 >$at_stderr
   2112 at_failed=false
   2113 $at_diff $at_devnull $at_stderr || at_failed=:
   2114 $at_diff $at_devnull $at_stdout || at_failed=:
   2115 case $at_status in
   2116    77) echo 77 > $at_status_file
   2117             exit 77;;
   2118    0) ;;
   2119    *) echo "output.at:50: exit code was $at_status, expected 0"
   2120       at_failed=:;;
   2121 esac
   2122 if $at_failed; then
   2123 
   2124   echo 1 > $at_status_file
   2125   exit 1
   2126 fi
   2127 
   2128 $at_traceon
   2129 
   2130 $at_traceoff
   2131 echo "output.at:50: ls foo.output foo.tab.c foo.tab.h"
   2132 echo output.at:50 >$at_check_line_file
   2133 ( $at_traceon; ls foo.output foo.tab.c foo.tab.h ) >$at_stdout 2>$at_stder1
   2134 at_status=$?
   2135 grep '^ *+' $at_stder1 >&2
   2136 grep -v '^ *+' $at_stder1 >$at_stderr
   2137 at_failed=false
   2138 $at_diff $at_devnull $at_stderr || at_failed=:
   2139 echo stdout:; cat $at_stdout
   2140 case $at_status in
   2141    77) echo 77 > $at_status_file
   2142             exit 77;;
   2143    0) ;;
   2144    *) echo "output.at:50: exit code was $at_status, expected 0"
   2145       at_failed=:;;
   2146 esac
   2147 if $at_failed; then
   2148 
   2149   echo 1 > $at_status_file
   2150   exit 1
   2151 fi
   2152 
   2153 $at_traceon
   2154 
   2155 
   2156       $at_traceoff
   2157       $at_times_p && times >$at_times_file
   2158     ) 5>&1 2>&1 | eval $at_tee_pipe
   2159     at_status=`cat $at_status_file`
   2160     ;;
   2161 
   2162   15 ) # 15. output.at:52: Output files:  -dv -y
   2163     at_setup_line='output.at:52'
   2164     at_desc='Output files:  -dv -y '
   2165     $at_quiet $ECHO_N " 15: Output files:  -dv -y                        $ECHO_C"
   2166     at_xfail=no
   2167     (
   2168       echo "15. output.at:52: testing ..."
   2169       $at_traceon
   2170 
   2171 case "foo.y" in
   2172   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2173 esac
   2174 cat >foo.y <<'_ATEOF'
   2175 
   2176 %%
   2177 foo: {};
   2178 _ATEOF
   2179 
   2180 
   2181 $at_traceoff
   2182 echo "output.at:52: bison -dv -y foo.y "
   2183 echo output.at:52 >$at_check_line_file
   2184 ( $at_traceon; bison -dv -y foo.y  ) >$at_stdout 2>$at_stder1
   2185 at_status=$?
   2186 grep '^ *+' $at_stder1 >&2
   2187 grep -v '^ *+' $at_stder1 >$at_stderr
   2188 at_failed=false
   2189 $at_diff $at_devnull $at_stderr || at_failed=:
   2190 $at_diff $at_devnull $at_stdout || at_failed=:
   2191 case $at_status in
   2192    77) echo 77 > $at_status_file
   2193             exit 77;;
   2194    0) ;;
   2195    *) echo "output.at:52: exit code was $at_status, expected 0"
   2196       at_failed=:;;
   2197 esac
   2198 if $at_failed; then
   2199 
   2200   echo 1 > $at_status_file
   2201   exit 1
   2202 fi
   2203 
   2204 $at_traceon
   2205 
   2206 $at_traceoff
   2207 echo "output.at:52: ls y.output y.tab.c y.tab.h"
   2208 echo output.at:52 >$at_check_line_file
   2209 ( $at_traceon; ls y.output y.tab.c y.tab.h ) >$at_stdout 2>$at_stder1
   2210 at_status=$?
   2211 grep '^ *+' $at_stder1 >&2
   2212 grep -v '^ *+' $at_stder1 >$at_stderr
   2213 at_failed=false
   2214 $at_diff $at_devnull $at_stderr || at_failed=:
   2215 echo stdout:; cat $at_stdout
   2216 case $at_status in
   2217    77) echo 77 > $at_status_file
   2218             exit 77;;
   2219    0) ;;
   2220    *) echo "output.at:52: exit code was $at_status, expected 0"
   2221       at_failed=:;;
   2222 esac
   2223 if $at_failed; then
   2224 
   2225   echo 1 > $at_status_file
   2226   exit 1
   2227 fi
   2228 
   2229 $at_traceon
   2230 
   2231 
   2232       $at_traceoff
   2233       $at_times_p && times >$at_times_file
   2234     ) 5>&1 2>&1 | eval $at_tee_pipe
   2235     at_status=`cat $at_status_file`
   2236     ;;
   2237 
   2238   16 ) # 16. output.at:54: Output files:  -dv -b bar
   2239     at_setup_line='output.at:54'
   2240     at_desc='Output files:  -dv -b bar '
   2241     $at_quiet $ECHO_N " 16: Output files:  -dv -b bar                    $ECHO_C"
   2242     at_xfail=no
   2243     (
   2244       echo "16. output.at:54: testing ..."
   2245       $at_traceon
   2246 
   2247 case "foo.y" in
   2248   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2249 esac
   2250 cat >foo.y <<'_ATEOF'
   2251 
   2252 %%
   2253 foo: {};
   2254 _ATEOF
   2255 
   2256 
   2257 $at_traceoff
   2258 echo "output.at:54: bison -dv -b bar foo.y "
   2259 echo output.at:54 >$at_check_line_file
   2260 ( $at_traceon; bison -dv -b bar foo.y  ) >$at_stdout 2>$at_stder1
   2261 at_status=$?
   2262 grep '^ *+' $at_stder1 >&2
   2263 grep -v '^ *+' $at_stder1 >$at_stderr
   2264 at_failed=false
   2265 $at_diff $at_devnull $at_stderr || at_failed=:
   2266 $at_diff $at_devnull $at_stdout || at_failed=:
   2267 case $at_status in
   2268    77) echo 77 > $at_status_file
   2269             exit 77;;
   2270    0) ;;
   2271    *) echo "output.at:54: exit code was $at_status, expected 0"
   2272       at_failed=:;;
   2273 esac
   2274 if $at_failed; then
   2275 
   2276   echo 1 > $at_status_file
   2277   exit 1
   2278 fi
   2279 
   2280 $at_traceon
   2281 
   2282 $at_traceoff
   2283 echo "output.at:54: ls bar.output bar.tab.c bar.tab.h"
   2284 echo output.at:54 >$at_check_line_file
   2285 ( $at_traceon; ls bar.output bar.tab.c bar.tab.h ) >$at_stdout 2>$at_stder1
   2286 at_status=$?
   2287 grep '^ *+' $at_stder1 >&2
   2288 grep -v '^ *+' $at_stder1 >$at_stderr
   2289 at_failed=false
   2290 $at_diff $at_devnull $at_stderr || at_failed=:
   2291 echo stdout:; cat $at_stdout
   2292 case $at_status in
   2293    77) echo 77 > $at_status_file
   2294             exit 77;;
   2295    0) ;;
   2296    *) echo "output.at:54: exit code was $at_status, expected 0"
   2297       at_failed=:;;
   2298 esac
   2299 if $at_failed; then
   2300 
   2301   echo 1 > $at_status_file
   2302   exit 1
   2303 fi
   2304 
   2305 $at_traceon
   2306 
   2307 
   2308       $at_traceoff
   2309       $at_times_p && times >$at_times_file
   2310     ) 5>&1 2>&1 | eval $at_tee_pipe
   2311     at_status=`cat $at_status_file`
   2312     ;;
   2313 
   2314   17 ) # 17. output.at:56: Output files:  -dv -g -o foo.c
   2315     at_setup_line='output.at:56'
   2316     at_desc='Output files:  -dv -g -o foo.c '
   2317     $at_quiet $ECHO_N " 17: Output files:  -dv -g -o foo.c               $ECHO_C"
   2318     at_xfail=no
   2319     (
   2320       echo "17. output.at:56: testing ..."
   2321       $at_traceon
   2322 
   2323 case "foo.y" in
   2324   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2325 esac
   2326 cat >foo.y <<'_ATEOF'
   2327 
   2328 %%
   2329 foo: {};
   2330 _ATEOF
   2331 
   2332 
   2333 $at_traceoff
   2334 echo "output.at:56: bison -dv -g -o foo.c foo.y "
   2335 echo output.at:56 >$at_check_line_file
   2336 ( $at_traceon; bison -dv -g -o foo.c foo.y  ) >$at_stdout 2>$at_stder1
   2337 at_status=$?
   2338 grep '^ *+' $at_stder1 >&2
   2339 grep -v '^ *+' $at_stder1 >$at_stderr
   2340 at_failed=false
   2341 $at_diff $at_devnull $at_stderr || at_failed=:
   2342 $at_diff $at_devnull $at_stdout || at_failed=:
   2343 case $at_status in
   2344    77) echo 77 > $at_status_file
   2345             exit 77;;
   2346    0) ;;
   2347    *) echo "output.at:56: exit code was $at_status, expected 0"
   2348       at_failed=:;;
   2349 esac
   2350 if $at_failed; then
   2351 
   2352   echo 1 > $at_status_file
   2353   exit 1
   2354 fi
   2355 
   2356 $at_traceon
   2357 
   2358 $at_traceoff
   2359 echo "output.at:56: ls foo.c foo.h foo.output foo.vcg"
   2360 echo output.at:56 >$at_check_line_file
   2361 ( $at_traceon; ls foo.c foo.h foo.output foo.vcg ) >$at_stdout 2>$at_stder1
   2362 at_status=$?
   2363 grep '^ *+' $at_stder1 >&2
   2364 grep -v '^ *+' $at_stder1 >$at_stderr
   2365 at_failed=false
   2366 $at_diff $at_devnull $at_stderr || at_failed=:
   2367 echo stdout:; cat $at_stdout
   2368 case $at_status in
   2369    77) echo 77 > $at_status_file
   2370             exit 77;;
   2371    0) ;;
   2372    *) echo "output.at:56: exit code was $at_status, expected 0"
   2373       at_failed=:;;
   2374 esac
   2375 if $at_failed; then
   2376 
   2377   echo 1 > $at_status_file
   2378   exit 1
   2379 fi
   2380 
   2381 $at_traceon
   2382 
   2383 
   2384       $at_traceoff
   2385       $at_times_p && times >$at_times_file
   2386     ) 5>&1 2>&1 | eval $at_tee_pipe
   2387     at_status=`cat $at_status_file`
   2388     ;;
   2389 
   2390   18 ) # 18. output.at:60: Output files: %defines %verbose
   2391     at_setup_line='output.at:60'
   2392     at_desc='Output files: %defines %verbose  '
   2393     $at_quiet $ECHO_N " 18: Output files: %defines %verbose              $ECHO_C"
   2394     at_xfail=no
   2395     (
   2396       echo "18. output.at:60: testing ..."
   2397       $at_traceon
   2398 
   2399 case "foo.y" in
   2400   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2401 esac
   2402 cat >foo.y <<'_ATEOF'
   2403 %defines %verbose
   2404 %%
   2405 foo: {};
   2406 _ATEOF
   2407 
   2408 
   2409 $at_traceoff
   2410 echo "output.at:60: bison  foo.y "
   2411 echo output.at:60 >$at_check_line_file
   2412 ( $at_traceon; bison  foo.y  ) >$at_stdout 2>$at_stder1
   2413 at_status=$?
   2414 grep '^ *+' $at_stder1 >&2
   2415 grep -v '^ *+' $at_stder1 >$at_stderr
   2416 at_failed=false
   2417 $at_diff $at_devnull $at_stderr || at_failed=:
   2418 $at_diff $at_devnull $at_stdout || at_failed=:
   2419 case $at_status in
   2420    77) echo 77 > $at_status_file
   2421             exit 77;;
   2422    0) ;;
   2423    *) echo "output.at:60: exit code was $at_status, expected 0"
   2424       at_failed=:;;
   2425 esac
   2426 if $at_failed; then
   2427 
   2428   echo 1 > $at_status_file
   2429   exit 1
   2430 fi
   2431 
   2432 $at_traceon
   2433 
   2434 $at_traceoff
   2435 echo "output.at:60: ls foo.output foo.tab.c foo.tab.h"
   2436 echo output.at:60 >$at_check_line_file
   2437 ( $at_traceon; ls foo.output foo.tab.c foo.tab.h ) >$at_stdout 2>$at_stder1
   2438 at_status=$?
   2439 grep '^ *+' $at_stder1 >&2
   2440 grep -v '^ *+' $at_stder1 >$at_stderr
   2441 at_failed=false
   2442 $at_diff $at_devnull $at_stderr || at_failed=:
   2443 echo stdout:; cat $at_stdout
   2444 case $at_status in
   2445    77) echo 77 > $at_status_file
   2446             exit 77;;
   2447    0) ;;
   2448    *) echo "output.at:60: exit code was $at_status, expected 0"
   2449       at_failed=:;;
   2450 esac
   2451 if $at_failed; then
   2452 
   2453   echo 1 > $at_status_file
   2454   exit 1
   2455 fi
   2456 
   2457 $at_traceon
   2458 
   2459 
   2460       $at_traceoff
   2461       $at_times_p && times >$at_times_file
   2462     ) 5>&1 2>&1 | eval $at_tee_pipe
   2463     at_status=`cat $at_status_file`
   2464     ;;
   2465 
   2466   19 ) # 19. output.at:62: Output files: %defines %verbose %yacc
   2467     at_setup_line='output.at:62'
   2468     at_desc='Output files: %defines %verbose %yacc  '
   2469     $at_quiet $ECHO_N " 19: Output files: %defines %verbose %yacc        $ECHO_C"
   2470     at_xfail=no
   2471     (
   2472       echo "19. output.at:62: testing ..."
   2473       $at_traceon
   2474 
   2475 case "foo.y" in
   2476   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2477 esac
   2478 cat >foo.y <<'_ATEOF'
   2479 %defines %verbose %yacc
   2480 %%
   2481 foo: {};
   2482 _ATEOF
   2483 
   2484 
   2485 $at_traceoff
   2486 echo "output.at:62: bison  foo.y "
   2487 echo output.at:62 >$at_check_line_file
   2488 ( $at_traceon; bison  foo.y  ) >$at_stdout 2>$at_stder1
   2489 at_status=$?
   2490 grep '^ *+' $at_stder1 >&2
   2491 grep -v '^ *+' $at_stder1 >$at_stderr
   2492 at_failed=false
   2493 $at_diff $at_devnull $at_stderr || at_failed=:
   2494 $at_diff $at_devnull $at_stdout || at_failed=:
   2495 case $at_status in
   2496    77) echo 77 > $at_status_file
   2497             exit 77;;
   2498    0) ;;
   2499    *) echo "output.at:62: exit code was $at_status, expected 0"
   2500       at_failed=:;;
   2501 esac
   2502 if $at_failed; then
   2503 
   2504   echo 1 > $at_status_file
   2505   exit 1
   2506 fi
   2507 
   2508 $at_traceon
   2509 
   2510 $at_traceoff
   2511 echo "output.at:62: ls y.output y.tab.c y.tab.h"
   2512 echo output.at:62 >$at_check_line_file
   2513 ( $at_traceon; ls y.output y.tab.c y.tab.h ) >$at_stdout 2>$at_stder1
   2514 at_status=$?
   2515 grep '^ *+' $at_stder1 >&2
   2516 grep -v '^ *+' $at_stder1 >$at_stderr
   2517 at_failed=false
   2518 $at_diff $at_devnull $at_stderr || at_failed=:
   2519 echo stdout:; cat $at_stdout
   2520 case $at_status in
   2521    77) echo 77 > $at_status_file
   2522             exit 77;;
   2523    0) ;;
   2524    *) echo "output.at:62: exit code was $at_status, expected 0"
   2525       at_failed=:;;
   2526 esac
   2527 if $at_failed; then
   2528 
   2529   echo 1 > $at_status_file
   2530   exit 1
   2531 fi
   2532 
   2533 $at_traceon
   2534 
   2535 
   2536       $at_traceoff
   2537       $at_times_p && times >$at_times_file
   2538     ) 5>&1 2>&1 | eval $at_tee_pipe
   2539     at_status=`cat $at_status_file`
   2540     ;;
   2541 
   2542   20 ) # 20. output.at:65: Output files: %defines %verbose %yacc
   2543     at_setup_line='output.at:65'
   2544     at_desc='Output files: %defines %verbose %yacc  '
   2545     $at_quiet $ECHO_N " 20: Output files: %defines %verbose %yacc        $ECHO_C"
   2546     at_xfail=no
   2547     (
   2548       echo "20. output.at:65: testing ..."
   2549       $at_traceon
   2550 
   2551 case "foo.yy" in
   2552   */*) mkdir `echo "foo.yy" | sed 's,/.*,,'`;;
   2553 esac
   2554 cat >foo.yy <<'_ATEOF'
   2555 %defines %verbose %yacc
   2556 %%
   2557 foo: {};
   2558 _ATEOF
   2559 
   2560 
   2561 $at_traceoff
   2562 echo "output.at:65: bison  foo.yy "
   2563 echo output.at:65 >$at_check_line_file
   2564 ( $at_traceon; bison  foo.yy  ) >$at_stdout 2>$at_stder1
   2565 at_status=$?
   2566 grep '^ *+' $at_stder1 >&2
   2567 grep -v '^ *+' $at_stder1 >$at_stderr
   2568 at_failed=false
   2569 $at_diff $at_devnull $at_stderr || at_failed=:
   2570 $at_diff $at_devnull $at_stdout || at_failed=:
   2571 case $at_status in
   2572    77) echo 77 > $at_status_file
   2573             exit 77;;
   2574    0) ;;
   2575    *) echo "output.at:65: exit code was $at_status, expected 0"
   2576       at_failed=:;;
   2577 esac
   2578 if $at_failed; then
   2579 
   2580   echo 1 > $at_status_file
   2581   exit 1
   2582 fi
   2583 
   2584 $at_traceon
   2585 
   2586 $at_traceoff
   2587 echo "output.at:65: ls y.output y.tab.c y.tab.h"
   2588 echo output.at:65 >$at_check_line_file
   2589 ( $at_traceon; ls y.output y.tab.c y.tab.h ) >$at_stdout 2>$at_stder1
   2590 at_status=$?
   2591 grep '^ *+' $at_stder1 >&2
   2592 grep -v '^ *+' $at_stder1 >$at_stderr
   2593 at_failed=false
   2594 $at_diff $at_devnull $at_stderr || at_failed=:
   2595 echo stdout:; cat $at_stdout
   2596 case $at_status in
   2597    77) echo 77 > $at_status_file
   2598             exit 77;;
   2599    0) ;;
   2600    *) echo "output.at:65: exit code was $at_status, expected 0"
   2601       at_failed=:;;
   2602 esac
   2603 if $at_failed; then
   2604 
   2605   echo 1 > $at_status_file
   2606   exit 1
   2607 fi
   2608 
   2609 $at_traceon
   2610 
   2611 
   2612       $at_traceoff
   2613       $at_times_p && times >$at_times_file
   2614     ) 5>&1 2>&1 | eval $at_tee_pipe
   2615     at_status=`cat $at_status_file`
   2616     ;;
   2617 
   2618   21 ) # 21. output.at:69: Output files: %file-prefix="bar" %defines %verbose
   2619     at_setup_line='output.at:69'
   2620     at_desc='Output files: %file-prefix="bar" %defines %verbose  '
   2621     $at_quiet $ECHO_N " 21: Output files: %file-prefix="bar" %defines %verbose  $ECHO_C"
   2622     at_xfail=no
   2623     (
   2624       echo "21. output.at:69: testing ..."
   2625       $at_traceon
   2626 
   2627 case "foo.y" in
   2628   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2629 esac
   2630 cat >foo.y <<'_ATEOF'
   2631 %file-prefix="bar" %defines %verbose
   2632 %%
   2633 foo: {};
   2634 _ATEOF
   2635 
   2636 
   2637 $at_traceoff
   2638 echo "output.at:69: bison  foo.y "
   2639 echo output.at:69 >$at_check_line_file
   2640 ( $at_traceon; bison  foo.y  ) >$at_stdout 2>$at_stder1
   2641 at_status=$?
   2642 grep '^ *+' $at_stder1 >&2
   2643 grep -v '^ *+' $at_stder1 >$at_stderr
   2644 at_failed=false
   2645 $at_diff $at_devnull $at_stderr || at_failed=:
   2646 $at_diff $at_devnull $at_stdout || at_failed=:
   2647 case $at_status in
   2648    77) echo 77 > $at_status_file
   2649             exit 77;;
   2650    0) ;;
   2651    *) echo "output.at:69: exit code was $at_status, expected 0"
   2652       at_failed=:;;
   2653 esac
   2654 if $at_failed; then
   2655 
   2656   echo 1 > $at_status_file
   2657   exit 1
   2658 fi
   2659 
   2660 $at_traceon
   2661 
   2662 $at_traceoff
   2663 echo "output.at:69: ls bar.output bar.tab.c bar.tab.h"
   2664 echo output.at:69 >$at_check_line_file
   2665 ( $at_traceon; ls bar.output bar.tab.c bar.tab.h ) >$at_stdout 2>$at_stder1
   2666 at_status=$?
   2667 grep '^ *+' $at_stder1 >&2
   2668 grep -v '^ *+' $at_stder1 >$at_stderr
   2669 at_failed=false
   2670 $at_diff $at_devnull $at_stderr || at_failed=:
   2671 echo stdout:; cat $at_stdout
   2672 case $at_status in
   2673    77) echo 77 > $at_status_file
   2674             exit 77;;
   2675    0) ;;
   2676    *) echo "output.at:69: exit code was $at_status, expected 0"
   2677       at_failed=:;;
   2678 esac
   2679 if $at_failed; then
   2680 
   2681   echo 1 > $at_status_file
   2682   exit 1
   2683 fi
   2684 
   2685 $at_traceon
   2686 
   2687 
   2688       $at_traceoff
   2689       $at_times_p && times >$at_times_file
   2690     ) 5>&1 2>&1 | eval $at_tee_pipe
   2691     at_status=`cat $at_status_file`
   2692     ;;
   2693 
   2694   22 ) # 22. output.at:71: Output files: %output="bar.c" %defines %verbose %yacc
   2695     at_setup_line='output.at:71'
   2696     at_desc='Output files: %output="bar.c" %defines %verbose %yacc  '
   2697     $at_quiet $ECHO_N " 22: Output files: %output="bar.c" %defines %verbose %yacc  $ECHO_C"
   2698     at_xfail=no
   2699     (
   2700       echo "22. output.at:71: testing ..."
   2701       $at_traceon
   2702 
   2703 case "foo.y" in
   2704   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2705 esac
   2706 cat >foo.y <<'_ATEOF'
   2707 %output="bar.c" %defines %verbose %yacc
   2708 %%
   2709 foo: {};
   2710 _ATEOF
   2711 
   2712 
   2713 $at_traceoff
   2714 echo "output.at:71: bison  foo.y "
   2715 echo output.at:71 >$at_check_line_file
   2716 ( $at_traceon; bison  foo.y  ) >$at_stdout 2>$at_stder1
   2717 at_status=$?
   2718 grep '^ *+' $at_stder1 >&2
   2719 grep -v '^ *+' $at_stder1 >$at_stderr
   2720 at_failed=false
   2721 $at_diff $at_devnull $at_stderr || at_failed=:
   2722 $at_diff $at_devnull $at_stdout || at_failed=:
   2723 case $at_status in
   2724    77) echo 77 > $at_status_file
   2725             exit 77;;
   2726    0) ;;
   2727    *) echo "output.at:71: exit code was $at_status, expected 0"
   2728       at_failed=:;;
   2729 esac
   2730 if $at_failed; then
   2731 
   2732   echo 1 > $at_status_file
   2733   exit 1
   2734 fi
   2735 
   2736 $at_traceon
   2737 
   2738 $at_traceoff
   2739 echo "output.at:71: ls bar.output bar.c bar.h"
   2740 echo output.at:71 >$at_check_line_file
   2741 ( $at_traceon; ls bar.output bar.c bar.h ) >$at_stdout 2>$at_stder1
   2742 at_status=$?
   2743 grep '^ *+' $at_stder1 >&2
   2744 grep -v '^ *+' $at_stder1 >$at_stderr
   2745 at_failed=false
   2746 $at_diff $at_devnull $at_stderr || at_failed=:
   2747 echo stdout:; cat $at_stdout
   2748 case $at_status in
   2749    77) echo 77 > $at_status_file
   2750             exit 77;;
   2751    0) ;;
   2752    *) echo "output.at:71: exit code was $at_status, expected 0"
   2753       at_failed=:;;
   2754 esac
   2755 if $at_failed; then
   2756 
   2757   echo 1 > $at_status_file
   2758   exit 1
   2759 fi
   2760 
   2761 $at_traceon
   2762 
   2763 
   2764       $at_traceoff
   2765       $at_times_p && times >$at_times_file
   2766     ) 5>&1 2>&1 | eval $at_tee_pipe
   2767     at_status=`cat $at_status_file`
   2768     ;;
   2769 
   2770   23 ) # 23. output.at:75: Output files: %file-prefix="baz" %output="bar.c" %defines %verbose %yacc
   2771     at_setup_line='output.at:75'
   2772     at_desc='Output files: %file-prefix="baz" %output="bar.c" %defines %verbose %yacc  '
   2773     $at_quiet $ECHO_N " 23: Output files: %file-prefix="baz" %output="bar.c" %defines %verbose %yacc  $ECHO_C"
   2774     at_xfail=no
   2775     (
   2776       echo "23. output.at:75: testing ..."
   2777       $at_traceon
   2778 
   2779 case "foo.y" in
   2780   */*) mkdir `echo "foo.y" | sed 's,/.*,,'`;;
   2781 esac
   2782 cat >foo.y <<'_ATEOF'
   2783 %file-prefix="baz" %output="bar.c" %defines %verbose %yacc
   2784 %%
   2785 foo: {};
   2786 _ATEOF
   2787 
   2788 
   2789 $at_traceoff
   2790 echo "output.at:75: bison  foo.y "
   2791 echo output.at:75 >$at_check_line_file
   2792 ( $at_traceon; bison  foo.y  ) >$at_stdout 2>$at_stder1
   2793 at_status=$?
   2794 grep '^ *+' $at_stder1 >&2
   2795 grep -v '^ *+' $at_stder1 >$at_stderr
   2796 at_failed=false
   2797 $at_diff $at_devnull $at_stderr || at_failed=:
   2798 $at_diff $at_devnull $at_stdout || at_failed=:
   2799 case $at_status in
   2800    77) echo 77 > $at_status_file
   2801             exit 77;;
   2802    0) ;;
   2803    *) echo "output.at:75: exit code was $at_status, expected 0"
   2804       at_failed=:;;
   2805 esac
   2806 if $at_failed; then
   2807 
   2808   echo 1 > $at_status_file
   2809   exit 1
   2810 fi
   2811 
   2812 $at_traceon
   2813 
   2814 $at_traceoff
   2815 echo "output.at:75: ls bar.output bar.c bar.h"
   2816 echo output.at:75 >$at_check_line_file
   2817 ( $at_traceon; ls bar.output bar.c bar.h ) >$at_stdout 2>$at_stder1
   2818 at_status=$?
   2819 grep '^ *+' $at_stder1 >&2
   2820 grep -v '^ *+' $at_stder1 >$at_stderr
   2821 at_failed=false
   2822 $at_diff $at_devnull $at_stderr || at_failed=:
   2823 echo stdout:; cat $at_stdout
   2824 case $at_status in
   2825    77) echo 77 > $at_status_file
   2826             exit 77;;
   2827    0) ;;
   2828    *) echo "output.at:75: exit code was $at_status, expected 0"
   2829       at_failed=:;;
   2830 esac
   2831 if $at_failed; then
   2832 
   2833   echo 1 > $at_status_file
   2834   exit 1
   2835 fi
   2836 
   2837 $at_traceon
   2838 
   2839 
   2840       $at_traceoff
   2841       $at_times_p && times >$at_times_file
   2842     ) 5>&1 2>&1 | eval $at_tee_pipe
   2843     at_status=`cat $at_status_file`
   2844     ;;
   2845 
   2846   24 ) # 24. output.at:80: Output files: %defines %verbose
   2847     at_setup_line='output.at:80'
   2848     at_desc='Output files: %defines %verbose  '
   2849     $at_quiet $ECHO_N " 24: Output files: %defines %verbose              $ECHO_C"
   2850     at_xfail=no
   2851     (
   2852       echo "24. output.at:80: testing ..."
   2853       $at_traceon
   2854 
   2855 case "foo.yy" in
   2856   */*) mkdir `echo "foo.yy" | sed 's,/.*,,'`;;
   2857 esac
   2858 cat >foo.yy <<'_ATEOF'
   2859 %defines %verbose
   2860 %%
   2861 foo: {};
   2862 _ATEOF
   2863 
   2864 
   2865 $at_traceoff
   2866 echo "output.at:80: bison  foo.yy "
   2867 echo output.at:80 >$at_check_line_file
   2868 ( $at_traceon; bison  foo.yy  ) >$at_stdout 2>$at_stder1
   2869 at_status=$?
   2870 grep '^ *+' $at_stder1 >&2
   2871 grep -v '^ *+' $at_stder1 >$at_stderr
   2872 at_failed=false
   2873 $at_diff $at_devnull $at_stderr || at_failed=:
   2874 $at_diff $at_devnull $at_stdout || at_failed=:
   2875 case $at_status in
   2876    77) echo 77 > $at_status_file
   2877             exit 77;;
   2878    0) ;;
   2879    *) echo "output.at:80: exit code was $at_status, expected 0"
   2880       at_failed=:;;
   2881 esac
   2882 if $at_failed; then
   2883 
   2884   echo 1 > $at_status_file
   2885   exit 1
   2886 fi
   2887 
   2888 $at_traceon
   2889 
   2890 $at_traceoff
   2891 echo "output.at:80: ls foo.output foo.tab.cc foo.tab.hh"
   2892 echo output.at:80 >$at_check_line_file
   2893 ( $at_traceon; ls foo.output foo.tab.cc foo.tab.hh ) >$at_stdout 2>$at_stder1
   2894 at_status=$?
   2895 grep '^ *+' $at_stder1 >&2
   2896 grep -v '^ *+' $at_stder1 >$at_stderr
   2897 at_failed=false
   2898 $at_diff $at_devnull $at_stderr || at_failed=:
   2899 echo stdout:; cat $at_stdout
   2900 case $at_status in
   2901    77) echo 77 > $at_status_file
   2902             exit 77;;
   2903    0) ;;
   2904    *) echo "output.at:80: exit code was $at_status, expected 0"
   2905       at_failed=:;;
   2906 esac
   2907 if $at_failed; then
   2908 
   2909   echo 1 > $at_status_file
   2910   exit 1
   2911 fi
   2912 
   2913 $at_traceon
   2914 
   2915 
   2916       $at_traceoff
   2917       $at_times_p && times >$at_times_file
   2918     ) 5>&1 2>&1 | eval $at_tee_pipe
   2919     at_status=`cat $at_status_file`
   2920     ;;
   2921 
   2922   25 ) # 25. output.at:83: Output files: %defines %verbose  -o foo.c
   2923     at_setup_line='output.at:83'
   2924     at_desc='Output files: %defines %verbose  -o foo.c '
   2925     $at_quiet $ECHO_N " 25: Output files: %defines %verbose  -o foo.c    $ECHO_C"
   2926     at_xfail=no
   2927     (
   2928       echo "25. output.at:83: testing ..."
   2929       $at_traceon
   2930 
   2931 case "foo.yy" in
   2932   */*) mkdir `echo "foo.yy" | sed 's,/.*,,'`;;
   2933 esac
   2934 cat >foo.yy <<'_ATEOF'
   2935 %defines %verbose
   2936 %%
   2937 foo: {};
   2938 _ATEOF
   2939 
   2940 
   2941 $at_traceoff
   2942 echo "output.at:83: bison -o foo.c foo.yy "
   2943 echo output.at:83 >$at_check_line_file
   2944 ( $at_traceon; bison -o foo.c foo.yy  ) >$at_stdout 2>$at_stder1
   2945 at_status=$?
   2946 grep '^ *+' $at_stder1 >&2
   2947 grep -v '^ *+' $at_stder1 >$at_stderr
   2948 at_failed=false
   2949 $at_diff $at_devnull $at_stderr || at_failed=:
   2950 $at_diff $at_devnull $at_stdout || at_failed=:
   2951 case $at_status in
   2952    77) echo 77 > $at_status_file
   2953             exit 77;;
   2954    0) ;;
   2955    *) echo "output.at:83: exit code was $at_status, expected 0"
   2956       at_failed=:;;
   2957 esac
   2958 if $at_failed; then
   2959 
   2960   echo 1 > $at_status_file
   2961   exit 1
   2962 fi
   2963 
   2964 $at_traceon
   2965 
   2966 $at_traceoff
   2967 echo "output.at:83: ls foo.c foo.h foo.output"
   2968 echo output.at:83 >$at_check_line_file
   2969 ( $at_traceon; ls foo.c foo.h foo.output ) >$at_stdout 2>$at_stder1
   2970 at_status=$?
   2971 grep '^ *+' $at_stder1 >&2
   2972 grep -v '^ *+' $at_stder1 >$at_stderr
   2973 at_failed=false
   2974 $at_diff $at_devnull $at_stderr || at_failed=:
   2975 echo stdout:; cat $at_stdout
   2976 case $at_status in
   2977    77) echo 77 > $at_status_file
   2978             exit 77;;
   2979    0) ;;
   2980    *) echo "output.at:83: exit code was $at_status, expected 0"
   2981       at_failed=:;;
   2982 esac
   2983 if $at_failed; then
   2984 
   2985   echo 1 > $at_status_file
   2986   exit 1
   2987 fi
   2988 
   2989 $at_traceon
   2990 
   2991 
   2992       $at_traceoff
   2993       $at_times_p && times >$at_times_file
   2994     ) 5>&1 2>&1 | eval $at_tee_pipe
   2995     at_status=`cat $at_status_file`
   2996     ;;
   2997 
   2998   26 ) # 26. output.at:87: Output files:  --defines=foo.hpp -o foo.c++
   2999     at_setup_line='output.at:87'
   3000     at_desc='Output files:  --defines=foo.hpp -o foo.c++ '
   3001     $at_quiet $ECHO_N " 26: Output files:  --defines=foo.hpp -o foo.c++  $ECHO_C"
   3002     at_xfail=no
   3003     (
   3004       echo "26. output.at:87: testing ..."
   3005       $at_traceon
   3006 
   3007 case "foo.yy" in
   3008   */*) mkdir `echo "foo.yy" | sed 's,/.*,,'`;;
   3009 esac
   3010 cat >foo.yy <<'_ATEOF'
   3011 
   3012 %%
   3013 foo: {};
   3014 _ATEOF
   3015 
   3016 
   3017 $at_traceoff
   3018 echo "output.at:87: bison --defines=foo.hpp -o foo.c++ foo.yy "
   3019 echo output.at:87 >$at_check_line_file
   3020 ( $at_traceon; bison --defines=foo.hpp -o foo.c++ foo.yy  ) >$at_stdout 2>$at_stder1
   3021 at_status=$?
   3022 grep '^ *+' $at_stder1 >&2
   3023 grep -v '^ *+' $at_stder1 >$at_stderr
   3024 at_failed=false
   3025 $at_diff $at_devnull $at_stderr || at_failed=:
   3026 $at_diff $at_devnull $at_stdout || at_failed=:
   3027 case $at_status in
   3028    77) echo 77 > $at_status_file
   3029             exit 77;;
   3030    0) ;;
   3031    *) echo "output.at:87: exit code was $at_status, expected 0"
   3032       at_failed=:;;
   3033 esac
   3034 if $at_failed; then
   3035 
   3036   echo 1 > $at_status_file
   3037   exit 1
   3038 fi
   3039 
   3040 $at_traceon
   3041 
   3042 $at_traceoff
   3043 echo "output.at:87: ls foo.c++ foo.hpp"
   3044 echo output.at:87 >$at_check_line_file
   3045 ( $at_traceon; ls foo.c++ foo.hpp ) >$at_stdout 2>$at_stder1
   3046 at_status=$?
   3047 grep '^ *+' $at_stder1 >&2
   3048 grep -v '^ *+' $at_stder1 >$at_stderr
   3049 at_failed=false
   3050 $at_diff $at_devnull $at_stderr || at_failed=:
   3051 echo stdout:; cat $at_stdout
   3052 case $at_status in
   3053    77) echo 77 > $at_status_file
   3054             exit 77;;
   3055    0) ;;
   3056    *) echo "output.at:87: exit code was $at_status, expected 0"
   3057       at_failed=:;;
   3058 esac
   3059 if $at_failed; then
   3060 
   3061   echo 1 > $at_status_file
   3062   exit 1
   3063 fi
   3064 
   3065 $at_traceon
   3066 
   3067 
   3068       $at_traceoff
   3069       $at_times_p && times >$at_times_file
   3070     ) 5>&1 2>&1 | eval $at_tee_pipe
   3071     at_status=`cat $at_status_file`
   3072     ;;
   3073 
   3074   27 ) # 27. output.at:91: Output files:  -o foo.c++ --graph=foo.gph
   3075     at_setup_line='output.at:91'
   3076     at_desc='Output files:  -o foo.c++ --graph=foo.gph '
   3077     $at_quiet $ECHO_N " 27: Output files:  -o foo.c++ --graph=foo.gph    $ECHO_C"
   3078     at_xfail=no
   3079     (
   3080       echo "27. output.at:91: testing ..."
   3081       $at_traceon
   3082 
   3083 case "foo.yy" in
   3084   */*) mkdir `echo "foo.yy" | sed 's,/.*,,'`;;
   3085 esac
   3086 cat >foo.yy <<'_ATEOF'
   3087 
   3088 %%
   3089 foo: {};
   3090 _ATEOF
   3091 
   3092 
   3093 $at_traceoff
   3094 echo "output.at:91: bison -o foo.c++ --graph=foo.gph foo.yy "
   3095 echo output.at:91 >$at_check_line_file
   3096 ( $at_traceon; bison -o foo.c++ --graph=foo.gph foo.yy  ) >$at_stdout 2>$at_stder1
   3097 at_status=$?
   3098 grep '^ *+' $at_stder1 >&2
   3099 grep -v '^ *+' $at_stder1 >$at_stderr
   3100 at_failed=false
   3101 $at_diff $at_devnull $at_stderr || at_failed=:
   3102 $at_diff $at_devnull $at_stdout || at_failed=:
   3103 case $at_status in
   3104    77) echo 77 > $at_status_file
   3105             exit 77;;
   3106    0) ;;
   3107    *) echo "output.at:91: exit code was $at_status, expected 0"
   3108       at_failed=:;;
   3109 esac
   3110 if $at_failed; then
   3111 
   3112   echo 1 > $at_status_file
   3113   exit 1
   3114 fi
   3115 
   3116 $at_traceon
   3117 
   3118 $at_traceoff
   3119 echo "output.at:91: ls foo.c++ foo.gph"
   3120 echo output.at:91 >$at_check_line_file
   3121 ( $at_traceon; ls foo.c++ foo.gph ) >$at_stdout 2>$at_stder1
   3122 at_status=$?
   3123 grep '^ *+' $at_stder1 >&2
   3124 grep -v '^ *+' $at_stder1 >$at_stderr
   3125 at_failed=false
   3126 $at_diff $at_devnull $at_stderr || at_failed=:
   3127 echo stdout:; cat $at_stdout
   3128 case $at_status in
   3129    77) echo 77 > $at_status_file
   3130             exit 77;;
   3131    0) ;;
   3132    *) echo "output.at:91: exit code was $at_status, expected 0"
   3133       at_failed=:;;
   3134 esac
   3135 if $at_failed; then
   3136 
   3137   echo 1 > $at_status_file
   3138   exit 1
   3139 fi
   3140 
   3141 $at_traceon
   3142 
   3143 
   3144       $at_traceoff
   3145       $at_times_p && times >$at_times_file
   3146     ) 5>&1 2>&1 | eval $at_tee_pipe
   3147     at_status=`cat $at_status_file`
   3148     ;;
   3149 
   3150   28 ) # 28. output.at:105: Output files: %skeleton "lalr1.cc" %defines %verbose
   3151     at_setup_line='output.at:105'
   3152     at_desc='Output files: %skeleton "lalr1.cc" %defines %verbose  '
   3153     $at_quiet $ECHO_N " 28: Output files: %skeleton "lalr1.cc" %defines %verbose  $ECHO_C"
   3154     at_xfail=no
   3155     (
   3156       echo "28. output.at:105: testing ..."
   3157       $at_traceon
   3158 
   3159 case "foo.yy" in
   3160   */*) mkdir `echo "foo.yy" | sed 's,/.*,,'`;;
   3161 esac
   3162 cat >foo.yy <<'_ATEOF'
   3163 %skeleton "lalr1.cc" %defines %verbose
   3164 %%
   3165 foo: {};
   3166 _ATEOF
   3167 
   3168 
   3169 $at_traceoff
   3170 echo "output.at:105: bison  foo.yy "
   3171 echo output.at:105 >$at_check_line_file
   3172 ( $at_traceon; bison  foo.yy  ) >$at_stdout 2>$at_stder1
   3173 at_status=$?
   3174 grep '^ *+' $at_stder1 >&2
   3175 grep -v '^ *+' $at_stder1 >$at_stderr
   3176 at_failed=false
   3177 $at_diff $at_devnull $at_stderr || at_failed=:
   3178 $at_diff $at_devnull $at_stdout || at_failed=:
   3179 case $at_status in
   3180    77) echo 77 > $at_status_file
   3181             exit 77;;
   3182    0) ;;
   3183    *) echo "output.at:105: exit code was $at_status, expected 0"
   3184       at_failed=:;;
   3185 esac
   3186 if $at_failed; then
   3187 
   3188   echo 1 > $at_status_file
   3189   exit 1
   3190 fi
   3191 
   3192 $at_traceon
   3193 
   3194 $at_traceoff
   3195 echo "output.at:105: ls foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh"
   3196 echo output.at:105 >$at_check_line_file
   3197 ( $at_traceon; ls foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh ) >$at_stdout 2>$at_stder1
   3198 at_status=$?
   3199 grep '^ *+' $at_stder1 >&2
   3200 grep -v '^ *+' $at_stder1 >$at_stderr
   3201 at_failed=false
   3202 $at_diff $at_devnull $at_stderr || at_failed=:
   3203 echo stdout:; cat $at_stdout
   3204 case $at_status in
   3205    77) echo 77 > $at_status_file
   3206             exit 77;;
   3207    0) ;;
   3208    *) echo "output.at:105: exit code was $at_status, expected 0"
   3209       at_failed=:;;
   3210 esac
   3211 if $at_failed; then
   3212 
   3213   echo 1 > $at_status_file
   3214   exit 1
   3215 fi
   3216 
   3217 $at_traceon
   3218 
   3219 
   3220       $at_traceoff
   3221       $at_times_p && times >$at_times_file
   3222     ) 5>&1 2>&1 | eval $at_tee_pipe
   3223     at_status=`cat $at_status_file`
   3224     ;;
   3225 
   3226   29 ) # 29. output.at:109: Output files: %skeleton "lalr1.cc" %defines %verbose
   3227     at_setup_line='output.at:109'
   3228     at_desc='Output files: %skeleton "lalr1.cc" %defines %verbose  '
   3229     $at_quiet $ECHO_N " 29: Output files: %skeleton "lalr1.cc" %defines %verbose  $ECHO_C"
   3230     at_xfail=no
   3231     (
   3232       echo "29. output.at:109: testing ..."
   3233       $at_traceon
   3234 
   3235 case "subdir/foo.yy" in
   3236   */*) mkdir `echo "subdir/foo.yy" | sed 's,/.*,,'`;;
   3237 esac
   3238 cat >subdir/foo.yy <<'_ATEOF'
   3239 %skeleton "lalr1.cc" %defines %verbose
   3240 %%
   3241 foo: {};
   3242 _ATEOF
   3243 
   3244 
   3245 $at_traceoff
   3246 echo "output.at:109: bison  subdir/foo.yy "
   3247 echo output.at:109 >$at_check_line_file
   3248 ( $at_traceon; bison  subdir/foo.yy  ) >$at_stdout 2>$at_stder1
   3249 at_status=$?
   3250 grep '^ *+' $at_stder1 >&2
   3251 grep -v '^ *+' $at_stder1 >$at_stderr
   3252 at_failed=false
   3253 $at_diff $at_devnull $at_stderr || at_failed=:
   3254 $at_diff $at_devnull $at_stdout || at_failed=:
   3255 case $at_status in
   3256    77) echo 77 > $at_status_file
   3257             exit 77;;
   3258    0) ;;
   3259    *) echo "output.at:109: exit code was $at_status, expected 0"
   3260       at_failed=:;;
   3261 esac
   3262 if $at_failed; then
   3263 
   3264   echo 1 > $at_status_file
   3265   exit 1
   3266 fi
   3267 
   3268 $at_traceon
   3269 
   3270 $at_traceoff
   3271 echo "output.at:109: ls foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh"
   3272 echo output.at:109 >$at_check_line_file
   3273 ( $at_traceon; ls foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh ) >$at_stdout 2>$at_stder1
   3274 at_status=$?
   3275 grep '^ *+' $at_stder1 >&2
   3276 grep -v '^ *+' $at_stder1 >$at_stderr
   3277 at_failed=false
   3278 $at_diff $at_devnull $at_stderr || at_failed=:
   3279 echo stdout:; cat $at_stdout
   3280 case $at_status in
   3281    77) echo 77 > $at_status_file
   3282             exit 77;;
   3283    0) ;;
   3284    *) echo "output.at:109: exit code was $at_status, expected 0"
   3285       at_failed=:;;
   3286 esac
   3287 if $at_failed; then
   3288 
   3289   echo 1 > $at_status_file
   3290   exit 1
   3291 fi
   3292 
   3293 $at_traceon
   3294 
   3295 # Also make sure that the includes do not refer to the subdirectory.
   3296 $at_traceoff
   3297 echo "output.at:109: grep 'include .subdir/' foo.tab.cc"
   3298 echo output.at:109 >$at_check_line_file
   3299 ( $at_traceon; grep 'include .subdir/' foo.tab.cc ) >$at_stdout 2>$at_stder1
   3300 at_status=$?
   3301 grep '^ *+' $at_stder1 >&2
   3302 grep -v '^ *+' $at_stder1 >$at_stderr
   3303 at_failed=false
   3304 $at_diff $at_devnull $at_stderr || at_failed=:
   3305 $at_diff $at_devnull $at_stdout || at_failed=:
   3306 case $at_status in
   3307    77) echo 77 > $at_status_file
   3308             exit 77;;
   3309    1) ;;
   3310    *) echo "output.at:109: exit code was $at_status, expected 1"
   3311       at_failed=:;;
   3312 esac
   3313 if $at_failed; then
   3314 
   3315   echo 1 > $at_status_file
   3316   exit 1
   3317 fi
   3318 
   3319 $at_traceon
   3320 
   3321 $at_traceoff
   3322 echo "output.at:109: grep 'include .subdir/' foo.tab.hh"
   3323 echo output.at:109 >$at_check_line_file
   3324 ( $at_traceon; grep 'include .subdir/' foo.tab.hh ) >$at_stdout 2>$at_stder1
   3325 at_status=$?
   3326 grep '^ *+' $at_stder1 >&2
   3327 grep -v '^ *+' $at_stder1 >$at_stderr
   3328 at_failed=false
   3329 $at_diff $at_devnull $at_stderr || at_failed=:
   3330 $at_diff $at_devnull $at_stdout || at_failed=:
   3331 case $at_status in
   3332    77) echo 77 > $at_status_file
   3333             exit 77;;
   3334    1) ;;
   3335    *) echo "output.at:109: exit code was $at_status, expected 1"
   3336       at_failed=:;;
   3337 esac
   3338 if $at_failed; then
   3339 
   3340   echo 1 > $at_status_file
   3341   exit 1
   3342 fi
   3343 
   3344 $at_traceon
   3345 
   3346 
   3347       $at_traceoff
   3348       $at_times_p && times >$at_times_file
   3349     ) 5>&1 2>&1 | eval $at_tee_pipe
   3350     at_status=`cat $at_status_file`
   3351     ;;
   3352 
   3353   30 ) # 30. output.at:114: Output files: %skeleton "lalr1.cc" %defines %verbose -o subdir/foo.cc
   3354     at_setup_line='output.at:114'
   3355     at_desc='Output files: %skeleton "lalr1.cc" %defines %verbose -o subdir/foo.cc '
   3356     $at_quiet $ECHO_N " 30: Output files: %skeleton "lalr1.cc" %defines %verbose -o subdir/foo.cc $ECHO_C"
   3357     at_xfail=no
   3358     (
   3359       echo "30. output.at:114: testing ..."
   3360       $at_traceon
   3361 
   3362 case "subdir/foo.yy" in
   3363   */*) mkdir `echo "subdir/foo.yy" | sed 's,/.*,,'`;;
   3364 esac
   3365 cat >subdir/foo.yy <<'_ATEOF'
   3366 %skeleton "lalr1.cc" %defines %verbose
   3367 %%
   3368 foo: {};
   3369 _ATEOF
   3370 
   3371 
   3372 $at_traceoff
   3373 echo "output.at:114: bison -o subdir/foo.cc subdir/foo.yy "
   3374 echo output.at:114 >$at_check_line_file
   3375 ( $at_traceon; bison -o subdir/foo.cc subdir/foo.yy  ) >$at_stdout 2>$at_stder1
   3376 at_status=$?
   3377 grep '^ *+' $at_stder1 >&2
   3378 grep -v '^ *+' $at_stder1 >$at_stderr
   3379 at_failed=false
   3380 $at_diff $at_devnull $at_stderr || at_failed=:
   3381 $at_diff $at_devnull $at_stdout || at_failed=:
   3382 case $at_status in
   3383    77) echo 77 > $at_status_file
   3384             exit 77;;
   3385    0) ;;
   3386    *) echo "output.at:114: exit code was $at_status, expected 0"
   3387       at_failed=:;;
   3388 esac
   3389 if $at_failed; then
   3390 
   3391   echo 1 > $at_status_file
   3392   exit 1
   3393 fi
   3394 
   3395 $at_traceon
   3396 
   3397 $at_traceoff
   3398 echo "output.at:114: ls subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh"
   3399 echo output.at:114 >$at_check_line_file
   3400 ( $at_traceon; ls subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh ) >$at_stdout 2>$at_stder1
   3401 at_status=$?
   3402 grep '^ *+' $at_stder1 >&2
   3403 grep -v '^ *+' $at_stder1 >$at_stderr
   3404 at_failed=false
   3405 $at_diff $at_devnull $at_stderr || at_failed=:
   3406 echo stdout:; cat $at_stdout
   3407 case $at_status in
   3408    77) echo 77 > $at_status_file
   3409             exit 77;;
   3410    0) ;;
   3411    *) echo "output.at:114: exit code was $at_status, expected 0"
   3412       at_failed=:;;
   3413 esac
   3414 if $at_failed; then
   3415 
   3416   echo 1 > $at_status_file
   3417   exit 1
   3418 fi
   3419 
   3420 $at_traceon
   3421 
   3422 # Also make sure that the includes do not refer to the subdirectory.
   3423 $at_traceoff
   3424 echo "output.at:114: grep 'include .subdir/' subdir/foo.cc"
   3425 echo output.at:114 >$at_check_line_file
   3426 ( $at_traceon; grep 'include .subdir/' subdir/foo.cc ) >$at_stdout 2>$at_stder1
   3427 at_status=$?
   3428 grep '^ *+' $at_stder1 >&2
   3429 grep -v '^ *+' $at_stder1 >$at_stderr
   3430 at_failed=false
   3431 $at_diff $at_devnull $at_stderr || at_failed=:
   3432 $at_diff $at_devnull $at_stdout || at_failed=:
   3433 case $at_status in
   3434    77) echo 77 > $at_status_file
   3435             exit 77;;
   3436    1) ;;
   3437    *) echo "output.at:114: exit code was $at_status, expected 1"
   3438       at_failed=:;;
   3439 esac
   3440 if $at_failed; then
   3441 
   3442   echo 1 > $at_status_file
   3443   exit 1
   3444 fi
   3445 
   3446 $at_traceon
   3447 
   3448 $at_traceoff
   3449 echo "output.at:114: grep 'include .subdir/' subdir/foo.hh"
   3450 echo output.at:114 >$at_check_line_file
   3451 ( $at_traceon; grep 'include .subdir/' subdir/foo.hh ) >$at_stdout 2>$at_stder1
   3452 at_status=$?
   3453 grep '^ *+' $at_stder1 >&2
   3454 grep -v '^ *+' $at_stder1 >$at_stderr
   3455 at_failed=false
   3456 $at_diff $at_devnull $at_stderr || at_failed=:
   3457 $at_diff $at_devnull $at_stdout || at_failed=:
   3458 case $at_status in
   3459    77) echo 77 > $at_status_file
   3460             exit 77;;
   3461    1) ;;
   3462    *) echo "output.at:114: exit code was $at_status, expected 1"
   3463       at_failed=:;;
   3464 esac
   3465 if $at_failed; then
   3466 
   3467   echo 1 > $at_status_file
   3468   exit 1
   3469 fi
   3470 
   3471 $at_traceon
   3472 
   3473 
   3474       $at_traceoff
   3475       $at_times_p && times >$at_times_file
   3476     ) 5>&1 2>&1 | eval $at_tee_pipe
   3477     at_status=`cat $at_status_file`
   3478     ;;
   3479 
   3480 
   3481   banner-3 ) # Banner 3. sets.at:59
   3482     cat <<\_ATEOF
   3483 
   3484 Grammar Sets (Firsts etc.).
   3485 
   3486 _ATEOF
   3487     ;;
   3488 
   3489   31 ) # 31. sets.at:66: Nullable
   3490     at_setup_line='sets.at:66'
   3491     at_desc='Nullable'
   3492     $at_quiet $ECHO_N " 31: Nullable                                     $ECHO_C"
   3493     at_xfail=no
   3494     (
   3495       echo "31. sets.at:66: testing ..."
   3496       $at_traceon
   3497 
   3498 
   3499 # At some point, nullable had been smoking grass, and managed to say:
   3500 #
   3501 # Entering set_nullable
   3502 # NULLABLE
   3503 #         'e': yes
   3504 #         (null): no
   3505 # ...
   3506 
   3507 cat >input.y <<'_ATEOF'
   3508 %%
   3509 e: 'e' | /* Nothing */;
   3510 _ATEOF
   3511 
   3512 
   3513 $at_traceoff
   3514 echo "sets.at:81: bison --trace=sets input.y"
   3515 echo sets.at:81 >$at_check_line_file
   3516 ( $at_traceon; bison --trace=sets input.y ) >$at_stdout 2>$at_stder1
   3517 at_status=$?
   3518 grep '^ *+' $at_stder1 >&2
   3519 grep -v '^ *+' $at_stder1 >$at_stderr
   3520 at_failed=false
   3521 echo stderr:; tee stderr <$at_stderr
   3522 $at_diff $at_devnull $at_stdout || at_failed=:
   3523 case $at_status in
   3524    77) echo 77 > $at_status_file
   3525             exit 77;;
   3526    0) ;;
   3527    *) echo "sets.at:81: exit code was $at_status, expected 0"
   3528       at_failed=:;;
   3529 esac
   3530 if $at_failed; then
   3531 
   3532   echo 1 > $at_status_file
   3533   exit 1
   3534 fi
   3535 
   3536 $at_traceon
   3537 
   3538 cat >extract.sed <<'_ATEOF'
   3539 #n
   3540 /^NULLABLE$/ {
   3541    :null
   3542    p
   3543    n
   3544    /^[	 ]*$/ !b null
   3545 }
   3546 /^FIRSTS$/ {
   3547    :firsts
   3548    p
   3549    n
   3550    /^[	 ]*$/ !b firsts
   3551 }
   3552 /^FDERIVES$/ {
   3553    :fderiv
   3554    p
   3555    n
   3556    /^[	 ]*$/ !b fderiv
   3557 }
   3558 /^DERIVES$/ {
   3559    :deriv
   3560    p
   3561    n
   3562    /^[	 ]*$/ !b deriv
   3563 }
   3564 _ATEOF
   3565 
   3566 $at_traceoff
   3567 echo "sets.at:82: sed -f extract.sed stderr"
   3568 echo sets.at:82 >$at_check_line_file
   3569 ( $at_traceon; sed -f extract.sed stderr ) >$at_stdout 2>$at_stder1
   3570 at_status=$?
   3571 grep '^ *+' $at_stder1 >&2
   3572 grep -v '^ *+' $at_stder1 >$at_stderr
   3573 at_failed=false
   3574 $at_diff $at_devnull $at_stderr || at_failed=:
   3575 echo stdout:; tee stdout <$at_stdout
   3576 case $at_status in
   3577    77) echo 77 > $at_status_file
   3578             exit 77;;
   3579    0) ;;
   3580    *) echo "sets.at:82: exit code was $at_status, expected 0"
   3581       at_failed=:;;
   3582 esac
   3583 if $at_failed; then
   3584 
   3585   echo 1 > $at_status_file
   3586   exit 1
   3587 fi
   3588 
   3589 $at_traceon
   3590 
   3591 $at_traceoff
   3592 echo "sets.at:82: mv stdout sets"
   3593 echo sets.at:82 >$at_check_line_file
   3594 ( $at_traceon; mv stdout sets ) >$at_stdout 2>$at_stder1
   3595 at_status=$?
   3596 grep '^ *+' $at_stder1 >&2
   3597 grep -v '^ *+' $at_stder1 >$at_stderr
   3598 at_failed=false
   3599 $at_diff $at_devnull $at_stderr || at_failed=:
   3600 $at_diff $at_devnull $at_stdout || at_failed=:
   3601 case $at_status in
   3602    77) echo 77 > $at_status_file
   3603             exit 77;;
   3604    0) ;;
   3605    *) echo "sets.at:82: exit code was $at_status, expected 0"
   3606       at_failed=:;;
   3607 esac
   3608 if $at_failed; then
   3609 
   3610   echo 1 > $at_status_file
   3611   exit 1
   3612 fi
   3613 
   3614 $at_traceon
   3615 
   3616 
   3617 $at_traceoff
   3618 echo "sets.at:107: cat sets"
   3619 echo sets.at:107 >$at_check_line_file
   3620 ( $at_traceon; cat sets ) >$at_stdout 2>$at_stder1
   3621 at_status=$?
   3622 grep '^ *+' $at_stder1 >&2
   3623 grep -v '^ *+' $at_stder1 >$at_stderr
   3624 at_failed=false
   3625 $at_diff $at_devnull $at_stderr || at_failed=:
   3626 echo >>$at_stdout; echo "DERIVES
   3627 	\$accept derives
   3628 		  0  e \$end
   3629 	e derives
   3630 		  1  'e'
   3631 		  2  /* empty */
   3632 NULLABLE
   3633 	\$accept: no
   3634 	e: yes
   3635 FIRSTS
   3636 	\$accept firsts
   3637 		\$accept
   3638 		e
   3639 	e firsts
   3640 		e
   3641 FDERIVES
   3642 	\$accept derives
   3643 		  0  e \$end
   3644 		  1  'e'
   3645 		  2  /* empty */
   3646 	e derives
   3647 		  1  'e'
   3648 		  2  /* empty */
   3649 " | $at_diff - $at_stdout || at_failed=:
   3650 case $at_status in
   3651    77) echo 77 > $at_status_file
   3652             exit 77;;
   3653    0) ;;
   3654    *) echo "sets.at:107: exit code was $at_status, expected 0"
   3655       at_failed=:;;
   3656 esac
   3657 if $at_failed; then
   3658 
   3659   echo 1 > $at_status_file
   3660   exit 1
   3661 fi
   3662 
   3663 $at_traceon
   3664 
   3665 
   3666       $at_traceoff
   3667       $at_times_p && times >$at_times_file
   3668     ) 5>&1 2>&1 | eval $at_tee_pipe
   3669     at_status=`cat $at_status_file`
   3670     ;;
   3671 
   3672   32 ) # 32. sets.at:151: Broken Closure
   3673     at_setup_line='sets.at:151'
   3674     at_desc='Broken Closure'
   3675     $at_quiet $ECHO_N " 32: Broken Closure                               $ECHO_C"
   3676     at_xfail=no
   3677     (
   3678       echo "32. sets.at:151: testing ..."
   3679       $at_traceon
   3680 
   3681 
   3682 cat >input.y <<'_ATEOF'
   3683 %%
   3684 a: b;
   3685 b: c;
   3686 c: d;
   3687 d: e;
   3688 e: f;
   3689 f: g;
   3690 g: h;
   3691 h: 'h';
   3692 _ATEOF
   3693 
   3694 
   3695 $at_traceoff
   3696 echo "sets.at:165: bison --trace=sets input.y"
   3697 echo sets.at:165 >$at_check_line_file
   3698 ( $at_traceon; bison --trace=sets input.y ) >$at_stdout 2>$at_stder1
   3699 at_status=$?
   3700 grep '^ *+' $at_stder1 >&2
   3701 grep -v '^ *+' $at_stder1 >$at_stderr
   3702 at_failed=false
   3703 echo stderr:; tee stderr <$at_stderr
   3704 $at_diff $at_devnull $at_stdout || at_failed=:
   3705 case $at_status in
   3706    77) echo 77 > $at_status_file
   3707             exit 77;;
   3708    0) ;;
   3709    *) echo "sets.at:165: exit code was $at_status, expected 0"
   3710       at_failed=:;;
   3711 esac
   3712 if $at_failed; then
   3713 
   3714   echo 1 > $at_status_file
   3715   exit 1
   3716 fi
   3717 
   3718 $at_traceon
   3719 
   3720 
   3721 $at_traceoff
   3722 echo "sets.at:183: sed -n 's/[	 ]*\$//;/^RTC: Firsts Output BEGIN/,/^RTC: Firsts Output END/p' stderr"
   3723 echo sets.at:183 >$at_check_line_file
   3724 ( $at_traceon; sed -n 's/[	 ]*$//;/^RTC: Firsts Output BEGIN/,/^RTC: Firsts Output END/p' stderr ) >$at_stdout 2>$at_stder1
   3725 at_status=$?
   3726 grep '^ *+' $at_stder1 >&2
   3727 grep -v '^ *+' $at_stder1 >$at_stderr
   3728 at_failed=false
   3729 $at_diff $at_devnull $at_stderr || at_failed=:
   3730 echo >>$at_stdout; echo "RTC: Firsts Output BEGIN
   3731 
   3732    012345678
   3733   .---------.
   3734  0|111111111|
   3735  1| 11111111|
   3736  2|  1111111|
   3737  3|   111111|
   3738  4|    11111|
   3739  5|     1111|
   3740  6|      111|
   3741  7|       11|
   3742  8|        1|
   3743   \`---------'
   3744 RTC: Firsts Output END
   3745 " | $at_diff - $at_stdout || at_failed=:
   3746 case $at_status in
   3747    77) echo 77 > $at_status_file
   3748             exit 77;;
   3749    0) ;;
   3750    *) echo "sets.at:183: exit code was $at_status, expected 0"
   3751       at_failed=:;;
   3752 esac
   3753 if $at_failed; then
   3754 
   3755   echo 1 > $at_status_file
   3756   exit 1
   3757 fi
   3758 
   3759 $at_traceon
   3760 
   3761 
   3762       $at_traceoff
   3763       $at_times_p && times >$at_times_file
   3764     ) 5>&1 2>&1 | eval $at_tee_pipe
   3765     at_status=`cat $at_status_file`
   3766     ;;
   3767 
   3768   33 ) # 33. sets.at:193: Firsts
   3769     at_setup_line='sets.at:193'
   3770     at_desc='Firsts'
   3771     $at_quiet $ECHO_N " 33: Firsts                                       $ECHO_C"
   3772     at_xfail=no
   3773     (
   3774       echo "33. sets.at:193: testing ..."
   3775       $at_traceon
   3776 
   3777 
   3778 cat >input.y <<'_ATEOF'
   3779 %nonassoc '<' '>'
   3780 %left '+' '-'
   3781 %right '^' '='
   3782 %%
   3783 exp:
   3784    exp '<' exp
   3785  | exp '>' exp
   3786  | exp '+' exp
   3787  | exp '-' exp
   3788  | exp '^' exp
   3789  | exp '=' exp
   3790  | "exp"
   3791  ;
   3792 _ATEOF
   3793 
   3794 
   3795 $at_traceoff
   3796 echo "sets.at:211: bison --trace=sets input.y"
   3797 echo sets.at:211 >$at_check_line_file
   3798 ( $at_traceon; bison --trace=sets input.y ) >$at_stdout 2>$at_stder1
   3799 at_status=$?
   3800 grep '^ *+' $at_stder1 >&2
   3801 grep -v '^ *+' $at_stder1 >$at_stderr
   3802 at_failed=false
   3803 echo stderr:; tee stderr <$at_stderr
   3804 $at_diff $at_devnull $at_stdout || at_failed=:
   3805 case $at_status in
   3806    77) echo 77 > $at_status_file
   3807             exit 77;;
   3808    0) ;;
   3809    *) echo "sets.at:211: exit code was $at_status, expected 0"
   3810       at_failed=:;;
   3811 esac
   3812 if $at_failed; then
   3813 
   3814   echo 1 > $at_status_file
   3815   exit 1
   3816 fi
   3817 
   3818 $at_traceon
   3819 
   3820 cat >extract.sed <<'_ATEOF'
   3821 #n
   3822 /^NULLABLE$/ {
   3823    :null
   3824    p
   3825    n
   3826    /^[	 ]*$/ !b null
   3827 }
   3828 /^FIRSTS$/ {
   3829    :firsts
   3830    p
   3831    n
   3832    /^[	 ]*$/ !b firsts
   3833 }
   3834 /^FDERIVES$/ {
   3835    :fderiv
   3836    p
   3837    n
   3838    /^[	 ]*$/ !b fderiv
   3839 }
   3840 /^DERIVES$/ {
   3841    :deriv
   3842    p
   3843    n
   3844    /^[	 ]*$/ !b deriv
   3845 }
   3846 _ATEOF
   3847 
   3848 $at_traceoff
   3849 echo "sets.at:212: sed -f extract.sed stderr"
   3850 echo sets.at:212 >$at_check_line_file
   3851 ( $at_traceon; sed -f extract.sed stderr ) >$at_stdout 2>$at_stder1
   3852 at_status=$?
   3853 grep '^ *+' $at_stder1 >&2
   3854 grep -v '^ *+' $at_stder1 >$at_stderr
   3855 at_failed=false
   3856 $at_diff $at_devnull $at_stderr || at_failed=:
   3857 echo stdout:; tee stdout <$at_stdout
   3858 case $at_status in
   3859    77) echo 77 > $at_status_file
   3860             exit 77;;
   3861    0) ;;
   3862    *) echo "sets.at:212: exit code was $at_status, expected 0"
   3863       at_failed=:;;
   3864 esac
   3865 if $at_failed; then
   3866 
   3867   echo 1 > $at_status_file
   3868   exit 1
   3869 fi
   3870 
   3871 $at_traceon
   3872 
   3873 $at_traceoff
   3874 echo "sets.at:212: mv stdout sets"
   3875 echo sets.at:212 >$at_check_line_file
   3876 ( $at_traceon; mv stdout sets ) >$at_stdout 2>$at_stder1
   3877 at_status=$?
   3878 grep '^ *+' $at_stder1 >&2
   3879 grep -v '^ *+' $at_stder1 >$at_stderr
   3880 at_failed=false
   3881 $at_diff $at_devnull $at_stderr || at_failed=:
   3882 $at_diff $at_devnull $at_stdout || at_failed=:
   3883 case $at_status in
   3884    77) echo 77 > $at_status_file
   3885             exit 77;;
   3886    0) ;;
   3887    *) echo "sets.at:212: exit code was $at_status, expected 0"
   3888       at_failed=:;;
   3889 esac
   3890 if $at_failed; then
   3891 
   3892   echo 1 > $at_status_file
   3893   exit 1
   3894 fi
   3895 
   3896 $at_traceon
   3897 
   3898 
   3899 $at_traceoff
   3900 echo "sets.at:252: cat sets"
   3901 echo sets.at:252 >$at_check_line_file
   3902 ( $at_traceon; cat sets ) >$at_stdout 2>$at_stder1
   3903 at_status=$?
   3904 grep '^ *+' $at_stder1 >&2
   3905 grep -v '^ *+' $at_stder1 >$at_stderr
   3906 at_failed=false
   3907 $at_diff $at_devnull $at_stderr || at_failed=:
   3908 echo >>$at_stdout; echo "DERIVES
   3909 	\$accept derives
   3910 		  0  exp \$end
   3911 	exp derives
   3912 		  1  exp '<' exp
   3913 		  2  exp '>' exp
   3914 		  3  exp '+' exp
   3915 		  4  exp '-' exp
   3916 		  5  exp '^' exp
   3917 		  6  exp '=' exp
   3918 		  7  \"exp\"
   3919 NULLABLE
   3920 	\$accept: no
   3921 	exp: no
   3922 FIRSTS
   3923 	\$accept firsts
   3924 		\$accept
   3925 		exp
   3926 	exp firsts
   3927 		exp
   3928 FDERIVES
   3929 	\$accept derives
   3930 		  0  exp \$end
   3931 		  1  exp '<' exp
   3932 		  2  exp '>' exp
   3933 		  3  exp '+' exp
   3934 		  4  exp '-' exp
   3935 		  5  exp '^' exp
   3936 		  6  exp '=' exp
   3937 		  7  \"exp\"
   3938 	exp derives
   3939 		  1  exp '<' exp
   3940 		  2  exp '>' exp
   3941 		  3  exp '+' exp
   3942 		  4  exp '-' exp
   3943 		  5  exp '^' exp
   3944 		  6  exp '=' exp
   3945 		  7  \"exp\"
   3946 " | $at_diff - $at_stdout || at_failed=:
   3947 case $at_status in
   3948    77) echo 77 > $at_status_file
   3949             exit 77;;
   3950    0) ;;
   3951    *) echo "sets.at:252: exit code was $at_status, expected 0"
   3952       at_failed=:;;
   3953 esac
   3954 if $at_failed; then
   3955 
   3956   echo 1 > $at_status_file
   3957   exit 1
   3958 fi
   3959 
   3960 $at_traceon
   3961 
   3962 
   3963       $at_traceoff
   3964       $at_times_p && times >$at_times_file
   3965     ) 5>&1 2>&1 | eval $at_tee_pipe
   3966     at_status=`cat $at_status_file`
   3967     ;;
   3968 
   3969   34 ) # 34. sets.at:269: Accept
   3970     at_setup_line='sets.at:269'
   3971     at_desc='Accept'
   3972     $at_quiet $ECHO_N " 34: Accept                                       $ECHO_C"
   3973     at_xfail=no
   3974     (
   3975       echo "34. sets.at:269: testing ..."
   3976       $at_traceon
   3977 
   3978 
   3979 cat >input.y <<'_ATEOF'
   3980 %token END 0
   3981 %%
   3982 input:
   3983   'a'
   3984 | '(' input ')'
   3985 | '(' error END
   3986 ;
   3987 _ATEOF
   3988 
   3989 
   3990 $at_traceoff
   3991 echo "sets.at:281: bison -v -o input.c input.y"
   3992 echo sets.at:281 >$at_check_line_file
   3993 ( $at_traceon; bison -v -o input.c input.y ) >$at_stdout 2>$at_stder1
   3994 at_status=$?
   3995 grep '^ *+' $at_stder1 >&2
   3996 grep -v '^ *+' $at_stder1 >$at_stderr
   3997 at_failed=false
   3998 $at_diff $at_devnull $at_stderr || at_failed=:
   3999 $at_diff $at_devnull $at_stdout || at_failed=:
   4000 case $at_status in
   4001    77) echo 77 > $at_status_file
   4002             exit 77;;
   4003    0) ;;
   4004    *) echo "sets.at:281: exit code was $at_status, expected 0"
   4005       at_failed=:;;
   4006 esac
   4007 if $at_failed; then
   4008 
   4009   echo 1 > $at_status_file
   4010   exit 1
   4011 fi
   4012 
   4013 $at_traceon
   4014 
   4015 
   4016 # Get the final state in the parser.
   4017 $at_traceoff
   4018 echo "sets.at:285: sed -n 's/.*define YYFINAL *\\([0-9][0-9]*\\)/final state \\1/p' input.c"
   4019 echo sets.at:285 >$at_check_line_file
   4020 ( $at_traceon; sed -n 's/.*define YYFINAL *\([0-9][0-9]*\)/final state \1/p' input.c ) >$at_stdout 2>$at_stder1
   4021 at_status=$?
   4022 grep '^ *+' $at_stder1 >&2
   4023 grep -v '^ *+' $at_stder1 >$at_stderr
   4024 at_failed=false
   4025 $at_diff $at_devnull $at_stderr || at_failed=:
   4026 echo stdout:; tee stdout <$at_stdout
   4027 case $at_status in
   4028    77) echo 77 > $at_status_file
   4029             exit 77;;
   4030    0) ;;
   4031    *) echo "sets.at:285: exit code was $at_status, expected 0"
   4032       at_failed=:;;
   4033 esac
   4034 if $at_failed; then
   4035 
   4036   echo 1 > $at_status_file
   4037   exit 1
   4038 fi
   4039 
   4040 $at_traceon
   4041 
   4042 mv stdout expout
   4043 
   4044 # Get the final state in the report, from the "accept" action..
   4045 $at_traceoff
   4046 echo "sets.at:300: sed -n '
   4047            /^state \\(.*\\)/{
   4048 	     s//final state \\1/
   4049 	     x
   4050 	   }
   4051 	   / accept/{
   4052 	     x
   4053 	     p
   4054 	     q
   4055 	   }
   4056 	' input.output"
   4057 echo sets.at:300 >$at_check_line_file
   4058 ( $at_traceon; sed -n '
   4059            /^state \(.*\)/{
   4060 	     s//final state \1/
   4061 	     x
   4062 	   }
   4063 	   / accept/{
   4064 	     x
   4065 	     p
   4066 	     q
   4067 	   }
   4068 	' input.output ) >$at_stdout 2>$at_stder1
   4069 at_status=$?
   4070 grep '^ *+' $at_stder1 >&2
   4071 grep -v '^ *+' $at_stder1 >$at_stderr
   4072 at_failed=false
   4073 $at_diff $at_devnull $at_stderr || at_failed=:
   4074 $at_diff expout $at_stdout || at_failed=:
   4075 case $at_status in
   4076    77) echo 77 > $at_status_file
   4077             exit 77;;
   4078    0) ;;
   4079    *) echo "sets.at:300: exit code was $at_status, expected 0"
   4080       at_failed=:;;
   4081 esac
   4082 if $at_failed; then
   4083 
   4084   echo 1 > $at_status_file
   4085   exit 1
   4086 fi
   4087 
   4088 $at_traceon
   4089 
   4090 
   4091       $at_traceoff
   4092       $at_times_p && times >$at_times_file
   4093     ) 5>&1 2>&1 | eval $at_tee_pipe
   4094     at_status=`cat $at_status_file`
   4095     ;;
   4096 
   4097 
   4098   banner-4 ) # Banner 4. reduce.at:19
   4099     cat <<\_ATEOF
   4100 
   4101 Grammar Reduction.
   4102 
   4103 _ATEOF
   4104     ;;
   4105 
   4106   35 ) # 35. reduce.at:26: Useless Terminals
   4107     at_setup_line='reduce.at:26'
   4108     at_desc='Useless Terminals'
   4109     $at_quiet $ECHO_N " 35: Useless Terminals                            $ECHO_C"
   4110     at_xfail=no
   4111     (
   4112       echo "35. reduce.at:26: testing ..."
   4113       $at_traceon
   4114 
   4115 
   4116 cat >input.y <<'_ATEOF'
   4117 %verbose
   4118 %output="input.c"
   4119 
   4120 %token useless1
   4121 %token useless2
   4122 %token useless3
   4123 %token useless4
   4124 %token useless5
   4125 %token useless6
   4126 %token useless7
   4127 %token useless8
   4128 %token useless9
   4129 
   4130 %token useful
   4131 %%
   4132 exp: useful;
   4133 _ATEOF
   4134 
   4135 
   4136 $at_traceoff
   4137 echo "reduce.at:47: bison input.y"
   4138 echo reduce.at:47 >$at_check_line_file
   4139 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   4140 at_status=$?
   4141 grep '^ *+' $at_stder1 >&2
   4142 grep -v '^ *+' $at_stder1 >$at_stderr
   4143 at_failed=false
   4144 $at_diff $at_devnull $at_stderr || at_failed=:
   4145 $at_diff $at_devnull $at_stdout || at_failed=:
   4146 case $at_status in
   4147    77) echo 77 > $at_status_file
   4148             exit 77;;
   4149    0) ;;
   4150    *) echo "reduce.at:47: exit code was $at_status, expected 0"
   4151       at_failed=:;;
   4152 esac
   4153 if $at_failed; then
   4154 
   4155   echo 1 > $at_status_file
   4156   exit 1
   4157 fi
   4158 
   4159 $at_traceon
   4160 
   4161 
   4162 $at_traceoff
   4163 echo "reduce.at:60: sed -n '/^Grammar/q;/^\$/!p' input.output"
   4164 echo reduce.at:60 >$at_check_line_file
   4165 ( $at_traceon; sed -n '/^Grammar/q;/^$/!p' input.output ) >$at_stdout 2>$at_stder1
   4166 at_status=$?
   4167 grep '^ *+' $at_stder1 >&2
   4168 grep -v '^ *+' $at_stder1 >$at_stderr
   4169 at_failed=false
   4170 $at_diff $at_devnull $at_stderr || at_failed=:
   4171 echo >>$at_stdout; echo "Terminals which are not used
   4172    useless1
   4173    useless2
   4174    useless3
   4175    useless4
   4176    useless5
   4177    useless6
   4178    useless7
   4179    useless8
   4180    useless9
   4181 " | $at_diff - $at_stdout || at_failed=:
   4182 case $at_status in
   4183    77) echo 77 > $at_status_file
   4184             exit 77;;
   4185    0) ;;
   4186    *) echo "reduce.at:60: exit code was $at_status, expected 0"
   4187       at_failed=:;;
   4188 esac
   4189 if $at_failed; then
   4190 
   4191   echo 1 > $at_status_file
   4192   exit 1
   4193 fi
   4194 
   4195 $at_traceon
   4196 
   4197 
   4198       $at_traceoff
   4199       $at_times_p && times >$at_times_file
   4200     ) 5>&1 2>&1 | eval $at_tee_pipe
   4201     at_status=`cat $at_status_file`
   4202     ;;
   4203 
   4204   36 ) # 36. reduce.at:70: Useless Nonterminals
   4205     at_setup_line='reduce.at:70'
   4206     at_desc='Useless Nonterminals'
   4207     $at_quiet $ECHO_N " 36: Useless Nonterminals                         $ECHO_C"
   4208     at_xfail=no
   4209     (
   4210       echo "36. reduce.at:70: testing ..."
   4211       $at_traceon
   4212 
   4213 
   4214 cat >input.y <<'_ATEOF'
   4215 %verbose
   4216 %output="input.c"
   4217 
   4218 %nterm useless1
   4219 %nterm useless2
   4220 %nterm useless3
   4221 %nterm useless4
   4222 %nterm useless5
   4223 %nterm useless6
   4224 %nterm useless7
   4225 %nterm useless8
   4226 %nterm useless9
   4227 
   4228 %token useful
   4229 %%
   4230 exp: useful;
   4231 _ATEOF
   4232 
   4233 
   4234 $at_traceoff
   4235 echo "reduce.at:102: bison input.y"
   4236 echo reduce.at:102 >$at_check_line_file
   4237 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   4238 at_status=$?
   4239 grep '^ *+' $at_stder1 >&2
   4240 grep -v '^ *+' $at_stder1 >$at_stderr
   4241 at_failed=false
   4242 echo >>$at_stderr; echo "input.y: warning: 9 useless nonterminals
   4243 input.y:4.8-15: warning: useless nonterminal: useless1
   4244 input.y:5.8-15: warning: useless nonterminal: useless2
   4245 input.y:6.8-15: warning: useless nonterminal: useless3
   4246 input.y:7.8-15: warning: useless nonterminal: useless4
   4247 input.y:8.8-15: warning: useless nonterminal: useless5
   4248 input.y:9.8-15: warning: useless nonterminal: useless6
   4249 input.y:10.8-15: warning: useless nonterminal: useless7
   4250 input.y:11.8-15: warning: useless nonterminal: useless8
   4251 input.y:12.8-15: warning: useless nonterminal: useless9
   4252 " | $at_diff - $at_stderr || at_failed=:
   4253 $at_diff $at_devnull $at_stdout || at_failed=:
   4254 case $at_status in
   4255    77) echo 77 > $at_status_file
   4256             exit 77;;
   4257    0) ;;
   4258    *) echo "reduce.at:102: exit code was $at_status, expected 0"
   4259       at_failed=:;;
   4260 esac
   4261 if $at_failed; then
   4262 
   4263   echo 1 > $at_status_file
   4264   exit 1
   4265 fi
   4266 
   4267 $at_traceon
   4268 
   4269 
   4270 $at_traceoff
   4271 echo "reduce.at:115: sed -n '/^Grammar/q;/^\$/!p' input.output"
   4272 echo reduce.at:115 >$at_check_line_file
   4273 ( $at_traceon; sed -n '/^Grammar/q;/^$/!p' input.output ) >$at_stdout 2>$at_stder1
   4274 at_status=$?
   4275 grep '^ *+' $at_stder1 >&2
   4276 grep -v '^ *+' $at_stder1 >$at_stderr
   4277 at_failed=false
   4278 $at_diff $at_devnull $at_stderr || at_failed=:
   4279 echo >>$at_stdout; echo "Useless nonterminals
   4280    useless1
   4281    useless2
   4282    useless3
   4283    useless4
   4284    useless5
   4285    useless6
   4286    useless7
   4287    useless8
   4288    useless9
   4289 " | $at_diff - $at_stdout || at_failed=:
   4290 case $at_status in
   4291    77) echo 77 > $at_status_file
   4292             exit 77;;
   4293    0) ;;
   4294    *) echo "reduce.at:115: exit code was $at_status, expected 0"
   4295       at_failed=:;;
   4296 esac
   4297 if $at_failed; then
   4298 
   4299   echo 1 > $at_status_file
   4300   exit 1
   4301 fi
   4302 
   4303 $at_traceon
   4304 
   4305 
   4306       $at_traceoff
   4307       $at_times_p && times >$at_times_file
   4308     ) 5>&1 2>&1 | eval $at_tee_pipe
   4309     at_status=`cat $at_status_file`
   4310     ;;
   4311 
   4312   37 ) # 37. reduce.at:125: Useless Rules
   4313     at_setup_line='reduce.at:125'
   4314     at_desc='Useless Rules'
   4315     $at_quiet $ECHO_N " 37: Useless Rules                                $ECHO_C"
   4316     at_xfail=no
   4317     (
   4318       echo "37. reduce.at:125: testing ..."
   4319       $at_traceon
   4320 
   4321 
   4322 
   4323 
   4324 cat >input.y <<'_ATEOF'
   4325 %verbose
   4326 %output="input.c"
   4327 %token useful
   4328 %%
   4329 exp: useful;
   4330 useless1: '1';
   4331 useless2: '2';
   4332 useless3: '3';
   4333 useless4: '4';
   4334 useless5: '5';
   4335 useless6: '6';
   4336 useless7: '7';
   4337 useless8: '8';
   4338 useless9: '9';
   4339 _ATEOF
   4340 
   4341 
   4342 $at_traceoff
   4343 echo "reduce.at:166: bison input.y"
   4344 echo reduce.at:166 >$at_check_line_file
   4345 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   4346 at_status=$?
   4347 grep '^ *+' $at_stder1 >&2
   4348 grep -v '^ *+' $at_stder1 >$at_stderr
   4349 at_failed=false
   4350 echo >>$at_stderr; echo "input.y: warning: 9 useless nonterminals and 9 useless rules
   4351 input.y:6.1-8: warning: useless nonterminal: useless1
   4352 input.y:7.1-8: warning: useless nonterminal: useless2
   4353 input.y:8.1-8: warning: useless nonterminal: useless3
   4354 input.y:9.1-8: warning: useless nonterminal: useless4
   4355 input.y:10.1-8: warning: useless nonterminal: useless5
   4356 input.y:11.1-8: warning: useless nonterminal: useless6
   4357 input.y:12.1-8: warning: useless nonterminal: useless7
   4358 input.y:13.1-8: warning: useless nonterminal: useless8
   4359 input.y:14.1-8: warning: useless nonterminal: useless9
   4360 input.y:6.11-13: warning: useless rule: useless1: '1'
   4361 input.y:7.11-13: warning: useless rule: useless2: '2'
   4362 input.y:8.11-13: warning: useless rule: useless3: '3'
   4363 input.y:9.11-13: warning: useless rule: useless4: '4'
   4364 input.y:10.11-13: warning: useless rule: useless5: '5'
   4365 input.y:11.11-13: warning: useless rule: useless6: '6'
   4366 input.y:12.11-13: warning: useless rule: useless7: '7'
   4367 input.y:13.11-13: warning: useless rule: useless8: '8'
   4368 input.y:14.11-13: warning: useless rule: useless9: '9'
   4369 " | $at_diff - $at_stderr || at_failed=:
   4370 $at_diff $at_devnull $at_stdout || at_failed=:
   4371 case $at_status in
   4372    77) echo 77 > $at_status_file
   4373             exit 77;;
   4374    0) ;;
   4375    *) echo "reduce.at:166: exit code was $at_status, expected 0"
   4376       at_failed=:;;
   4377 esac
   4378 if $at_failed; then
   4379 
   4380   echo 1 > $at_status_file
   4381   exit 1
   4382 fi
   4383 
   4384 $at_traceon
   4385 
   4386 
   4387 $at_traceoff
   4388 echo "reduce.at:199: sed -n '/^Grammar/q;/^\$/!p' input.output"
   4389 echo reduce.at:199 >$at_check_line_file
   4390 ( $at_traceon; sed -n '/^Grammar/q;/^$/!p' input.output ) >$at_stdout 2>$at_stder1
   4391 at_status=$?
   4392 grep '^ *+' $at_stder1 >&2
   4393 grep -v '^ *+' $at_stder1 >$at_stderr
   4394 at_failed=false
   4395 $at_diff $at_devnull $at_stderr || at_failed=:
   4396 echo >>$at_stdout; echo "Useless nonterminals
   4397    useless1
   4398    useless2
   4399    useless3
   4400    useless4
   4401    useless5
   4402    useless6
   4403    useless7
   4404    useless8
   4405    useless9
   4406 Terminals which are not used
   4407    '1'
   4408    '2'
   4409    '3'
   4410    '4'
   4411    '5'
   4412    '6'
   4413    '7'
   4414    '8'
   4415    '9'
   4416 Useless rules
   4417     2 useless1: '1'
   4418     3 useless2: '2'
   4419     4 useless3: '3'
   4420     5 useless4: '4'
   4421     6 useless5: '5'
   4422     7 useless6: '6'
   4423     8 useless7: '7'
   4424     9 useless8: '8'
   4425    10 useless9: '9'
   4426 " | $at_diff - $at_stdout || at_failed=:
   4427 case $at_status in
   4428    77) echo 77 > $at_status_file
   4429             exit 77;;
   4430    0) ;;
   4431    *) echo "reduce.at:199: exit code was $at_status, expected 0"
   4432       at_failed=:;;
   4433 esac
   4434 if $at_failed; then
   4435 
   4436   echo 1 > $at_status_file
   4437   exit 1
   4438 fi
   4439 
   4440 $at_traceon
   4441 
   4442 
   4443       $at_traceoff
   4444       $at_times_p && times >$at_times_file
   4445     ) 5>&1 2>&1 | eval $at_tee_pipe
   4446     at_status=`cat $at_status_file`
   4447     ;;
   4448 
   4449   38 ) # 38. reduce.at:212: Reduced Automaton
   4450     at_setup_line='reduce.at:212'
   4451     at_desc='Reduced Automaton'
   4452     $at_quiet $ECHO_N " 38: Reduced Automaton                            $ECHO_C"
   4453     at_xfail=no
   4454     (
   4455       echo "38. reduce.at:212: testing ..."
   4456       $at_traceon
   4457 
   4458 
   4459 
   4460 
   4461 # The non reduced grammar.
   4462 # ------------------------
   4463 cat >not-reduced.y <<'_ATEOF'
   4464 /* A useless token. */
   4465 %token useless_token
   4466 /* A useful one. */
   4467 %token useful
   4468 %verbose
   4469 %output="not-reduced.c"
   4470 
   4471 %%
   4472 
   4473 exp: useful            { /* A useful action. */ }
   4474    | non_productive    { /* A non productive action. */ }
   4475    ;
   4476 
   4477 not_reachable: useful  { /* A not reachable action. */ }
   4478              ;
   4479 
   4480 non_productive: non_productive useless_token
   4481                        { /* Another non productive action. */ }
   4482               ;
   4483 %%
   4484 _ATEOF
   4485 
   4486 
   4487 $at_traceoff
   4488 echo "reduce.at:248: bison not-reduced.y"
   4489 echo reduce.at:248 >$at_check_line_file
   4490 ( $at_traceon; bison not-reduced.y ) >$at_stdout 2>$at_stder1
   4491 at_status=$?
   4492 grep '^ *+' $at_stder1 >&2
   4493 grep -v '^ *+' $at_stder1 >$at_stderr
   4494 at_failed=false
   4495 echo >>$at_stderr; echo "not-reduced.y: warning: 2 useless nonterminals and 3 useless rules
   4496 not-reduced.y:14.1-13: warning: useless nonterminal: not_reachable
   4497 not-reduced.y:11.6-19: warning: useless nonterminal: non_productive
   4498 not-reduced.y:11.6-57: warning: useless rule: exp: non_productive
   4499 not-reduced.y:14.16-56: warning: useless rule: not_reachable: useful
   4500 not-reduced.y:17.17-18.63: warning: useless rule: non_productive: non_productive useless_token
   4501 " | $at_diff - $at_stderr || at_failed=:
   4502 $at_diff $at_devnull $at_stdout || at_failed=:
   4503 case $at_status in
   4504    77) echo 77 > $at_status_file
   4505             exit 77;;
   4506    0) ;;
   4507    *) echo "reduce.at:248: exit code was $at_status, expected 0"
   4508       at_failed=:;;
   4509 esac
   4510 if $at_failed; then
   4511 
   4512   echo 1 > $at_status_file
   4513   exit 1
   4514 fi
   4515 
   4516 $at_traceon
   4517 
   4518 
   4519 $at_traceoff
   4520 echo "reduce.at:260: sed -n '/^Grammar/q;/^\$/!p' not-reduced.output"
   4521 echo reduce.at:260 >$at_check_line_file
   4522 ( $at_traceon; sed -n '/^Grammar/q;/^$/!p' not-reduced.output ) >$at_stdout 2>$at_stder1
   4523 at_status=$?
   4524 grep '^ *+' $at_stder1 >&2
   4525 grep -v '^ *+' $at_stder1 >$at_stderr
   4526 at_failed=false
   4527 $at_diff $at_devnull $at_stderr || at_failed=:
   4528 echo >>$at_stdout; echo "Useless nonterminals
   4529    not_reachable
   4530    non_productive
   4531 Terminals which are not used
   4532    useless_token
   4533 Useless rules
   4534     2 exp: non_productive
   4535     3 not_reachable: useful
   4536     4 non_productive: non_productive useless_token
   4537 " | $at_diff - $at_stdout || at_failed=:
   4538 case $at_status in
   4539    77) echo 77 > $at_status_file
   4540             exit 77;;
   4541    0) ;;
   4542    *) echo "reduce.at:260: exit code was $at_status, expected 0"
   4543       at_failed=:;;
   4544 esac
   4545 if $at_failed; then
   4546 
   4547   echo 1 > $at_status_file
   4548   exit 1
   4549 fi
   4550 
   4551 $at_traceon
   4552 
   4553 
   4554 # The reduced grammar.
   4555 # --------------------
   4556 cat >reduced.y <<'_ATEOF'
   4557 /* A useless token. */
   4558 %token useless_token
   4559 /* A useful one. */
   4560 %token useful
   4561 %verbose
   4562 %output="reduced.c"
   4563 
   4564 %%
   4565 
   4566 exp: useful            { /* A useful action. */ }
   4567 //   | non_productive    { /* A non productive action. */ } */
   4568    ;
   4569 
   4570 //not_reachable: useful  { /* A not reachable action. */ }
   4571 //             ;
   4572 
   4573 //non_productive: non_productive useless_token
   4574 //                       { /* Another non productive action. */ }
   4575 //              ;
   4576 %%
   4577 _ATEOF
   4578 
   4579 
   4580 $at_traceoff
   4581 echo "reduce.at:287: bison reduced.y"
   4582 echo reduce.at:287 >$at_check_line_file
   4583 ( $at_traceon; bison reduced.y ) >$at_stdout 2>$at_stder1
   4584 at_status=$?
   4585 grep '^ *+' $at_stder1 >&2
   4586 grep -v '^ *+' $at_stder1 >$at_stderr
   4587 at_failed=false
   4588 $at_diff $at_devnull $at_stderr || at_failed=:
   4589 $at_diff $at_devnull $at_stdout || at_failed=:
   4590 case $at_status in
   4591    77) echo 77 > $at_status_file
   4592             exit 77;;
   4593    0) ;;
   4594    *) echo "reduce.at:287: exit code was $at_status, expected 0"
   4595       at_failed=:;;
   4596 esac
   4597 if $at_failed; then
   4598 
   4599   echo 1 > $at_status_file
   4600   exit 1
   4601 fi
   4602 
   4603 $at_traceon
   4604 
   4605 
   4606 # Comparing the parsers.
   4607 cp reduced.c expout
   4608 $at_traceoff
   4609 echo "reduce.at:291: sed 's/not-reduced/reduced/g' not-reduced.c"
   4610 echo reduce.at:291 >$at_check_line_file
   4611 ( $at_traceon; sed 's/not-reduced/reduced/g' not-reduced.c ) >$at_stdout 2>$at_stder1
   4612 at_status=$?
   4613 grep '^ *+' $at_stder1 >&2
   4614 grep -v '^ *+' $at_stder1 >$at_stderr
   4615 at_failed=false
   4616 $at_diff $at_devnull $at_stderr || at_failed=:
   4617 $at_diff expout $at_stdout || at_failed=:
   4618 case $at_status in
   4619    77) echo 77 > $at_status_file
   4620             exit 77;;
   4621    0) ;;
   4622    *) echo "reduce.at:291: exit code was $at_status, expected 0"
   4623       at_failed=:;;
   4624 esac
   4625 if $at_failed; then
   4626 
   4627   echo 1 > $at_status_file
   4628   exit 1
   4629 fi
   4630 
   4631 $at_traceon
   4632 
   4633 
   4634       $at_traceoff
   4635       $at_times_p && times >$at_times_file
   4636     ) 5>&1 2>&1 | eval $at_tee_pipe
   4637     at_status=`cat $at_status_file`
   4638     ;;
   4639 
   4640   39 ) # 39. reduce.at:301: Underivable Rules
   4641     at_setup_line='reduce.at:301'
   4642     at_desc='Underivable Rules'
   4643     $at_quiet $ECHO_N " 39: Underivable Rules                            $ECHO_C"
   4644     at_xfail=no
   4645     (
   4646       echo "39. reduce.at:301: testing ..."
   4647       $at_traceon
   4648 
   4649 
   4650 
   4651 
   4652 cat >input.y <<'_ATEOF'
   4653 %verbose
   4654 %output="input.c"
   4655 %token useful
   4656 %%
   4657 exp: useful | underivable;
   4658 underivable: indirection;
   4659 indirection: underivable;
   4660 _ATEOF
   4661 
   4662 
   4663 $at_traceoff
   4664 echo "reduce.at:322: bison input.y"
   4665 echo reduce.at:322 >$at_check_line_file
   4666 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   4667 at_status=$?
   4668 grep '^ *+' $at_stder1 >&2
   4669 grep -v '^ *+' $at_stder1 >$at_stderr
   4670 at_failed=false
   4671 echo >>$at_stderr; echo "input.y: warning: 2 useless nonterminals and 3 useless rules
   4672 input.y:5.15-25: warning: useless nonterminal: underivable
   4673 input.y:6.14-24: warning: useless nonterminal: indirection
   4674 input.y:5.15-25: warning: useless rule: exp: underivable
   4675 input.y:6.14-24: warning: useless rule: underivable: indirection
   4676 input.y:7.14-24: warning: useless rule: indirection: underivable
   4677 " | $at_diff - $at_stderr || at_failed=:
   4678 $at_diff $at_devnull $at_stdout || at_failed=:
   4679 case $at_status in
   4680    77) echo 77 > $at_status_file
   4681             exit 77;;
   4682    0) ;;
   4683    *) echo "reduce.at:322: exit code was $at_status, expected 0"
   4684       at_failed=:;;
   4685 esac
   4686 if $at_failed; then
   4687 
   4688   echo 1 > $at_status_file
   4689   exit 1
   4690 fi
   4691 
   4692 $at_traceon
   4693 
   4694 
   4695 $at_traceoff
   4696 echo "reduce.at:332: sed -n '/^Grammar/q;/^\$/!p' input.output"
   4697 echo reduce.at:332 >$at_check_line_file
   4698 ( $at_traceon; sed -n '/^Grammar/q;/^$/!p' input.output ) >$at_stdout 2>$at_stder1
   4699 at_status=$?
   4700 grep '^ *+' $at_stder1 >&2
   4701 grep -v '^ *+' $at_stder1 >$at_stderr
   4702 at_failed=false
   4703 $at_diff $at_devnull $at_stderr || at_failed=:
   4704 echo >>$at_stdout; echo "Useless nonterminals
   4705    underivable
   4706    indirection
   4707 Useless rules
   4708     2 exp: underivable
   4709     3 underivable: indirection
   4710     4 indirection: underivable
   4711 " | $at_diff - $at_stdout || at_failed=:
   4712 case $at_status in
   4713    77) echo 77 > $at_status_file
   4714             exit 77;;
   4715    0) ;;
   4716    *) echo "reduce.at:332: exit code was $at_status, expected 0"
   4717       at_failed=:;;
   4718 esac
   4719 if $at_failed; then
   4720 
   4721   echo 1 > $at_status_file
   4722   exit 1
   4723 fi
   4724 
   4725 $at_traceon
   4726 
   4727 
   4728       $at_traceoff
   4729       $at_times_p && times >$at_times_file
   4730     ) 5>&1 2>&1 | eval $at_tee_pipe
   4731     at_status=`cat $at_status_file`
   4732     ;;
   4733 
   4734   40 ) # 40. reduce.at:342: Empty Language
   4735     at_setup_line='reduce.at:342'
   4736     at_desc='Empty Language'
   4737     $at_quiet $ECHO_N " 40: Empty Language                               $ECHO_C"
   4738     at_xfail=no
   4739     (
   4740       echo "40. reduce.at:342: testing ..."
   4741       $at_traceon
   4742 
   4743 
   4744 cat >input.y <<'_ATEOF'
   4745 %output="input.c"
   4746 %%
   4747 exp: exp;
   4748 _ATEOF
   4749 
   4750 
   4751 $at_traceoff
   4752 echo "reduce.at:353: bison input.y"
   4753 echo reduce.at:353 >$at_check_line_file
   4754 ( $at_traceon; bison input.y ) >$at_stdout 2>$at_stder1
   4755 at_status=$?
   4756 grep '^ *+' $at_stder1 >&2
   4757 grep -v '^ *+' $at_stder1 >$at_stderr
   4758 at_failed=false
   4759 echo >>$at_stderr; echo "input.y: warning: 2 useless nonterminals and 2 useless rules
   4760 input.y:3.1-3: fatal error: start symbol exp does not derive any sentence
   4761 " | $at_diff - $at_stderr || at_failed=:
   4762 $at_diff $at_devnull $at_stdout || at_failed=:
   4763 case $at_status in
   4764    77) echo 77 > $at_status_file
   4765             exit 77;;
   4766    1) ;;
   4767    *) echo "reduce.at:353: exit code was $at_status, expected 1"
   4768       at_failed=:;;
   4769 esac
   4770 if $at_failed; then
   4771 
   4772   echo 1 > $at_status_file
   4773   exit 1
   4774 fi
   4775 
   4776 $at_traceon
   4777 
   4778 
   4779       $at_traceoff
   4780       $at_times_p && times >$at_times_file
   4781     ) 5>&1 2>&1 | eval $at_tee_pipe
   4782     at_status=`cat $at_status_file`
   4783     ;;
   4784 
   4785 
   4786   banner-5 ) # Banner 5. synclines.at:19
   4787     cat <<\_ATEOF
   4788 
   4789 User Actions.
   4790 
   4791 _ATEOF
   4792     ;;
   4793 
   4794   41 ) # 41. synclines.at:95: Prologue synch line
   4795     at_setup_line='synclines.at:95'
   4796     at_desc='Prologue synch line'
   4797     $at_quiet $ECHO_N " 41: Prologue synch line                          $ECHO_C"
   4798     at_xfail=no
   4799     (
   4800       echo "41. synclines.at:95: testing ..."
   4801       $at_traceon
   4802 
   4803 
   4804 # It seems impossible to find a generic scheme to check the location
   4805 # of an error.  Even requiring GCC is not sufficient, since for instance
   4806 # the version modified by Apple:
   4807 #
   4808 # | Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs
   4809 # | Apple Computer, Inc. version gcc-934.3, based on gcc version 2.95.2
   4810 # | 19991024 (release) configure:2124: $? = 0
   4811 #
   4812 # instead of:
   4813 #
   4814 # | input.y:2: #error "2"
   4815 #
   4816 # it reports:
   4817 #
   4818 # | input.y:2: "2"
   4819 # | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
   4820 
   4821 cat >syncline.c <<'_ATEOF'
   4822 #error "1"
   4823 _ATEOF
   4824 
   4825 
   4826 $at_traceoff
   4827 echo "synclines.at:95: \$CC \$CFLAGS \$CPPFLAGS -c syncline.c"
   4828 echo synclines.at:95 >$at_check_line_file
   4829 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c syncline.c ) >$at_stdout 2>$at_stder1
   4830 at_status=$?
   4831 grep '^ *+' $at_stder1 >&2
   4832 grep -v '^ *+' $at_stder1 >$at_stderr
   4833 at_failed=false
   4834 echo stderr:; tee stderr <$at_stderr
   4835 $at_diff $at_devnull $at_stdout || at_failed=:
   4836 case $at_status in
   4837    77) echo 77 > $at_status_file
   4838             exit 77;;
   4839    *);;
   4840 esac
   4841 if $at_failed; then
   4842 
   4843   echo 1 > $at_status_file
   4844   exit 1
   4845 fi
   4846 
   4847 $at_traceon
   4848 
   4849 # In case GCC displays column information, strip it down.
   4850 #
   4851 #   input.y:4:2: #error "4"    or
   4852 #   input.y:4.2: #error "4"    or
   4853 #   input.y:4:2: error: #error "4"
   4854 # =>
   4855 #   input.y:4: #error "4"
   4856 #
   4857 $at_traceoff
   4858 echo "synclines.at:95: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   4859 echo synclines.at:95 >$at_check_line_file
   4860 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   4861 at_status=$?
   4862 grep '^ *+' $at_stder1 >&2
   4863 grep -v '^ *+' $at_stder1 >$at_stderr
   4864 at_failed=false
   4865 $at_diff $at_devnull $at_stderr || at_failed=:
   4866 echo stdout:; tee stdout <$at_stdout
   4867 case $at_status in
   4868    77) echo 77 > $at_status_file
   4869             exit 77;;
   4870    0) ;;
   4871    *) echo "synclines.at:95: exit code was $at_status, expected 0"
   4872       at_failed=:;;
   4873 esac
   4874 if $at_failed; then
   4875 
   4876   echo 1 > $at_status_file
   4877   exit 1
   4878 fi
   4879 
   4880 $at_traceon
   4881 
   4882 
   4883 $at_traceoff
   4884 echo "synclines.at:95: test \"\`cat stdout\`\" = 'syncline.c:1: #error \"1\"' || exit 77"
   4885 echo synclines.at:95 >$at_check_line_file
   4886 ( $at_traceon; test "`cat stdout`" = 'syncline.c:1: #error "1"' || exit 77 ) >$at_stdout 2>$at_stder1
   4887 at_status=$?
   4888 grep '^ *+' $at_stder1 >&2
   4889 grep -v '^ *+' $at_stder1 >$at_stderr
   4890 at_failed=false
   4891 $at_diff $at_devnull $at_stderr || at_failed=:
   4892 $at_diff $at_devnull $at_stdout || at_failed=:
   4893 case $at_status in
   4894    77) echo 77 > $at_status_file
   4895             exit 77;;
   4896    0) ;;
   4897    *) echo "synclines.at:95: exit code was $at_status, expected 0"
   4898       at_failed=:;;
   4899 esac
   4900 if $at_failed; then
   4901 
   4902   echo 1 > $at_status_file
   4903   exit 1
   4904 fi
   4905 
   4906 $at_traceon
   4907 
   4908 
   4909 cat >input.y <<'_ATEOF'
   4910 %{
   4911 #error "2"
   4912 void yyerror (const char *s);
   4913 int yylex (void);
   4914 %}
   4915 %%
   4916 exp: '0';
   4917 _ATEOF
   4918 
   4919 $at_traceoff
   4920 echo "synclines.at:95: bison -o input.c input.y"
   4921 echo synclines.at:95 >$at_check_line_file
   4922 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   4923 at_status=$?
   4924 grep '^ *+' $at_stder1 >&2
   4925 grep -v '^ *+' $at_stder1 >$at_stderr
   4926 at_failed=false
   4927 $at_diff $at_devnull $at_stderr || at_failed=:
   4928 $at_diff $at_devnull $at_stdout || at_failed=:
   4929 case $at_status in
   4930    77) echo 77 > $at_status_file
   4931             exit 77;;
   4932    0) ;;
   4933    *) echo "synclines.at:95: exit code was $at_status, expected 0"
   4934       at_failed=:;;
   4935 esac
   4936 if $at_failed; then
   4937 
   4938   echo 1 > $at_status_file
   4939   exit 1
   4940 fi
   4941 
   4942 $at_traceon
   4943 
   4944 $at_traceoff
   4945 echo "synclines.at:95: \$CC \$CFLAGS \$CPPFLAGS -c input.c"
   4946 echo synclines.at:95 >$at_check_line_file
   4947 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c input.c ) >$at_stdout 2>$at_stder1
   4948 at_status=$?
   4949 grep '^ *+' $at_stder1 >&2
   4950 grep -v '^ *+' $at_stder1 >$at_stderr
   4951 at_failed=false
   4952 echo stderr:; tee stderr <$at_stderr
   4953 $at_diff $at_devnull $at_stdout || at_failed=:
   4954 case $at_status in
   4955    77) echo 77 > $at_status_file
   4956             exit 77;;
   4957    *);;
   4958 esac
   4959 if $at_failed; then
   4960 
   4961   echo 1 > $at_status_file
   4962   exit 1
   4963 fi
   4964 
   4965 $at_traceon
   4966 
   4967 # In case GCC displays column information, strip it down.
   4968 #
   4969 #   input.y:4:2: #error "4"    or
   4970 #   input.y:4.2: #error "4"    or
   4971 #   input.y:4:2: error: #error "4"
   4972 # =>
   4973 #   input.y:4: #error "4"
   4974 #
   4975 $at_traceoff
   4976 echo "synclines.at:95: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   4977 echo synclines.at:95 >$at_check_line_file
   4978 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   4979 at_status=$?
   4980 grep '^ *+' $at_stder1 >&2
   4981 grep -v '^ *+' $at_stder1 >$at_stderr
   4982 at_failed=false
   4983 $at_diff $at_devnull $at_stderr || at_failed=:
   4984 echo stdout:; tee stdout <$at_stdout
   4985 case $at_status in
   4986    77) echo 77 > $at_status_file
   4987             exit 77;;
   4988    0) ;;
   4989    *) echo "synclines.at:95: exit code was $at_status, expected 0"
   4990       at_failed=:;;
   4991 esac
   4992 if $at_failed; then
   4993 
   4994   echo 1 > $at_status_file
   4995   exit 1
   4996 fi
   4997 
   4998 $at_traceon
   4999 
   5000 
   5001 $at_traceoff
   5002 echo "synclines.at:95: cat stdout"
   5003 echo synclines.at:95 >$at_check_line_file
   5004 ( $at_traceon; cat stdout ) >$at_stdout 2>$at_stder1
   5005 at_status=$?
   5006 grep '^ *+' $at_stder1 >&2
   5007 grep -v '^ *+' $at_stder1 >$at_stderr
   5008 at_failed=false
   5009 $at_diff $at_devnull $at_stderr || at_failed=:
   5010 echo >>$at_stdout; echo "input.y:2: #error \"2\"
   5011 " | $at_diff - $at_stdout || at_failed=:
   5012 case $at_status in
   5013    77) echo 77 > $at_status_file
   5014             exit 77;;
   5015    0) ;;
   5016    *) echo "synclines.at:95: exit code was $at_status, expected 0"
   5017       at_failed=:;;
   5018 esac
   5019 if $at_failed; then
   5020 
   5021   echo 1 > $at_status_file
   5022   exit 1
   5023 fi
   5024 
   5025 $at_traceon
   5026 
   5027       $at_traceoff
   5028       $at_times_p && times >$at_times_file
   5029     ) 5>&1 2>&1 | eval $at_tee_pipe
   5030     at_status=`cat $at_status_file`
   5031     ;;
   5032 
   5033   42 ) # 42. synclines.at:115: %union synch line
   5034     at_setup_line='synclines.at:115'
   5035     at_desc='%union synch line'
   5036     $at_quiet $ECHO_N " 42: %union synch line                            $ECHO_C"
   5037     at_xfail=no
   5038     (
   5039       echo "42. synclines.at:115: testing ..."
   5040       $at_traceon
   5041 
   5042 
   5043 # It seems impossible to find a generic scheme to check the location
   5044 # of an error.  Even requiring GCC is not sufficient, since for instance
   5045 # the version modified by Apple:
   5046 #
   5047 # | Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs
   5048 # | Apple Computer, Inc. version gcc-934.3, based on gcc version 2.95.2
   5049 # | 19991024 (release) configure:2124: $? = 0
   5050 #
   5051 # instead of:
   5052 #
   5053 # | input.y:2: #error "2"
   5054 #
   5055 # it reports:
   5056 #
   5057 # | input.y:2: "2"
   5058 # | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
   5059 
   5060 cat >syncline.c <<'_ATEOF'
   5061 #error "1"
   5062 _ATEOF
   5063 
   5064 
   5065 $at_traceoff
   5066 echo "synclines.at:115: \$CC \$CFLAGS \$CPPFLAGS -c syncline.c"
   5067 echo synclines.at:115 >$at_check_line_file
   5068 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c syncline.c ) >$at_stdout 2>$at_stder1
   5069 at_status=$?
   5070 grep '^ *+' $at_stder1 >&2
   5071 grep -v '^ *+' $at_stder1 >$at_stderr
   5072 at_failed=false
   5073 echo stderr:; tee stderr <$at_stderr
   5074 $at_diff $at_devnull $at_stdout || at_failed=:
   5075 case $at_status in
   5076    77) echo 77 > $at_status_file
   5077             exit 77;;
   5078    *);;
   5079 esac
   5080 if $at_failed; then
   5081 
   5082   echo 1 > $at_status_file
   5083   exit 1
   5084 fi
   5085 
   5086 $at_traceon
   5087 
   5088 # In case GCC displays column information, strip it down.
   5089 #
   5090 #   input.y:4:2: #error "4"    or
   5091 #   input.y:4.2: #error "4"    or
   5092 #   input.y:4:2: error: #error "4"
   5093 # =>
   5094 #   input.y:4: #error "4"
   5095 #
   5096 $at_traceoff
   5097 echo "synclines.at:115: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   5098 echo synclines.at:115 >$at_check_line_file
   5099 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   5100 at_status=$?
   5101 grep '^ *+' $at_stder1 >&2
   5102 grep -v '^ *+' $at_stder1 >$at_stderr
   5103 at_failed=false
   5104 $at_diff $at_devnull $at_stderr || at_failed=:
   5105 echo stdout:; tee stdout <$at_stdout
   5106 case $at_status in
   5107    77) echo 77 > $at_status_file
   5108             exit 77;;
   5109    0) ;;
   5110    *) echo "synclines.at:115: exit code was $at_status, expected 0"
   5111       at_failed=:;;
   5112 esac
   5113 if $at_failed; then
   5114 
   5115   echo 1 > $at_status_file
   5116   exit 1
   5117 fi
   5118 
   5119 $at_traceon
   5120 
   5121 
   5122 $at_traceoff
   5123 echo "synclines.at:115: test \"\`cat stdout\`\" = 'syncline.c:1: #error \"1\"' || exit 77"
   5124 echo synclines.at:115 >$at_check_line_file
   5125 ( $at_traceon; test "`cat stdout`" = 'syncline.c:1: #error "1"' || exit 77 ) >$at_stdout 2>$at_stder1
   5126 at_status=$?
   5127 grep '^ *+' $at_stder1 >&2
   5128 grep -v '^ *+' $at_stder1 >$at_stderr
   5129 at_failed=false
   5130 $at_diff $at_devnull $at_stderr || at_failed=:
   5131 $at_diff $at_devnull $at_stdout || at_failed=:
   5132 case $at_status in
   5133    77) echo 77 > $at_status_file
   5134             exit 77;;
   5135    0) ;;
   5136    *) echo "synclines.at:115: exit code was $at_status, expected 0"
   5137       at_failed=:;;
   5138 esac
   5139 if $at_failed; then
   5140 
   5141   echo 1 > $at_status_file
   5142   exit 1
   5143 fi
   5144 
   5145 $at_traceon
   5146 
   5147 
   5148 cat >input.y <<'_ATEOF'
   5149 %union {
   5150 #error "2"
   5151   char dummy;
   5152 }
   5153 %{
   5154 void yyerror (const char *s);
   5155 int yylex (void);
   5156 %}
   5157 %%
   5158 exp: '0';
   5159 _ATEOF
   5160 
   5161 $at_traceoff
   5162 echo "synclines.at:115: bison -o input.c input.y"
   5163 echo synclines.at:115 >$at_check_line_file
   5164 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   5165 at_status=$?
   5166 grep '^ *+' $at_stder1 >&2
   5167 grep -v '^ *+' $at_stder1 >$at_stderr
   5168 at_failed=false
   5169 $at_diff $at_devnull $at_stderr || at_failed=:
   5170 $at_diff $at_devnull $at_stdout || at_failed=:
   5171 case $at_status in
   5172    77) echo 77 > $at_status_file
   5173             exit 77;;
   5174    0) ;;
   5175    *) echo "synclines.at:115: exit code was $at_status, expected 0"
   5176       at_failed=:;;
   5177 esac
   5178 if $at_failed; then
   5179 
   5180   echo 1 > $at_status_file
   5181   exit 1
   5182 fi
   5183 
   5184 $at_traceon
   5185 
   5186 $at_traceoff
   5187 echo "synclines.at:115: \$CC \$CFLAGS \$CPPFLAGS -c input.c"
   5188 echo synclines.at:115 >$at_check_line_file
   5189 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c input.c ) >$at_stdout 2>$at_stder1
   5190 at_status=$?
   5191 grep '^ *+' $at_stder1 >&2
   5192 grep -v '^ *+' $at_stder1 >$at_stderr
   5193 at_failed=false
   5194 echo stderr:; tee stderr <$at_stderr
   5195 $at_diff $at_devnull $at_stdout || at_failed=:
   5196 case $at_status in
   5197    77) echo 77 > $at_status_file
   5198             exit 77;;
   5199    *);;
   5200 esac
   5201 if $at_failed; then
   5202 
   5203   echo 1 > $at_status_file
   5204   exit 1
   5205 fi
   5206 
   5207 $at_traceon
   5208 
   5209 # In case GCC displays column information, strip it down.
   5210 #
   5211 #   input.y:4:2: #error "4"    or
   5212 #   input.y:4.2: #error "4"    or
   5213 #   input.y:4:2: error: #error "4"
   5214 # =>
   5215 #   input.y:4: #error "4"
   5216 #
   5217 $at_traceoff
   5218 echo "synclines.at:115: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   5219 echo synclines.at:115 >$at_check_line_file
   5220 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   5221 at_status=$?
   5222 grep '^ *+' $at_stder1 >&2
   5223 grep -v '^ *+' $at_stder1 >$at_stderr
   5224 at_failed=false
   5225 $at_diff $at_devnull $at_stderr || at_failed=:
   5226 echo stdout:; tee stdout <$at_stdout
   5227 case $at_status in
   5228    77) echo 77 > $at_status_file
   5229             exit 77;;
   5230    0) ;;
   5231    *) echo "synclines.at:115: exit code was $at_status, expected 0"
   5232       at_failed=:;;
   5233 esac
   5234 if $at_failed; then
   5235 
   5236   echo 1 > $at_status_file
   5237   exit 1
   5238 fi
   5239 
   5240 $at_traceon
   5241 
   5242 
   5243 $at_traceoff
   5244 echo "synclines.at:115: cat stdout"
   5245 echo synclines.at:115 >$at_check_line_file
   5246 ( $at_traceon; cat stdout ) >$at_stdout 2>$at_stder1
   5247 at_status=$?
   5248 grep '^ *+' $at_stder1 >&2
   5249 grep -v '^ *+' $at_stder1 >$at_stderr
   5250 at_failed=false
   5251 $at_diff $at_devnull $at_stderr || at_failed=:
   5252 echo >>$at_stdout; echo "input.y:2: #error \"2\"
   5253 " | $at_diff - $at_stdout || at_failed=:
   5254 case $at_status in
   5255    77) echo 77 > $at_status_file
   5256             exit 77;;
   5257    0) ;;
   5258    *) echo "synclines.at:115: exit code was $at_status, expected 0"
   5259       at_failed=:;;
   5260 esac
   5261 if $at_failed; then
   5262 
   5263   echo 1 > $at_status_file
   5264   exit 1
   5265 fi
   5266 
   5267 $at_traceon
   5268 
   5269       $at_traceoff
   5270       $at_times_p && times >$at_times_file
   5271     ) 5>&1 2>&1 | eval $at_tee_pipe
   5272     at_status=`cat $at_status_file`
   5273     ;;
   5274 
   5275   43 ) # 43. synclines.at:138: Postprologue synch line
   5276     at_setup_line='synclines.at:138'
   5277     at_desc='Postprologue synch line'
   5278     $at_quiet $ECHO_N " 43: Postprologue synch line                      $ECHO_C"
   5279     at_xfail=no
   5280     (
   5281       echo "43. synclines.at:138: testing ..."
   5282       $at_traceon
   5283 
   5284 
   5285 # It seems impossible to find a generic scheme to check the location
   5286 # of an error.  Even requiring GCC is not sufficient, since for instance
   5287 # the version modified by Apple:
   5288 #
   5289 # | Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs
   5290 # | Apple Computer, Inc. version gcc-934.3, based on gcc version 2.95.2
   5291 # | 19991024 (release) configure:2124: $? = 0
   5292 #
   5293 # instead of:
   5294 #
   5295 # | input.y:2: #error "2"
   5296 #
   5297 # it reports:
   5298 #
   5299 # | input.y:2: "2"
   5300 # | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
   5301 
   5302 cat >syncline.c <<'_ATEOF'
   5303 #error "1"
   5304 _ATEOF
   5305 
   5306 
   5307 $at_traceoff
   5308 echo "synclines.at:138: \$CC \$CFLAGS \$CPPFLAGS -c syncline.c"
   5309 echo synclines.at:138 >$at_check_line_file
   5310 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c syncline.c ) >$at_stdout 2>$at_stder1
   5311 at_status=$?
   5312 grep '^ *+' $at_stder1 >&2
   5313 grep -v '^ *+' $at_stder1 >$at_stderr
   5314 at_failed=false
   5315 echo stderr:; tee stderr <$at_stderr
   5316 $at_diff $at_devnull $at_stdout || at_failed=:
   5317 case $at_status in
   5318    77) echo 77 > $at_status_file
   5319             exit 77;;
   5320    *);;
   5321 esac
   5322 if $at_failed; then
   5323 
   5324   echo 1 > $at_status_file
   5325   exit 1
   5326 fi
   5327 
   5328 $at_traceon
   5329 
   5330 # In case GCC displays column information, strip it down.
   5331 #
   5332 #   input.y:4:2: #error "4"    or
   5333 #   input.y:4.2: #error "4"    or
   5334 #   input.y:4:2: error: #error "4"
   5335 # =>
   5336 #   input.y:4: #error "4"
   5337 #
   5338 $at_traceoff
   5339 echo "synclines.at:138: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   5340 echo synclines.at:138 >$at_check_line_file
   5341 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   5342 at_status=$?
   5343 grep '^ *+' $at_stder1 >&2
   5344 grep -v '^ *+' $at_stder1 >$at_stderr
   5345 at_failed=false
   5346 $at_diff $at_devnull $at_stderr || at_failed=:
   5347 echo stdout:; tee stdout <$at_stdout
   5348 case $at_status in
   5349    77) echo 77 > $at_status_file
   5350             exit 77;;
   5351    0) ;;
   5352    *) echo "synclines.at:138: exit code was $at_status, expected 0"
   5353       at_failed=:;;
   5354 esac
   5355 if $at_failed; then
   5356 
   5357   echo 1 > $at_status_file
   5358   exit 1
   5359 fi
   5360 
   5361 $at_traceon
   5362 
   5363 
   5364 $at_traceoff
   5365 echo "synclines.at:138: test \"\`cat stdout\`\" = 'syncline.c:1: #error \"1\"' || exit 77"
   5366 echo synclines.at:138 >$at_check_line_file
   5367 ( $at_traceon; test "`cat stdout`" = 'syncline.c:1: #error "1"' || exit 77 ) >$at_stdout 2>$at_stder1
   5368 at_status=$?
   5369 grep '^ *+' $at_stder1 >&2
   5370 grep -v '^ *+' $at_stder1 >$at_stderr
   5371 at_failed=false
   5372 $at_diff $at_devnull $at_stderr || at_failed=:
   5373 $at_diff $at_devnull $at_stdout || at_failed=:
   5374 case $at_status in
   5375    77) echo 77 > $at_status_file
   5376             exit 77;;
   5377    0) ;;
   5378    *) echo "synclines.at:138: exit code was $at_status, expected 0"
   5379       at_failed=:;;
   5380 esac
   5381 if $at_failed; then
   5382 
   5383   echo 1 > $at_status_file
   5384   exit 1
   5385 fi
   5386 
   5387 $at_traceon
   5388 
   5389 
   5390 cat >input.y <<'_ATEOF'
   5391 %{
   5392 void yyerror (const char *s);
   5393 int yylex (void);
   5394 %}
   5395 %union
   5396 {
   5397   int ival;
   5398 }
   5399 %{
   5400 #error "10"
   5401 %}
   5402 %%
   5403 exp: '0';
   5404 _ATEOF
   5405 
   5406 $at_traceoff
   5407 echo "synclines.at:138: bison -o input.c input.y"
   5408 echo synclines.at:138 >$at_check_line_file
   5409 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   5410 at_status=$?
   5411 grep '^ *+' $at_stder1 >&2
   5412 grep -v '^ *+' $at_stder1 >$at_stderr
   5413 at_failed=false
   5414 $at_diff $at_devnull $at_stderr || at_failed=:
   5415 $at_diff $at_devnull $at_stdout || at_failed=:
   5416 case $at_status in
   5417    77) echo 77 > $at_status_file
   5418             exit 77;;
   5419    0) ;;
   5420    *) echo "synclines.at:138: exit code was $at_status, expected 0"
   5421       at_failed=:;;
   5422 esac
   5423 if $at_failed; then
   5424 
   5425   echo 1 > $at_status_file
   5426   exit 1
   5427 fi
   5428 
   5429 $at_traceon
   5430 
   5431 $at_traceoff
   5432 echo "synclines.at:138: \$CC \$CFLAGS \$CPPFLAGS -c input.c"
   5433 echo synclines.at:138 >$at_check_line_file
   5434 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c input.c ) >$at_stdout 2>$at_stder1
   5435 at_status=$?
   5436 grep '^ *+' $at_stder1 >&2
   5437 grep -v '^ *+' $at_stder1 >$at_stderr
   5438 at_failed=false
   5439 echo stderr:; tee stderr <$at_stderr
   5440 $at_diff $at_devnull $at_stdout || at_failed=:
   5441 case $at_status in
   5442    77) echo 77 > $at_status_file
   5443             exit 77;;
   5444    *);;
   5445 esac
   5446 if $at_failed; then
   5447 
   5448   echo 1 > $at_status_file
   5449   exit 1
   5450 fi
   5451 
   5452 $at_traceon
   5453 
   5454 # In case GCC displays column information, strip it down.
   5455 #
   5456 #   input.y:4:2: #error "4"    or
   5457 #   input.y:4.2: #error "4"    or
   5458 #   input.y:4:2: error: #error "4"
   5459 # =>
   5460 #   input.y:4: #error "4"
   5461 #
   5462 $at_traceoff
   5463 echo "synclines.at:138: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   5464 echo synclines.at:138 >$at_check_line_file
   5465 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   5466 at_status=$?
   5467 grep '^ *+' $at_stder1 >&2
   5468 grep -v '^ *+' $at_stder1 >$at_stderr
   5469 at_failed=false
   5470 $at_diff $at_devnull $at_stderr || at_failed=:
   5471 echo stdout:; tee stdout <$at_stdout
   5472 case $at_status in
   5473    77) echo 77 > $at_status_file
   5474             exit 77;;
   5475    0) ;;
   5476    *) echo "synclines.at:138: exit code was $at_status, expected 0"
   5477       at_failed=:;;
   5478 esac
   5479 if $at_failed; then
   5480 
   5481   echo 1 > $at_status_file
   5482   exit 1
   5483 fi
   5484 
   5485 $at_traceon
   5486 
   5487 
   5488 $at_traceoff
   5489 echo "synclines.at:138: cat stdout"
   5490 echo synclines.at:138 >$at_check_line_file
   5491 ( $at_traceon; cat stdout ) >$at_stdout 2>$at_stder1
   5492 at_status=$?
   5493 grep '^ *+' $at_stder1 >&2
   5494 grep -v '^ *+' $at_stder1 >$at_stderr
   5495 at_failed=false
   5496 $at_diff $at_devnull $at_stderr || at_failed=:
   5497 echo >>$at_stdout; echo "input.y:10: #error \"10\"
   5498 " | $at_diff - $at_stdout || at_failed=:
   5499 case $at_status in
   5500    77) echo 77 > $at_status_file
   5501             exit 77;;
   5502    0) ;;
   5503    *) echo "synclines.at:138: exit code was $at_status, expected 0"
   5504       at_failed=:;;
   5505 esac
   5506 if $at_failed; then
   5507 
   5508   echo 1 > $at_status_file
   5509   exit 1
   5510 fi
   5511 
   5512 $at_traceon
   5513 
   5514       $at_traceoff
   5515       $at_times_p && times >$at_times_file
   5516     ) 5>&1 2>&1 | eval $at_tee_pipe
   5517     at_status=`cat $at_status_file`
   5518     ;;
   5519 
   5520   44 ) # 44. synclines.at:157: Action synch line
   5521     at_setup_line='synclines.at:157'
   5522     at_desc='Action synch line'
   5523     $at_quiet $ECHO_N " 44: Action synch line                            $ECHO_C"
   5524     at_xfail=no
   5525     (
   5526       echo "44. synclines.at:157: testing ..."
   5527       $at_traceon
   5528 
   5529 
   5530 # It seems impossible to find a generic scheme to check the location
   5531 # of an error.  Even requiring GCC is not sufficient, since for instance
   5532 # the version modified by Apple:
   5533 #
   5534 # | Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs
   5535 # | Apple Computer, Inc. version gcc-934.3, based on gcc version 2.95.2
   5536 # | 19991024 (release) configure:2124: $? = 0
   5537 #
   5538 # instead of:
   5539 #
   5540 # | input.y:2: #error "2"
   5541 #
   5542 # it reports:
   5543 #
   5544 # | input.y:2: "2"
   5545 # | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
   5546 
   5547 cat >syncline.c <<'_ATEOF'
   5548 #error "1"
   5549 _ATEOF
   5550 
   5551 
   5552 $at_traceoff
   5553 echo "synclines.at:157: \$CC \$CFLAGS \$CPPFLAGS -c syncline.c"
   5554 echo synclines.at:157 >$at_check_line_file
   5555 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c syncline.c ) >$at_stdout 2>$at_stder1
   5556 at_status=$?
   5557 grep '^ *+' $at_stder1 >&2
   5558 grep -v '^ *+' $at_stder1 >$at_stderr
   5559 at_failed=false
   5560 echo stderr:; tee stderr <$at_stderr
   5561 $at_diff $at_devnull $at_stdout || at_failed=:
   5562 case $at_status in
   5563    77) echo 77 > $at_status_file
   5564             exit 77;;
   5565    *);;
   5566 esac
   5567 if $at_failed; then
   5568 
   5569   echo 1 > $at_status_file
   5570   exit 1
   5571 fi
   5572 
   5573 $at_traceon
   5574 
   5575 # In case GCC displays column information, strip it down.
   5576 #
   5577 #   input.y:4:2: #error "4"    or
   5578 #   input.y:4.2: #error "4"    or
   5579 #   input.y:4:2: error: #error "4"
   5580 # =>
   5581 #   input.y:4: #error "4"
   5582 #
   5583 $at_traceoff
   5584 echo "synclines.at:157: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   5585 echo synclines.at:157 >$at_check_line_file
   5586 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   5587 at_status=$?
   5588 grep '^ *+' $at_stder1 >&2
   5589 grep -v '^ *+' $at_stder1 >$at_stderr
   5590 at_failed=false
   5591 $at_diff $at_devnull $at_stderr || at_failed=:
   5592 echo stdout:; tee stdout <$at_stdout
   5593 case $at_status in
   5594    77) echo 77 > $at_status_file
   5595             exit 77;;
   5596    0) ;;
   5597    *) echo "synclines.at:157: exit code was $at_status, expected 0"
   5598       at_failed=:;;
   5599 esac
   5600 if $at_failed; then
   5601 
   5602   echo 1 > $at_status_file
   5603   exit 1
   5604 fi
   5605 
   5606 $at_traceon
   5607 
   5608 
   5609 $at_traceoff
   5610 echo "synclines.at:157: test \"\`cat stdout\`\" = 'syncline.c:1: #error \"1\"' || exit 77"
   5611 echo synclines.at:157 >$at_check_line_file
   5612 ( $at_traceon; test "`cat stdout`" = 'syncline.c:1: #error "1"' || exit 77 ) >$at_stdout 2>$at_stder1
   5613 at_status=$?
   5614 grep '^ *+' $at_stder1 >&2
   5615 grep -v '^ *+' $at_stder1 >$at_stderr
   5616 at_failed=false
   5617 $at_diff $at_devnull $at_stderr || at_failed=:
   5618 $at_diff $at_devnull $at_stdout || at_failed=:
   5619 case $at_status in
   5620    77) echo 77 > $at_status_file
   5621             exit 77;;
   5622    0) ;;
   5623    *) echo "synclines.at:157: exit code was $at_status, expected 0"
   5624       at_failed=:;;
   5625 esac
   5626 if $at_failed; then
   5627 
   5628   echo 1 > $at_status_file
   5629   exit 1
   5630 fi
   5631 
   5632 $at_traceon
   5633 
   5634 
   5635 cat >input.y <<'_ATEOF'
   5636 %{
   5637 void yyerror (const char *s);
   5638 int yylex (void);
   5639 %}
   5640 %%
   5641 exp:
   5642 {
   5643 #error "8"
   5644 };
   5645 _ATEOF
   5646 
   5647 $at_traceoff
   5648 echo "synclines.at:157: bison -o input.c input.y"
   5649 echo synclines.at:157 >$at_check_line_file
   5650 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   5651 at_status=$?
   5652 grep '^ *+' $at_stder1 >&2
   5653 grep -v '^ *+' $at_stder1 >$at_stderr
   5654 at_failed=false
   5655 $at_diff $at_devnull $at_stderr || at_failed=:
   5656 $at_diff $at_devnull $at_stdout || at_failed=:
   5657 case $at_status in
   5658    77) echo 77 > $at_status_file
   5659             exit 77;;
   5660    0) ;;
   5661    *) echo "synclines.at:157: exit code was $at_status, expected 0"
   5662       at_failed=:;;
   5663 esac
   5664 if $at_failed; then
   5665 
   5666   echo 1 > $at_status_file
   5667   exit 1
   5668 fi
   5669 
   5670 $at_traceon
   5671 
   5672 $at_traceoff
   5673 echo "synclines.at:157: \$CC \$CFLAGS \$CPPFLAGS -c input.c"
   5674 echo synclines.at:157 >$at_check_line_file
   5675 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c input.c ) >$at_stdout 2>$at_stder1
   5676 at_status=$?
   5677 grep '^ *+' $at_stder1 >&2
   5678 grep -v '^ *+' $at_stder1 >$at_stderr
   5679 at_failed=false
   5680 echo stderr:; tee stderr <$at_stderr
   5681 $at_diff $at_devnull $at_stdout || at_failed=:
   5682 case $at_status in
   5683    77) echo 77 > $at_status_file
   5684             exit 77;;
   5685    *);;
   5686 esac
   5687 if $at_failed; then
   5688 
   5689   echo 1 > $at_status_file
   5690   exit 1
   5691 fi
   5692 
   5693 $at_traceon
   5694 
   5695 # In case GCC displays column information, strip it down.
   5696 #
   5697 #   input.y:4:2: #error "4"    or
   5698 #   input.y:4.2: #error "4"    or
   5699 #   input.y:4:2: error: #error "4"
   5700 # =>
   5701 #   input.y:4: #error "4"
   5702 #
   5703 $at_traceoff
   5704 echo "synclines.at:157: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   5705 echo synclines.at:157 >$at_check_line_file
   5706 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   5707 at_status=$?
   5708 grep '^ *+' $at_stder1 >&2
   5709 grep -v '^ *+' $at_stder1 >$at_stderr
   5710 at_failed=false
   5711 $at_diff $at_devnull $at_stderr || at_failed=:
   5712 echo stdout:; tee stdout <$at_stdout
   5713 case $at_status in
   5714    77) echo 77 > $at_status_file
   5715             exit 77;;
   5716    0) ;;
   5717    *) echo "synclines.at:157: exit code was $at_status, expected 0"
   5718       at_failed=:;;
   5719 esac
   5720 if $at_failed; then
   5721 
   5722   echo 1 > $at_status_file
   5723   exit 1
   5724 fi
   5725 
   5726 $at_traceon
   5727 
   5728 
   5729 $at_traceoff
   5730 echo "synclines.at:157: cat stdout"
   5731 echo synclines.at:157 >$at_check_line_file
   5732 ( $at_traceon; cat stdout ) >$at_stdout 2>$at_stder1
   5733 at_status=$?
   5734 grep '^ *+' $at_stder1 >&2
   5735 grep -v '^ *+' $at_stder1 >$at_stderr
   5736 at_failed=false
   5737 $at_diff $at_devnull $at_stderr || at_failed=:
   5738 echo >>$at_stdout; echo "input.y:8: #error \"8\"
   5739 " | $at_diff - $at_stdout || at_failed=:
   5740 case $at_status in
   5741    77) echo 77 > $at_status_file
   5742             exit 77;;
   5743    0) ;;
   5744    *) echo "synclines.at:157: exit code was $at_status, expected 0"
   5745       at_failed=:;;
   5746 esac
   5747 if $at_failed; then
   5748 
   5749   echo 1 > $at_status_file
   5750   exit 1
   5751 fi
   5752 
   5753 $at_traceon
   5754 
   5755       $at_traceoff
   5756       $at_times_p && times >$at_times_file
   5757     ) 5>&1 2>&1 | eval $at_tee_pipe
   5758     at_status=`cat $at_status_file`
   5759     ;;
   5760 
   5761   45 ) # 45. synclines.at:175: Epilogue synch line
   5762     at_setup_line='synclines.at:175'
   5763     at_desc='Epilogue synch line'
   5764     $at_quiet $ECHO_N " 45: Epilogue synch line                          $ECHO_C"
   5765     at_xfail=no
   5766     (
   5767       echo "45. synclines.at:175: testing ..."
   5768       $at_traceon
   5769 
   5770 
   5771 # It seems impossible to find a generic scheme to check the location
   5772 # of an error.  Even requiring GCC is not sufficient, since for instance
   5773 # the version modified by Apple:
   5774 #
   5775 # | Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs
   5776 # | Apple Computer, Inc. version gcc-934.3, based on gcc version 2.95.2
   5777 # | 19991024 (release) configure:2124: $? = 0
   5778 #
   5779 # instead of:
   5780 #
   5781 # | input.y:2: #error "2"
   5782 #
   5783 # it reports:
   5784 #
   5785 # | input.y:2: "2"
   5786 # | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
   5787 
   5788 cat >syncline.c <<'_ATEOF'
   5789 #error "1"
   5790 _ATEOF
   5791 
   5792 
   5793 $at_traceoff
   5794 echo "synclines.at:175: \$CC \$CFLAGS \$CPPFLAGS -c syncline.c"
   5795 echo synclines.at:175 >$at_check_line_file
   5796 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c syncline.c ) >$at_stdout 2>$at_stder1
   5797 at_status=$?
   5798 grep '^ *+' $at_stder1 >&2
   5799 grep -v '^ *+' $at_stder1 >$at_stderr
   5800 at_failed=false
   5801 echo stderr:; tee stderr <$at_stderr
   5802 $at_diff $at_devnull $at_stdout || at_failed=:
   5803 case $at_status in
   5804    77) echo 77 > $at_status_file
   5805             exit 77;;
   5806    *);;
   5807 esac
   5808 if $at_failed; then
   5809 
   5810   echo 1 > $at_status_file
   5811   exit 1
   5812 fi
   5813 
   5814 $at_traceon
   5815 
   5816 # In case GCC displays column information, strip it down.
   5817 #
   5818 #   input.y:4:2: #error "4"    or
   5819 #   input.y:4.2: #error "4"    or
   5820 #   input.y:4:2: error: #error "4"
   5821 # =>
   5822 #   input.y:4: #error "4"
   5823 #
   5824 $at_traceoff
   5825 echo "synclines.at:175: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   5826 echo synclines.at:175 >$at_check_line_file
   5827 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   5828 at_status=$?
   5829 grep '^ *+' $at_stder1 >&2
   5830 grep -v '^ *+' $at_stder1 >$at_stderr
   5831 at_failed=false
   5832 $at_diff $at_devnull $at_stderr || at_failed=:
   5833 echo stdout:; tee stdout <$at_stdout
   5834 case $at_status in
   5835    77) echo 77 > $at_status_file
   5836             exit 77;;
   5837    0) ;;
   5838    *) echo "synclines.at:175: exit code was $at_status, expected 0"
   5839       at_failed=:;;
   5840 esac
   5841 if $at_failed; then
   5842 
   5843   echo 1 > $at_status_file
   5844   exit 1
   5845 fi
   5846 
   5847 $at_traceon
   5848 
   5849 
   5850 $at_traceoff
   5851 echo "synclines.at:175: test \"\`cat stdout\`\" = 'syncline.c:1: #error \"1\"' || exit 77"
   5852 echo synclines.at:175 >$at_check_line_file
   5853 ( $at_traceon; test "`cat stdout`" = 'syncline.c:1: #error "1"' || exit 77 ) >$at_stdout 2>$at_stder1
   5854 at_status=$?
   5855 grep '^ *+' $at_stder1 >&2
   5856 grep -v '^ *+' $at_stder1 >$at_stderr
   5857 at_failed=false
   5858 $at_diff $at_devnull $at_stderr || at_failed=:
   5859 $at_diff $at_devnull $at_stdout || at_failed=:
   5860 case $at_status in
   5861    77) echo 77 > $at_status_file
   5862             exit 77;;
   5863    0) ;;
   5864    *) echo "synclines.at:175: exit code was $at_status, expected 0"
   5865       at_failed=:;;
   5866 esac
   5867 if $at_failed; then
   5868 
   5869   echo 1 > $at_status_file
   5870   exit 1
   5871 fi
   5872 
   5873 $at_traceon
   5874 
   5875 
   5876 cat >input.y <<'_ATEOF'
   5877 %{
   5878 void yyerror (const char *s);
   5879 int yylex (void);
   5880 %}
   5881 %%
   5882 exp: '0';
   5883 %%
   5884 #error "8"
   5885 _ATEOF
   5886 
   5887 $at_traceoff
   5888 echo "synclines.at:175: bison -o input.c input.y"
   5889 echo synclines.at:175 >$at_check_line_file
   5890 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   5891 at_status=$?
   5892 grep '^ *+' $at_stder1 >&2
   5893 grep -v '^ *+' $at_stder1 >$at_stderr
   5894 at_failed=false
   5895 $at_diff $at_devnull $at_stderr || at_failed=:
   5896 $at_diff $at_devnull $at_stdout || at_failed=:
   5897 case $at_status in
   5898    77) echo 77 > $at_status_file
   5899             exit 77;;
   5900    0) ;;
   5901    *) echo "synclines.at:175: exit code was $at_status, expected 0"
   5902       at_failed=:;;
   5903 esac
   5904 if $at_failed; then
   5905 
   5906   echo 1 > $at_status_file
   5907   exit 1
   5908 fi
   5909 
   5910 $at_traceon
   5911 
   5912 $at_traceoff
   5913 echo "synclines.at:175: \$CC \$CFLAGS \$CPPFLAGS -c input.c"
   5914 echo synclines.at:175 >$at_check_line_file
   5915 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -c input.c ) >$at_stdout 2>$at_stder1
   5916 at_status=$?
   5917 grep '^ *+' $at_stder1 >&2
   5918 grep -v '^ *+' $at_stder1 >$at_stderr
   5919 at_failed=false
   5920 echo stderr:; tee stderr <$at_stderr
   5921 $at_diff $at_devnull $at_stdout || at_failed=:
   5922 case $at_status in
   5923    77) echo 77 > $at_status_file
   5924             exit 77;;
   5925    *);;
   5926 esac
   5927 if $at_failed; then
   5928 
   5929   echo 1 > $at_status_file
   5930   exit 1
   5931 fi
   5932 
   5933 $at_traceon
   5934 
   5935 # In case GCC displays column information, strip it down.
   5936 #
   5937 #   input.y:4:2: #error "4"    or
   5938 #   input.y:4.2: #error "4"    or
   5939 #   input.y:4:2: error: #error "4"
   5940 # =>
   5941 #   input.y:4: #error "4"
   5942 #
   5943 $at_traceoff
   5944 echo "synclines.at:175: sed -e 's/^\\([^:]*:[^:.]*\\)[.:][^:]*:\\(.*\\)\$/\\1:\\2/' -e 's/^\\([^:]*:[^:]*:\\)[^#]*\\( #error\\)/\\1\\2/' stderr"
   5945 echo synclines.at:175 >$at_check_line_file
   5946 ( $at_traceon; sed -e 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' -e 's/^\([^:]*:[^:]*:\)[^#]*\( #error\)/\1\2/' stderr ) >$at_stdout 2>$at_stder1
   5947 at_status=$?
   5948 grep '^ *+' $at_stder1 >&2
   5949 grep -v '^ *+' $at_stder1 >$at_stderr
   5950 at_failed=false
   5951 $at_diff $at_devnull $at_stderr || at_failed=:
   5952 echo stdout:; tee stdout <$at_stdout
   5953 case $at_status in
   5954    77) echo 77 > $at_status_file
   5955             exit 77;;
   5956    0) ;;
   5957    *) echo "synclines.at:175: exit code was $at_status, expected 0"
   5958       at_failed=:;;
   5959 esac
   5960 if $at_failed; then
   5961 
   5962   echo 1 > $at_status_file
   5963   exit 1
   5964 fi
   5965 
   5966 $at_traceon
   5967 
   5968 
   5969 $at_traceoff
   5970 echo "synclines.at:175: cat stdout"
   5971 echo synclines.at:175 >$at_check_line_file
   5972 ( $at_traceon; cat stdout ) >$at_stdout 2>$at_stder1
   5973 at_status=$?
   5974 grep '^ *+' $at_stder1 >&2
   5975 grep -v '^ *+' $at_stder1 >$at_stderr
   5976 at_failed=false
   5977 $at_diff $at_devnull $at_stderr || at_failed=:
   5978 echo >>$at_stdout; echo "input.y:8: #error \"8\"
   5979 " | $at_diff - $at_stdout || at_failed=:
   5980 case $at_status in
   5981    77) echo 77 > $at_status_file
   5982             exit 77;;
   5983    0) ;;
   5984    *) echo "synclines.at:175: exit code was $at_status, expected 0"
   5985       at_failed=:;;
   5986 esac
   5987 if $at_failed; then
   5988 
   5989   echo 1 > $at_status_file
   5990   exit 1
   5991 fi
   5992 
   5993 $at_traceon
   5994 
   5995       $at_traceoff
   5996       $at_times_p && times >$at_times_file
   5997     ) 5>&1 2>&1 | eval $at_tee_pipe
   5998     at_status=`cat $at_status_file`
   5999     ;;
   6000 
   6001 
   6002   banner-6 ) # Banner 6. headers.at:19
   6003     cat <<\_ATEOF
   6004 
   6005 Parser Headers.
   6006 
   6007 _ATEOF
   6008     ;;
   6009 
   6010   46 ) # 46. headers.at:27: %union and --defines
   6011     at_setup_line='headers.at:27'
   6012     at_desc='%union and --defines'
   6013     $at_quiet $ECHO_N " 46: %union and --defines                         $ECHO_C"
   6014     at_xfail=no
   6015     (
   6016       echo "46. headers.at:27: testing ..."
   6017       $at_traceon
   6018 
   6019 
   6020 cat >input.y <<'_ATEOF'
   6021 %union
   6022 {
   6023   int   integer;
   6024   char *string ;
   6025 }
   6026 %%
   6027 exp: {};
   6028 _ATEOF
   6029 
   6030 
   6031 $at_traceoff
   6032 echo "headers.at:39: bison --defines input.y"
   6033 echo headers.at:39 >$at_check_line_file
   6034 ( $at_traceon; bison --defines input.y ) >$at_stdout 2>$at_stder1
   6035 at_status=$?
   6036 grep '^ *+' $at_stder1 >&2
   6037 grep -v '^ *+' $at_stder1 >$at_stderr
   6038 at_failed=false
   6039 $at_diff $at_devnull $at_stderr || at_failed=:
   6040 $at_diff $at_devnull $at_stdout || at_failed=:
   6041 case $at_status in
   6042    77) echo 77 > $at_status_file
   6043             exit 77;;
   6044    0) ;;
   6045    *) echo "headers.at:39: exit code was $at_status, expected 0"
   6046       at_failed=:;;
   6047 esac
   6048 if $at_failed; then
   6049 
   6050   echo 1 > $at_status_file
   6051   exit 1
   6052 fi
   6053 
   6054 $at_traceon
   6055 
   6056 
   6057       $at_traceoff
   6058       $at_times_p && times >$at_times_file
   6059     ) 5>&1 2>&1 | eval $at_tee_pipe
   6060     at_status=`cat $at_status_file`
   6061     ;;
   6062 
   6063   47 ) # 47. headers.at:77: Invalid CPP guards: input/input
   6064     at_setup_line='headers.at:77'
   6065     at_desc='Invalid CPP guards: input/input'
   6066     $at_quiet $ECHO_N " 47: Invalid CPP guards: input/input              $ECHO_C"
   6067     at_xfail=no
   6068     (
   6069       echo "47. headers.at:77: testing ..."
   6070       $at_traceon
   6071 
   6072 
   6073 # Possibly create inner directories.
   6074 dirname=`(dirname input/input) 2>/dev/null ||
   6075 $as_expr Xinput/input : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
   6076 	 Xinput/input : 'X\(//\)[^/]' \| \
   6077 	 Xinput/input : 'X\(//\)$' \| \
   6078 	 Xinput/input : 'X\(/\)' \| \
   6079 	 .     : '\(.\)' 2>/dev/null ||
   6080 echo Xinput/input |
   6081     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
   6082   	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
   6083   	  /^X\(\/\/\)$/{ s//\1/; q; }
   6084   	  /^X\(\/\).*/{ s//\1/; q; }
   6085   	  s/.*/./; q'`
   6086 { if $as_mkdir_p; then
   6087     mkdir -p $dirname
   6088   else
   6089     as_dir=$dirname
   6090     as_dirs=
   6091     while test ! -d "$as_dir"; do
   6092       as_dirs="$as_dir $as_dirs"
   6093       as_dir=`(dirname "$as_dir") 2>/dev/null ||
   6094 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
   6095 	 X"$as_dir" : 'X\(//\)[^/]' \| \
   6096 	 X"$as_dir" : 'X\(//\)$' \| \
   6097 	 X"$as_dir" : 'X\(/\)' \| \
   6098 	 .     : '\(.\)' 2>/dev/null ||
   6099 echo X"$as_dir" |
   6100     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
   6101   	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
   6102   	  /^X\(\/\/\)$/{ s//\1/; q; }
   6103   	  /^X\(\/\).*/{ s//\1/; q; }
   6104   	  s/.*/./; q'`
   6105     done
   6106     test ! -n "$as_dirs" || mkdir $as_dirs
   6107   fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirname" >&5
   6108 echo "$as_me: error: cannot create directory $dirname" >&2;}
   6109    { (exit 1); exit 1; }; }; }
   6110 
   6111 
   6112 cat >input/input.y <<'_ATEOF'
   6113 %{
   6114 #ifdef HAVE_CONFIG_H
   6115 # include <config.h>
   6116   /* We don't need perfect functions for these tests. */
   6117 # undef malloc
   6118 # undef memcmp
   6119 # undef realloc
   6120 #endif
   6121 %}
   6122 
   6123 %{
   6124 #include <input/input.h>
   6125 void yyerror (const char *);
   6126 int yylex (void);
   6127 %}
   6128 %%
   6129 dummy:;
   6130 %%
   6131 #include <input/input.h>
   6132 _ATEOF
   6133 
   6134 
   6135 
   6136 $at_traceoff
   6137 echo "headers.at:77: bison --defines=input/input.h --output=y.tab.c input/input.y"
   6138 echo headers.at:77 >$at_check_line_file
   6139 ( $at_traceon; bison --defines=input/input.h --output=y.tab.c input/input.y ) >$at_stdout 2>$at_stder1
   6140 at_status=$?
   6141 grep '^ *+' $at_stder1 >&2
   6142 grep -v '^ *+' $at_stder1 >$at_stderr
   6143 at_failed=false
   6144 $at_diff $at_devnull $at_stderr || at_failed=:
   6145 $at_diff $at_devnull $at_stdout || at_failed=:
   6146 case $at_status in
   6147    77) echo 77 > $at_status_file
   6148             exit 77;;
   6149    0) ;;
   6150    *) echo "headers.at:77: exit code was $at_status, expected 0"
   6151       at_failed=:;;
   6152 esac
   6153 if $at_failed; then
   6154 
   6155   echo 1 > $at_status_file
   6156   exit 1
   6157 fi
   6158 
   6159 $at_traceon
   6160 
   6161 
   6162 $at_traceoff
   6163 echo "headers.at:77: \$CC \$CFLAGS \$CPPFLAGS -o y.tab.o -I. -c y.tab.c"
   6164 echo headers.at:77 >$at_check_line_file
   6165 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -o y.tab.o -I. -c y.tab.c ) >$at_stdout 2>$at_stder1
   6166 at_status=$?
   6167 grep '^ *+' $at_stder1 >&2
   6168 grep -v '^ *+' $at_stder1 >$at_stderr
   6169 at_failed=false
   6170 echo stderr:; cat $at_stderr
   6171 echo stdout:; cat $at_stdout
   6172 case $at_status in
   6173    77) echo 77 > $at_status_file
   6174             exit 77;;
   6175    0) ;;
   6176    *) echo "headers.at:77: exit code was $at_status, expected 0"
   6177       at_failed=:;;
   6178 esac
   6179 if $at_failed; then
   6180 
   6181   echo 1 > $at_status_file
   6182   exit 1
   6183 fi
   6184 
   6185 $at_traceon
   6186 
   6187 
   6188       $at_traceoff
   6189       $at_times_p && times >$at_times_file
   6190     ) 5>&1 2>&1 | eval $at_tee_pipe
   6191     at_status=`cat $at_status_file`
   6192     ;;
   6193 
   6194   48 ) # 48. headers.at:78: Invalid CPP guards: 9foo
   6195     at_setup_line='headers.at:78'
   6196     at_desc='Invalid CPP guards: 9foo'
   6197     $at_quiet $ECHO_N " 48: Invalid CPP guards: 9foo                     $ECHO_C"
   6198     at_xfail=no
   6199     (
   6200       echo "48. headers.at:78: testing ..."
   6201       $at_traceon
   6202 
   6203 
   6204 # Possibly create inner directories.
   6205 dirname=`(dirname 9foo) 2>/dev/null ||
   6206 $as_expr X9foo : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
   6207 	 X9foo : 'X\(//\)[^/]' \| \
   6208 	 X9foo : 'X\(//\)$' \| \
   6209 	 X9foo : 'X\(/\)' \| \
   6210 	 .     : '\(.\)' 2>/dev/null ||
   6211 echo X9foo |
   6212     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
   6213   	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
   6214   	  /^X\(\/\/\)$/{ s//\1/; q; }
   6215   	  /^X\(\/\).*/{ s//\1/; q; }
   6216   	  s/.*/./; q'`
   6217 { if $as_mkdir_p; then
   6218     mkdir -p $dirname
   6219   else
   6220     as_dir=$dirname
   6221     as_dirs=
   6222     while test ! -d "$as_dir"; do
   6223       as_dirs="$as_dir $as_dirs"
   6224       as_dir=`(dirname "$as_dir") 2>/dev/null ||
   6225 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
   6226 	 X"$as_dir" : 'X\(//\)[^/]' \| \
   6227 	 X"$as_dir" : 'X\(//\)$' \| \
   6228 	 X"$as_dir" : 'X\(/\)' \| \
   6229 	 .     : '\(.\)' 2>/dev/null ||
   6230 echo X"$as_dir" |
   6231     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
   6232   	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
   6233   	  /^X\(\/\/\)$/{ s//\1/; q; }
   6234   	  /^X\(\/\).*/{ s//\1/; q; }
   6235   	  s/.*/./; q'`
   6236     done
   6237     test ! -n "$as_dirs" || mkdir $as_dirs
   6238   fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirname" >&5
   6239 echo "$as_me: error: cannot create directory $dirname" >&2;}
   6240    { (exit 1); exit 1; }; }; }
   6241 
   6242 
   6243 cat >9foo.y <<'_ATEOF'
   6244 %{
   6245 #ifdef HAVE_CONFIG_H
   6246 # include <config.h>
   6247   /* We don't need perfect functions for these tests. */
   6248 # undef malloc
   6249 # undef memcmp
   6250 # undef realloc
   6251 #endif
   6252 %}
   6253 
   6254 %{
   6255 #include <9foo.h>
   6256 void yyerror (const char *);
   6257 int yylex (void);
   6258 %}
   6259 %%
   6260 dummy:;
   6261 %%
   6262 #include <9foo.h>
   6263 _ATEOF
   6264 
   6265 
   6266 
   6267 $at_traceoff
   6268 echo "headers.at:78: bison --defines=9foo.h --output=y.tab.c 9foo.y"
   6269 echo headers.at:78 >$at_check_line_file
   6270 ( $at_traceon; bison --defines=9foo.h --output=y.tab.c 9foo.y ) >$at_stdout 2>$at_stder1
   6271 at_status=$?
   6272 grep '^ *+' $at_stder1 >&2
   6273 grep -v '^ *+' $at_stder1 >$at_stderr
   6274 at_failed=false
   6275 $at_diff $at_devnull $at_stderr || at_failed=:
   6276 $at_diff $at_devnull $at_stdout || at_failed=:
   6277 case $at_status in
   6278    77) echo 77 > $at_status_file
   6279             exit 77;;
   6280    0) ;;
   6281    *) echo "headers.at:78: exit code was $at_status, expected 0"
   6282       at_failed=:;;
   6283 esac
   6284 if $at_failed; then
   6285 
   6286   echo 1 > $at_status_file
   6287   exit 1
   6288 fi
   6289 
   6290 $at_traceon
   6291 
   6292 
   6293 $at_traceoff
   6294 echo "headers.at:78: \$CC \$CFLAGS \$CPPFLAGS -o y.tab.o -I. -c y.tab.c"
   6295 echo headers.at:78 >$at_check_line_file
   6296 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -o y.tab.o -I. -c y.tab.c ) >$at_stdout 2>$at_stder1
   6297 at_status=$?
   6298 grep '^ *+' $at_stder1 >&2
   6299 grep -v '^ *+' $at_stder1 >$at_stderr
   6300 at_failed=false
   6301 echo stderr:; cat $at_stderr
   6302 echo stdout:; cat $at_stdout
   6303 case $at_status in
   6304    77) echo 77 > $at_status_file
   6305             exit 77;;
   6306    0) ;;
   6307    *) echo "headers.at:78: exit code was $at_status, expected 0"
   6308       at_failed=:;;
   6309 esac
   6310 if $at_failed; then
   6311 
   6312   echo 1 > $at_status_file
   6313   exit 1
   6314 fi
   6315 
   6316 $at_traceon
   6317 
   6318 
   6319       $at_traceoff
   6320       $at_times_p && times >$at_times_file
   6321     ) 5>&1 2>&1 | eval $at_tee_pipe
   6322     at_status=`cat $at_status_file`
   6323     ;;
   6324 
   6325   49 ) # 49. headers.at:87: export YYLTYPE
   6326     at_setup_line='headers.at:87'
   6327     at_desc='export YYLTYPE'
   6328     $at_quiet $ECHO_N " 49: export YYLTYPE                               $ECHO_C"
   6329     at_xfail=no
   6330     (
   6331       echo "49. headers.at:87: testing ..."
   6332       $at_traceon
   6333 
   6334 
   6335 cat >input.y <<'_ATEOF'
   6336 %{
   6337 #ifdef HAVE_CONFIG_H
   6338 # include <config.h>
   6339   /* We don't need perfect functions for these tests. */
   6340 # undef malloc
   6341 # undef memcmp
   6342 # undef realloc
   6343 #endif
   6344 %}
   6345 
   6346 %locations
   6347 
   6348 %name-prefix="my_"
   6349 %{
   6350 #include <stdio.h>
   6351 #include <stdlib.h>
   6352 
   6353 static int
   6354 my_lex (void)
   6355 {
   6356   return EOF;
   6357 }
   6358 
   6359 static void
   6360 my_error (const char *msg)
   6361 {
   6362   fprintf (stderr, "%s\n", msg);
   6363 }
   6364 
   6365 %}
   6366 %%
   6367 exp:;
   6368 _ATEOF
   6369 
   6370 
   6371 
   6372 $at_traceoff
   6373 echo "headers.at:114: bison --defines -o input.c input.y"
   6374 echo headers.at:114 >$at_check_line_file
   6375 ( $at_traceon; bison --defines -o input.c input.y ) >$at_stdout 2>$at_stder1
   6376 at_status=$?
   6377 grep '^ *+' $at_stder1 >&2
   6378 grep -v '^ *+' $at_stder1 >$at_stderr
   6379 at_failed=false
   6380 $at_diff $at_devnull $at_stderr || at_failed=:
   6381 $at_diff $at_devnull $at_stdout || at_failed=:
   6382 case $at_status in
   6383    77) echo 77 > $at_status_file
   6384             exit 77;;
   6385    0) ;;
   6386    *) echo "headers.at:114: exit code was $at_status, expected 0"
   6387       at_failed=:;;
   6388 esac
   6389 if $at_failed; then
   6390 
   6391   echo 1 > $at_status_file
   6392   exit 1
   6393 fi
   6394 
   6395 $at_traceon
   6396 
   6397 
   6398 # YYLTYPE should be defined, and MY_LLOC declared.
   6399 cat >caller.c <<'_ATEOF'
   6400 #include "input.h"
   6401 YYLTYPE *my_llocp = &my_lloc;
   6402 
   6403 int my_parse (void);
   6404 
   6405 int
   6406 main (void)
   6407 {
   6408   return my_parse ();
   6409 }
   6410 _ATEOF
   6411 
   6412 
   6413 # Link and execute, just to make sure everything is fine (and in
   6414 # particular, that MY_LLOC is indeed defined somewhere).
   6415 $at_traceoff
   6416 echo "headers.at:132: \$CC \$CFLAGS \$CPPFLAGS -o caller.o -c caller.c"
   6417 echo headers.at:132 >$at_check_line_file
   6418 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -o caller.o -c caller.c ) >$at_stdout 2>$at_stder1
   6419 at_status=$?
   6420 grep '^ *+' $at_stder1 >&2
   6421 grep -v '^ *+' $at_stder1 >$at_stderr
   6422 at_failed=false
   6423 echo stderr:; cat $at_stderr
   6424 echo stdout:; cat $at_stdout
   6425 case $at_status in
   6426    77) echo 77 > $at_status_file
   6427             exit 77;;
   6428    0) ;;
   6429    *) echo "headers.at:132: exit code was $at_status, expected 0"
   6430       at_failed=:;;
   6431 esac
   6432 if $at_failed; then
   6433 
   6434   echo 1 > $at_status_file
   6435   exit 1
   6436 fi
   6437 
   6438 $at_traceon
   6439 
   6440 $at_traceoff
   6441 echo "headers.at:133: \$CC \$CFLAGS \$CPPFLAGS -o input.o -c input.c"
   6442 echo headers.at:133 >$at_check_line_file
   6443 ( $at_traceon; $CC $CFLAGS $CPPFLAGS -o input.o -c input.c ) >$at_stdout 2>$at_stder1
   6444 at_status=$?
   6445 grep '^ *+' $at_stder1 >&2
   6446 grep -v '^ *+' $at_stder1 >$at_stderr
   6447 at_failed=false
   6448 echo stderr:; cat $at_stderr
   6449 echo stdout:; cat $at_stdout
   6450 case $at_status in
   6451    77) echo 77 > $at_status_file
   6452             exit 77;;
   6453    0) ;;
   6454    *) echo "headers.at:133: exit code was $at_status, expected 0"
   6455       at_failed=:;;
   6456 esac
   6457 if $at_failed; then
   6458 
   6459   echo 1 > $at_status_file
   6460   exit 1
   6461 fi
   6462 
   6463 $at_traceon
   6464 
   6465 $at_traceoff
   6466 echo "headers.at:134: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o caller caller.o input.o \$LIBS"
   6467 echo headers.at:134 >$at_check_line_file
   6468 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o caller caller.o input.o $LIBS ) >$at_stdout 2>$at_stder1
   6469 at_status=$?
   6470 grep '^ *+' $at_stder1 >&2
   6471 grep -v '^ *+' $at_stder1 >$at_stderr
   6472 at_failed=false
   6473 echo stderr:; cat $at_stderr
   6474 echo stdout:; cat $at_stdout
   6475 case $at_status in
   6476    77) echo 77 > $at_status_file
   6477             exit 77;;
   6478    0) ;;
   6479    *) echo "headers.at:134: exit code was $at_status, expected 0"
   6480       at_failed=:;;
   6481 esac
   6482 if $at_failed; then
   6483 
   6484   echo 1 > $at_status_file
   6485   exit 1
   6486 fi
   6487 
   6488 $at_traceon
   6489 
   6490 $at_traceoff
   6491 echo "headers.at:135: \$PREPARSER ./caller"
   6492 echo headers.at:135 >$at_check_line_file
   6493 ( $at_traceon; $PREPARSER ./caller ) >$at_stdout 2>$at_stder1
   6494 at_status=$?
   6495 grep '^ *+' $at_stder1 >&2
   6496 grep -v '^ *+' $at_stder1 >$at_stderr
   6497 at_failed=false
   6498 $at_diff $at_devnull $at_stderr || at_failed=:
   6499 $at_diff $at_devnull $at_stdout || at_failed=:
   6500 case $at_status in
   6501    77) echo 77 > $at_status_file
   6502             exit 77;;
   6503    0) ;;
   6504    *) echo "headers.at:135: exit code was $at_status, expected 0"
   6505       at_failed=:;;
   6506 esac
   6507 if $at_failed; then
   6508 
   6509   echo 1 > $at_status_file
   6510   exit 1
   6511 fi
   6512 
   6513 $at_traceon
   6514 
   6515 
   6516       $at_traceoff
   6517       $at_times_p && times >$at_times_file
   6518     ) 5>&1 2>&1 | eval $at_tee_pipe
   6519     at_status=`cat $at_status_file`
   6520     ;;
   6521 
   6522 
   6523   banner-7 ) # Banner 7. actions.at:19
   6524     cat <<\_ATEOF
   6525 
   6526 User Actions.
   6527 
   6528 _ATEOF
   6529     ;;
   6530 
   6531   50 ) # 50. actions.at:25: Mid-rule actions
   6532     at_setup_line='actions.at:25'
   6533     at_desc='Mid-rule actions'
   6534     $at_quiet $ECHO_N " 50: Mid-rule actions                             $ECHO_C"
   6535     at_xfail=no
   6536     (
   6537       echo "50. actions.at:25: testing ..."
   6538       $at_traceon
   6539 
   6540 
   6541 # Bison once forgot the mid-rule actions.  It was because the action
   6542 # was attached to the host rule (the one with the mid-rule action),
   6543 # instead of being attached to the empty rule dedicated to this
   6544 # action.
   6545 
   6546 cat >input.y <<'_ATEOF'
   6547 %{
   6548 #ifdef HAVE_CONFIG_H
   6549 # include <config.h>
   6550   /* We don't need perfect functions for these tests. */
   6551 # undef malloc
   6552 # undef memcmp
   6553 # undef realloc
   6554 #endif
   6555 %}
   6556 
   6557 %error-verbose
   6558 %debug
   6559 %{
   6560 # include <stdio.h>
   6561 # include <stdlib.h>
   6562   static void yyerror (const char *msg);
   6563   static int yylex (void);
   6564 %}
   6565 %%
   6566 exp:     { putchar ('0'); }
   6567      '1' { putchar ('1'); }
   6568      '2' { putchar ('2'); }
   6569      '3' { putchar ('3'); }
   6570      '4' { putchar ('4'); }
   6571      '5' { putchar ('5'); }
   6572      '6' { putchar ('6'); }
   6573      '7' { putchar ('7'); }
   6574      '8' { putchar ('8'); }
   6575      '9' { putchar ('9'); }
   6576          { putchar ('\n'); }
   6577    ;
   6578 %%
   6579 static int
   6580 yylex (void)
   6581 {
   6582   static const char *input = "123456789";
   6583   return *input++;
   6584 }
   6585 
   6586 static void
   6587 yyerror (const char *msg)
   6588 {
   6589   fprintf (stderr, "%s\n", msg);
   6590 }
   6591 
   6592 int
   6593 main (void)
   6594 {
   6595   return yyparse ();
   6596 }
   6597 _ATEOF
   6598 
   6599 
   6600 
   6601 $at_traceoff
   6602 echo "actions.at:75: bison -d -v -o input.c input.y"
   6603 echo actions.at:75 >$at_check_line_file
   6604 ( $at_traceon; bison -d -v -o input.c input.y ) >$at_stdout 2>$at_stder1
   6605 at_status=$?
   6606 grep '^ *+' $at_stder1 >&2
   6607 grep -v '^ *+' $at_stder1 >$at_stderr
   6608 at_failed=false
   6609 $at_diff $at_devnull $at_stderr || at_failed=:
   6610 $at_diff $at_devnull $at_stdout || at_failed=:
   6611 case $at_status in
   6612    77) echo 77 > $at_status_file
   6613             exit 77;;
   6614    0) ;;
   6615    *) echo "actions.at:75: exit code was $at_status, expected 0"
   6616       at_failed=:;;
   6617 esac
   6618 if $at_failed; then
   6619 
   6620   echo 1 > $at_status_file
   6621   exit 1
   6622 fi
   6623 
   6624 $at_traceon
   6625 
   6626 $at_traceoff
   6627 echo "actions.at:76: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   6628 echo actions.at:76 >$at_check_line_file
   6629 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   6630 at_status=$?
   6631 grep '^ *+' $at_stder1 >&2
   6632 grep -v '^ *+' $at_stder1 >$at_stderr
   6633 at_failed=false
   6634 echo stderr:; cat $at_stderr
   6635 echo stdout:; cat $at_stdout
   6636 case $at_status in
   6637    77) echo 77 > $at_status_file
   6638             exit 77;;
   6639    0) ;;
   6640    *) echo "actions.at:76: exit code was $at_status, expected 0"
   6641       at_failed=:;;
   6642 esac
   6643 if $at_failed; then
   6644 
   6645   echo 1 > $at_status_file
   6646   exit 1
   6647 fi
   6648 
   6649 $at_traceon
   6650 
   6651 $at_traceoff
   6652 echo "actions.at:79: \$PREPARSER ./input"
   6653 echo actions.at:79 >$at_check_line_file
   6654 ( $at_traceon; $PREPARSER ./input ) >$at_stdout 2>$at_stder1
   6655 at_status=$?
   6656 grep '^ *+' $at_stder1 >&2
   6657 grep -v '^ *+' $at_stder1 >$at_stderr
   6658 at_failed=false
   6659 $at_diff $at_devnull $at_stderr || at_failed=:
   6660 echo >>$at_stdout; echo "0123456789
   6661 " | $at_diff - $at_stdout || at_failed=:
   6662 case $at_status in
   6663    77) echo 77 > $at_status_file
   6664             exit 77;;
   6665    0) ;;
   6666    *) echo "actions.at:79: exit code was $at_status, expected 0"
   6667       at_failed=:;;
   6668 esac
   6669 if $at_failed; then
   6670 
   6671   echo 1 > $at_status_file
   6672   exit 1
   6673 fi
   6674 
   6675 $at_traceon
   6676 
   6677 
   6678       $at_traceoff
   6679       $at_times_p && times >$at_times_file
   6680     ) 5>&1 2>&1 | eval $at_tee_pipe
   6681     at_status=`cat $at_status_file`
   6682     ;;
   6683 
   6684   51 ) # 51. actions.at:91: Exotic Dollars
   6685     at_setup_line='actions.at:91'
   6686     at_desc='Exotic Dollars'
   6687     $at_quiet $ECHO_N " 51: Exotic Dollars                               $ECHO_C"
   6688     at_xfail=no
   6689     (
   6690       echo "51. actions.at:91: testing ..."
   6691       $at_traceon
   6692 
   6693 
   6694 cat >input.y <<'_ATEOF'
   6695 %{
   6696 #ifdef HAVE_CONFIG_H
   6697 # include <config.h>
   6698   /* We don't need perfect functions for these tests. */
   6699 # undef malloc
   6700 # undef memcmp
   6701 # undef realloc
   6702 #endif
   6703 %}
   6704 
   6705 %error-verbose
   6706 %debug
   6707 %{
   6708 # include <stdio.h>
   6709 # include <stdlib.h>
   6710   static void yyerror (const char *msg);
   6711   static int yylex (void);
   6712 # define USE(Var)
   6713 %}
   6714 
   6715 %union
   6716 {
   6717   int val;
   6718 };
   6719 
   6720 %type <val> a_1 a_2 a_5
   6721             sum_of_the_five_previous_values
   6722 
   6723 %%
   6724 exp: a_1 a_2 { $<val>$ = 3; } { $<val>$ = $<val>3 + 1; } a_5
   6725      sum_of_the_five_previous_values
   6726     {
   6727        USE (($1, $2, $<foo>3, $<foo>4, $5));
   6728        printf ("%d\n", $6);
   6729     }
   6730 ;
   6731 a_1: { $$ = 1; };
   6732 a_2: { $$ = 2; };
   6733 a_5: { $$ = 5; };
   6734 
   6735 sum_of_the_five_previous_values:
   6736     {
   6737        $$ = $<val>0 + $<val>-1 + $<val>-2 + $<val>-3 + $<val>-4;
   6738     }
   6739 ;
   6740 
   6741 %%
   6742 static int
   6743 yylex (void)
   6744 {
   6745   return EOF;
   6746 }
   6747 
   6748 static void
   6749 yyerror (const char *msg)
   6750 {
   6751   fprintf (stderr, "%s\n", msg);
   6752 }
   6753 
   6754 int
   6755 main (void)
   6756 {
   6757   return yyparse ();
   6758 }
   6759 _ATEOF
   6760 
   6761 
   6762 
   6763 $at_traceoff
   6764 echo "actions.at:150: bison -d -v -o input.c input.y"
   6765 echo actions.at:150 >$at_check_line_file
   6766 ( $at_traceon; bison -d -v -o input.c input.y ) >$at_stdout 2>$at_stder1
   6767 at_status=$?
   6768 grep '^ *+' $at_stder1 >&2
   6769 grep -v '^ *+' $at_stder1 >$at_stderr
   6770 at_failed=false
   6771 $at_diff $at_devnull $at_stderr || at_failed=:
   6772 $at_diff $at_devnull $at_stdout || at_failed=:
   6773 case $at_status in
   6774    77) echo 77 > $at_status_file
   6775             exit 77;;
   6776    0) ;;
   6777    *) echo "actions.at:150: exit code was $at_status, expected 0"
   6778       at_failed=:;;
   6779 esac
   6780 if $at_failed; then
   6781 
   6782   echo 1 > $at_status_file
   6783   exit 1
   6784 fi
   6785 
   6786 $at_traceon
   6787 
   6788 $at_traceoff
   6789 echo "actions.at:151: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   6790 echo actions.at:151 >$at_check_line_file
   6791 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   6792 at_status=$?
   6793 grep '^ *+' $at_stder1 >&2
   6794 grep -v '^ *+' $at_stder1 >$at_stderr
   6795 at_failed=false
   6796 echo stderr:; cat $at_stderr
   6797 echo stdout:; cat $at_stdout
   6798 case $at_status in
   6799    77) echo 77 > $at_status_file
   6800             exit 77;;
   6801    0) ;;
   6802    *) echo "actions.at:151: exit code was $at_status, expected 0"
   6803       at_failed=:;;
   6804 esac
   6805 if $at_failed; then
   6806 
   6807   echo 1 > $at_status_file
   6808   exit 1
   6809 fi
   6810 
   6811 $at_traceon
   6812 
   6813 $at_traceoff
   6814 echo "actions.at:154: \$PREPARSER ./input"
   6815 echo actions.at:154 >$at_check_line_file
   6816 ( $at_traceon; $PREPARSER ./input ) >$at_stdout 2>$at_stder1
   6817 at_status=$?
   6818 grep '^ *+' $at_stder1 >&2
   6819 grep -v '^ *+' $at_stder1 >$at_stderr
   6820 at_failed=false
   6821 $at_diff $at_devnull $at_stderr || at_failed=:
   6822 echo >>$at_stdout; echo "15
   6823 " | $at_diff - $at_stdout || at_failed=:
   6824 case $at_status in
   6825    77) echo 77 > $at_status_file
   6826             exit 77;;
   6827    0) ;;
   6828    *) echo "actions.at:154: exit code was $at_status, expected 0"
   6829       at_failed=:;;
   6830 esac
   6831 if $at_failed; then
   6832 
   6833   echo 1 > $at_status_file
   6834   exit 1
   6835 fi
   6836 
   6837 $at_traceon
   6838 
   6839 
   6840       $at_traceoff
   6841       $at_times_p && times >$at_times_file
   6842     ) 5>&1 2>&1 | eval $at_tee_pipe
   6843     at_status=`cat $at_status_file`
   6844     ;;
   6845 
   6846   52 ) # 52. actions.at:527: Printers and Destructors :
   6847     at_setup_line='actions.at:527'
   6848     at_desc='Printers and Destructors : '
   6849     $at_quiet $ECHO_N " 52: Printers and Destructors :                   $ECHO_C"
   6850     at_xfail=no
   6851     (
   6852       echo "52. actions.at:527: testing ..."
   6853       $at_traceon
   6854 
   6855 
   6856 
   6857 # Make sure complex $n work.
   6858 
   6859 # Be sure to pass all the %directives to this macro to have correct
   6860 # helping macros.  So don't put any directly in the Bison file.
   6861 
   6862 
   6863 
   6864 
   6865 # Using yacc.c?
   6866 
   6867 
   6868 
   6869 
   6870 
   6871 
   6872 
   6873 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   6874 
   6875 # yyerror always sees the locations (when activated), except if
   6876 # yacc & pure & !param.
   6877 
   6878 
   6879 # The interface is pure: either because %pure-parser, or because we
   6880 # are using the C++ parsers.
   6881 
   6882 
   6883 
   6884 
   6885 
   6886 
   6887 
   6888 
   6889 
   6890 
   6891 
   6892 cat >input.y <<'_ATEOF'
   6893 %{
   6894 #ifdef HAVE_CONFIG_H
   6895 # include <config.h>
   6896   /* We don't need perfect functions for these tests. */
   6897 # undef malloc
   6898 # undef memcmp
   6899 # undef realloc
   6900 #endif
   6901 %}
   6902 
   6903 %{
   6904 #include <stdio.h>
   6905 #include <stdlib.h>
   6906 #include <assert.h>
   6907 
   6908 #define YYINITDEPTH 10
   6909 #define YYMAXDEPTH 10
   6910 #define RANGE(Location) (Location).first_line, (Location).last_line
   6911 %}
   6912 
   6913 %error-verbose
   6914 %debug
   6915 %verbose
   6916 %locations
   6917 
   6918 
   6919 
   6920 
   6921 %{
   6922 
   6923 static int yylex (void);
   6924 static void yyerror (const char *msg);
   6925 %}
   6926 
   6927 
   6928 
   6929 %printer
   6930   {
   6931     fprintf (yyoutput, "%d", $$);
   6932   }
   6933   input line thing 'x' 'y'
   6934 
   6935 %destructor
   6936   { printf ("Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
   6937   input
   6938 
   6939 %destructor
   6940   { printf ("Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); }
   6941   line
   6942 
   6943 %destructor
   6944   { printf ("Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
   6945   thing
   6946 
   6947 %destructor
   6948   { printf ("Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
   6949   'x'
   6950 
   6951 %destructor
   6952   { printf ("Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); }
   6953   'y'
   6954 
   6955 %%
   6956 /*
   6957    This grammar is made to exercise error recovery.
   6958    "Lines" starting with `(' support error recovery, with
   6959    ')' as synchronizing token.  Lines starting with 'x' can never
   6960    be recovered from if in error.
   6961 */
   6962 
   6963 input:
   6964   /* Nothing. */
   6965     {
   6966       $$ = 0;
   6967       printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
   6968     }
   6969 | line input /* Right recursive to load the stack so that popping at
   6970 		EOF can	be exercised.  */
   6971     {
   6972       $$ = 2;
   6973       printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
   6974 	      $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
   6975     }
   6976 ;
   6977 
   6978 line:
   6979   thing thing thing ';'
   6980     {
   6981       $$ = $1;
   6982       printf ("line (%d@%d-%d): thing (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ';' (%d@%d-%d)\n",
   6983               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   6984               $3, RANGE (@3), $4, RANGE (@4));
   6985     }
   6986 | '(' thing thing ')'
   6987     {
   6988       $$ = $1;
   6989       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   6990               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   6991               $3, RANGE (@3), $4, RANGE (@4));
   6992     }
   6993 | '(' thing ')'
   6994     {
   6995       $$ = $1;
   6996       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   6997               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), $3, RANGE (@3));
   6998     }
   6999 | '(' error ')'
   7000     {
   7001       $$ = -1;
   7002       printf ("line (%d@%d-%d): '(' (%d@%d-%d) error (@%d-%d) ')' (%d@%d-%d)\n",
   7003               $$, RANGE (@$), $1, RANGE (@1), RANGE (@2), $3, RANGE (@3));
   7004     }
   7005 ;
   7006 
   7007 thing:
   7008   'x'
   7009     {
   7010       $$ = $1;
   7011       printf ("thing (%d@%d-%d): 'x' (%d@%d-%d)\n",
   7012               $$, RANGE (@$), $1, RANGE (@1));
   7013     }
   7014 ;
   7015 %%
   7016 /* Alias to ARGV[1]. */
   7017 const char *source = 0;
   7018 
   7019 static int
   7020 yylex (void)
   7021 {
   7022   static unsigned int counter = 0;
   7023 
   7024   int c = (yylval) = counter++;
   7025   /* As in BASIC, line numbers go from 10 to 10.  */
   7026  (yylloc).first_line = (yylloc).first_column = 10 * c;
   7027   (yylloc).last_line = (yylloc).last_column = (yylloc).first_line + 9;
   7028 
   7029 
   7030   if (source[c])
   7031     printf ("sending: '%c'", source[c]);
   7032   else
   7033     printf ("sending: EOF");
   7034   printf (" (%d@%d-%d)\n", c, RANGE ((yylloc)));
   7035   return source[c];
   7036 }
   7037 
   7038 static void
   7039 yyerror (const char *msg)
   7040 {
   7041   printf ("%d-%d: %s\n", RANGE (yylloc), msg);
   7042 }
   7043 
   7044 int
   7045 main (int argc, const char *argv[])
   7046 {
   7047   int status;
   7048   yydebug = !!getenv ("YYDEBUG");
   7049   assert (argc == 2);
   7050   source = argv[1];
   7051   status = yyparse ();
   7052   switch (status)
   7053     {
   7054       case 0: printf ("Successful parse.\n"); break;
   7055       case 1: printf ("Parsing FAILED.\n"); break;
   7056       default: printf ("Parsing FAILED (status %d).\n", status); break;
   7057     }
   7058   return status;
   7059 }
   7060 _ATEOF
   7061 
   7062 
   7063 
   7064 $at_traceoff
   7065 echo "actions.at:527: bison -o input.c input.y"
   7066 echo actions.at:527 >$at_check_line_file
   7067 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   7068 at_status=$?
   7069 grep '^ *+' $at_stder1 >&2
   7070 grep -v '^ *+' $at_stder1 >$at_stderr
   7071 at_failed=false
   7072 $at_diff $at_devnull $at_stderr || at_failed=:
   7073 $at_diff $at_devnull $at_stdout || at_failed=:
   7074 case $at_status in
   7075    77) echo 77 > $at_status_file
   7076             exit 77;;
   7077    0) ;;
   7078    *) echo "actions.at:527: exit code was $at_status, expected 0"
   7079       at_failed=:;;
   7080 esac
   7081 if $at_failed; then
   7082 
   7083   echo 1 > $at_status_file
   7084   exit 1
   7085 fi
   7086 
   7087 $at_traceon
   7088 
   7089    $at_traceoff
   7090 echo "actions.at:527: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   7091 echo actions.at:527 >$at_check_line_file
   7092 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   7093 at_status=$?
   7094 grep '^ *+' $at_stder1 >&2
   7095 grep -v '^ *+' $at_stder1 >$at_stderr
   7096 at_failed=false
   7097 echo stderr:; cat $at_stderr
   7098 echo stdout:; cat $at_stdout
   7099 case $at_status in
   7100    77) echo 77 > $at_status_file
   7101             exit 77;;
   7102    0) ;;
   7103    *) echo "actions.at:527: exit code was $at_status, expected 0"
   7104       at_failed=:;;
   7105 esac
   7106 if $at_failed; then
   7107 
   7108   echo 1 > $at_status_file
   7109   exit 1
   7110 fi
   7111 
   7112 $at_traceon
   7113 
   7114 
   7115 
   7116 # Check the location of "empty"
   7117 # -----------------------------
   7118 # I.e., epsilon-reductions, as in "(x)" which ends by reducing
   7119 # an empty "line" nterm.
   7120 # FIXME: This location is not satisfying.  Depend on the lookahead?
   7121 $at_traceoff
   7122 echo "actions.at:527: \$PREPARSER ./input '(x)'"
   7123 echo actions.at:527 >$at_check_line_file
   7124 ( $at_traceon; $PREPARSER ./input '(x)' ) >$at_stdout 2>$at_stder1
   7125 at_status=$?
   7126 grep '^ *+' $at_stder1 >&2
   7127 grep -v '^ *+' $at_stder1 >$at_stderr
   7128 at_failed=false
   7129 $at_diff $at_devnull $at_stderr || at_failed=:
   7130 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   7131 sending: 'x' (1@10-19)
   7132 thing (1@10-19): 'x' (1@10-19)
   7133 sending: ')' (2@20-29)
   7134 line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
   7135 sending: EOF (3@30-39)
   7136 input (0@29-29): /* Nothing */
   7137 input (2@0-29): line (0@0-29) input (0@29-29)
   7138 Freeing nterm input (2@0-29)
   7139 Successful parse.
   7140 " | $at_diff - $at_stdout || at_failed=:
   7141 case $at_status in
   7142    77) echo 77 > $at_status_file
   7143             exit 77;;
   7144    0) ;;
   7145    *) echo "actions.at:527: exit code was $at_status, expected 0"
   7146       at_failed=:;;
   7147 esac
   7148 if $at_failed; then
   7149 
   7150   echo 1 > $at_status_file
   7151   exit 1
   7152 fi
   7153 
   7154 $at_traceon
   7155 
   7156 
   7157 
   7158 # Check locations in error recovery
   7159 # ---------------------------------
   7160 # '(y)' is an error, but can be recovered from.  But what's the location
   7161 # of the error itself ('y'), and of the resulting reduction ('(error)').
   7162 $at_traceoff
   7163 echo "actions.at:527: \$PREPARSER ./input '(y)'"
   7164 echo actions.at:527 >$at_check_line_file
   7165 ( $at_traceon; $PREPARSER ./input '(y)' ) >$at_stdout 2>$at_stder1
   7166 at_status=$?
   7167 grep '^ *+' $at_stder1 >&2
   7168 grep -v '^ *+' $at_stder1 >$at_stderr
   7169 at_failed=false
   7170 $at_diff $at_devnull $at_stderr || at_failed=:
   7171 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   7172 sending: 'y' (1@10-19)
   7173 10-19: syntax error, unexpected 'y', expecting 'x'
   7174 Freeing token 'y' (1@10-19)
   7175 sending: ')' (2@20-29)
   7176 line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
   7177 sending: EOF (3@30-39)
   7178 input (0@29-29): /* Nothing */
   7179 input (2@0-29): line (-1@0-29) input (0@29-29)
   7180 Freeing nterm input (2@0-29)
   7181 Successful parse.
   7182 " | $at_diff - $at_stdout || at_failed=:
   7183 case $at_status in
   7184    77) echo 77 > $at_status_file
   7185             exit 77;;
   7186    0) ;;
   7187    *) echo "actions.at:527: exit code was $at_status, expected 0"
   7188       at_failed=:;;
   7189 esac
   7190 if $at_failed; then
   7191 
   7192   echo 1 > $at_status_file
   7193   exit 1
   7194 fi
   7195 
   7196 $at_traceon
   7197 
   7198 
   7199 
   7200 # Syntax errors caught by the parser
   7201 # ----------------------------------
   7202 # Exercise the discarding of stack top and input until `error'
   7203 # can be reduced.
   7204 #
   7205 #     '(', 'x', 'x', 'x', 'x', 'x', ')',
   7206 #
   7207 # Load the stack and provoke an error that cannot be caught by the
   7208 # grammar, to check that the stack is cleared.  And make sure the
   7209 # lookahead is freed.
   7210 #
   7211 #     '(', 'x', ')',
   7212 #     '(', 'x', ')',
   7213 #     'y'
   7214 $at_traceoff
   7215 echo "actions.at:527: \$PREPARSER ./input '(xxxxx)(x)(x)y'"
   7216 echo actions.at:527 >$at_check_line_file
   7217 ( $at_traceon; $PREPARSER ./input '(xxxxx)(x)(x)y' ) >$at_stdout 2>$at_stder1
   7218 at_status=$?
   7219 grep '^ *+' $at_stder1 >&2
   7220 grep -v '^ *+' $at_stder1 >$at_stderr
   7221 at_failed=false
   7222 $at_diff $at_devnull $at_stderr || at_failed=:
   7223 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   7224 sending: 'x' (1@10-19)
   7225 thing (1@10-19): 'x' (1@10-19)
   7226 sending: 'x' (2@20-29)
   7227 thing (2@20-29): 'x' (2@20-29)
   7228 sending: 'x' (3@30-39)
   7229 30-39: syntax error, unexpected 'x', expecting ')'
   7230 Freeing nterm thing (2@20-29)
   7231 Freeing nterm thing (1@10-19)
   7232 Freeing token 'x' (3@30-39)
   7233 sending: 'x' (4@40-49)
   7234 Freeing token 'x' (4@40-49)
   7235 sending: 'x' (5@50-59)
   7236 Freeing token 'x' (5@50-59)
   7237 sending: ')' (6@60-69)
   7238 line (-1@0-69): '(' (0@0-9) error (@10-59) ')' (6@60-69)
   7239 sending: '(' (7@70-79)
   7240 sending: 'x' (8@80-89)
   7241 thing (8@80-89): 'x' (8@80-89)
   7242 sending: ')' (9@90-99)
   7243 line (7@70-99): '(' (7@70-79) thing (8@80-89) ')' (9@90-99)
   7244 sending: '(' (10@100-109)
   7245 sending: 'x' (11@110-119)
   7246 thing (11@110-119): 'x' (11@110-119)
   7247 sending: ')' (12@120-129)
   7248 line (10@100-129): '(' (10@100-109) thing (11@110-119) ')' (12@120-129)
   7249 sending: 'y' (13@130-139)
   7250 input (0@129-129): /* Nothing */
   7251 input (2@100-129): line (10@100-129) input (0@129-129)
   7252 input (2@70-129): line (7@70-99) input (2@100-129)
   7253 input (2@0-129): line (-1@0-69) input (2@70-129)
   7254 130-139: syntax error, unexpected 'y', expecting \$end
   7255 Freeing nterm input (2@0-129)
   7256 Freeing token 'y' (13@130-139)
   7257 Parsing FAILED.
   7258 " | $at_diff - $at_stdout || at_failed=:
   7259 case $at_status in
   7260    77) echo 77 > $at_status_file
   7261             exit 77;;
   7262    1) ;;
   7263    *) echo "actions.at:527: exit code was $at_status, expected 1"
   7264       at_failed=:;;
   7265 esac
   7266 if $at_failed; then
   7267 
   7268   echo 1 > $at_status_file
   7269   exit 1
   7270 fi
   7271 
   7272 $at_traceon
   7273 
   7274 
   7275 # Check destruction upon stack overflow
   7276 # -------------------------------------
   7277 # Upon stack overflow, all symbols on the stack should be destroyed.
   7278 # Only check for yacc.c.
   7279 
   7280 $at_traceoff
   7281 echo "actions.at:527: \$PREPARSER ./input '(x)(x)(x)(x)(x)(x)(x)'"
   7282 echo actions.at:527 >$at_check_line_file
   7283 ( $at_traceon; $PREPARSER ./input '(x)(x)(x)(x)(x)(x)(x)' ) >$at_stdout 2>$at_stder1
   7284 at_status=$?
   7285 grep '^ *+' $at_stder1 >&2
   7286 grep -v '^ *+' $at_stder1 >$at_stderr
   7287 at_failed=false
   7288 $at_diff $at_devnull $at_stderr || at_failed=:
   7289 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   7290 sending: 'x' (1@10-19)
   7291 thing (1@10-19): 'x' (1@10-19)
   7292 sending: ')' (2@20-29)
   7293 line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
   7294 sending: '(' (3@30-39)
   7295 sending: 'x' (4@40-49)
   7296 thing (4@40-49): 'x' (4@40-49)
   7297 sending: ')' (5@50-59)
   7298 line (3@30-59): '(' (3@30-39) thing (4@40-49) ')' (5@50-59)
   7299 sending: '(' (6@60-69)
   7300 sending: 'x' (7@70-79)
   7301 thing (7@70-79): 'x' (7@70-79)
   7302 sending: ')' (8@80-89)
   7303 line (6@60-89): '(' (6@60-69) thing (7@70-79) ')' (8@80-89)
   7304 sending: '(' (9@90-99)
   7305 sending: 'x' (10@100-109)
   7306 thing (10@100-109): 'x' (10@100-109)
   7307 sending: ')' (11@110-119)
   7308 line (9@90-119): '(' (9@90-99) thing (10@100-109) ')' (11@110-119)
   7309 sending: '(' (12@120-129)
   7310 sending: 'x' (13@130-139)
   7311 thing (13@130-139): 'x' (13@130-139)
   7312 sending: ')' (14@140-149)
   7313 line (12@120-149): '(' (12@120-129) thing (13@130-139) ')' (14@140-149)
   7314 sending: '(' (15@150-159)
   7315 sending: 'x' (16@160-169)
   7316 thing (16@160-169): 'x' (16@160-169)
   7317 sending: ')' (17@170-179)
   7318 line (15@150-179): '(' (15@150-159) thing (16@160-169) ')' (17@170-179)
   7319 sending: '(' (18@180-189)
   7320 sending: 'x' (19@190-199)
   7321 thing (19@190-199): 'x' (19@190-199)
   7322 sending: ')' (20@200-209)
   7323 200-209: memory exhausted
   7324 Freeing nterm thing (19@190-199)
   7325 Freeing nterm line (15@150-179)
   7326 Freeing nterm line (12@120-149)
   7327 Freeing nterm line (9@90-119)
   7328 Freeing nterm line (6@60-89)
   7329 Freeing nterm line (3@30-59)
   7330 Freeing nterm line (0@0-29)
   7331 Parsing FAILED (status 2).
   7332 " | $at_diff - $at_stdout || at_failed=:
   7333 case $at_status in
   7334    77) echo 77 > $at_status_file
   7335             exit 77;;
   7336    2) ;;
   7337    *) echo "actions.at:527: exit code was $at_status, expected 2"
   7338       at_failed=:;;
   7339 esac
   7340 if $at_failed; then
   7341 
   7342   echo 1 > $at_status_file
   7343   exit 1
   7344 fi
   7345 
   7346 $at_traceon
   7347 
   7348 
   7349 
   7350 
   7351 
   7352       $at_traceoff
   7353       $at_times_p && times >$at_times_file
   7354     ) 5>&1 2>&1 | eval $at_tee_pipe
   7355     at_status=`cat $at_status_file`
   7356     ;;
   7357 
   7358   53 ) # 53. actions.at:528: Printers and Destructors with union:
   7359     at_setup_line='actions.at:528'
   7360     at_desc='Printers and Destructors with union: '
   7361     $at_quiet $ECHO_N " 53: Printers and Destructors with union:         $ECHO_C"
   7362     at_xfail=no
   7363     (
   7364       echo "53. actions.at:528: testing ..."
   7365       $at_traceon
   7366 
   7367 
   7368 
   7369 # Make sure complex $n work.
   7370 
   7371 # Be sure to pass all the %directives to this macro to have correct
   7372 # helping macros.  So don't put any directly in the Bison file.
   7373 
   7374 
   7375 
   7376 
   7377 # Using yacc.c?
   7378 
   7379 
   7380 
   7381 
   7382 
   7383 
   7384 
   7385 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   7386 
   7387 # yyerror always sees the locations (when activated), except if
   7388 # yacc & pure & !param.
   7389 
   7390 
   7391 # The interface is pure: either because %pure-parser, or because we
   7392 # are using the C++ parsers.
   7393 
   7394 
   7395 
   7396 
   7397 
   7398 
   7399 
   7400 
   7401 
   7402 
   7403 
   7404 cat >input.y <<'_ATEOF'
   7405 %{
   7406 #ifdef HAVE_CONFIG_H
   7407 # include <config.h>
   7408   /* We don't need perfect functions for these tests. */
   7409 # undef malloc
   7410 # undef memcmp
   7411 # undef realloc
   7412 #endif
   7413 %}
   7414 
   7415 %{
   7416 #include <stdio.h>
   7417 #include <stdlib.h>
   7418 #include <assert.h>
   7419 
   7420 #define YYINITDEPTH 10
   7421 #define YYMAXDEPTH 10
   7422 #define RANGE(Location) (Location).first_line, (Location).last_line
   7423 %}
   7424 
   7425 %error-verbose
   7426 %debug
   7427 %verbose
   7428 %locations
   7429 
   7430 %union
   7431 {
   7432   int ival;
   7433 }
   7434 
   7435 
   7436 %{
   7437 
   7438 static int yylex (void);
   7439 static void yyerror (const char *msg);
   7440 %}
   7441 
   7442 %type <ival> '(' 'x' 'y' ')' ';' thing line input
   7443 
   7444 %printer
   7445   {
   7446     fprintf (yyoutput, "%d", $$);
   7447   }
   7448   input line thing 'x' 'y'
   7449 
   7450 %destructor
   7451   { printf ("Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
   7452   input
   7453 
   7454 %destructor
   7455   { printf ("Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); }
   7456   line
   7457 
   7458 %destructor
   7459   { printf ("Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
   7460   thing
   7461 
   7462 %destructor
   7463   { printf ("Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
   7464   'x'
   7465 
   7466 %destructor
   7467   { printf ("Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); }
   7468   'y'
   7469 
   7470 %%
   7471 /*
   7472    This grammar is made to exercise error recovery.
   7473    "Lines" starting with `(' support error recovery, with
   7474    ')' as synchronizing token.  Lines starting with 'x' can never
   7475    be recovered from if in error.
   7476 */
   7477 
   7478 input:
   7479   /* Nothing. */
   7480     {
   7481       $$ = 0;
   7482       printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
   7483     }
   7484 | line input /* Right recursive to load the stack so that popping at
   7485 		EOF can	be exercised.  */
   7486     {
   7487       $$ = 2;
   7488       printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
   7489 	      $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
   7490     }
   7491 ;
   7492 
   7493 line:
   7494   thing thing thing ';'
   7495     {
   7496       $$ = $1;
   7497       printf ("line (%d@%d-%d): thing (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ';' (%d@%d-%d)\n",
   7498               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   7499               $3, RANGE (@3), $4, RANGE (@4));
   7500     }
   7501 | '(' thing thing ')'
   7502     {
   7503       $$ = $1;
   7504       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   7505               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   7506               $3, RANGE (@3), $4, RANGE (@4));
   7507     }
   7508 | '(' thing ')'
   7509     {
   7510       $$ = $1;
   7511       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   7512               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), $3, RANGE (@3));
   7513     }
   7514 | '(' error ')'
   7515     {
   7516       $$ = -1;
   7517       printf ("line (%d@%d-%d): '(' (%d@%d-%d) error (@%d-%d) ')' (%d@%d-%d)\n",
   7518               $$, RANGE (@$), $1, RANGE (@1), RANGE (@2), $3, RANGE (@3));
   7519     }
   7520 ;
   7521 
   7522 thing:
   7523   'x'
   7524     {
   7525       $$ = $1;
   7526       printf ("thing (%d@%d-%d): 'x' (%d@%d-%d)\n",
   7527               $$, RANGE (@$), $1, RANGE (@1));
   7528     }
   7529 ;
   7530 %%
   7531 /* Alias to ARGV[1]. */
   7532 const char *source = 0;
   7533 
   7534 static int
   7535 yylex (void)
   7536 {
   7537   static unsigned int counter = 0;
   7538 
   7539   int c = (yylval).ival = counter++;
   7540   /* As in BASIC, line numbers go from 10 to 10.  */
   7541  (yylloc).first_line = (yylloc).first_column = 10 * c;
   7542   (yylloc).last_line = (yylloc).last_column = (yylloc).first_line + 9;
   7543 
   7544 
   7545   if (source[c])
   7546     printf ("sending: '%c'", source[c]);
   7547   else
   7548     printf ("sending: EOF");
   7549   printf (" (%d@%d-%d)\n", c, RANGE ((yylloc)));
   7550   return source[c];
   7551 }
   7552 
   7553 static void
   7554 yyerror (const char *msg)
   7555 {
   7556   printf ("%d-%d: %s\n", RANGE (yylloc), msg);
   7557 }
   7558 
   7559 int
   7560 main (int argc, const char *argv[])
   7561 {
   7562   int status;
   7563   yydebug = !!getenv ("YYDEBUG");
   7564   assert (argc == 2);
   7565   source = argv[1];
   7566   status = yyparse ();
   7567   switch (status)
   7568     {
   7569       case 0: printf ("Successful parse.\n"); break;
   7570       case 1: printf ("Parsing FAILED.\n"); break;
   7571       default: printf ("Parsing FAILED (status %d).\n", status); break;
   7572     }
   7573   return status;
   7574 }
   7575 _ATEOF
   7576 
   7577 
   7578 
   7579 $at_traceoff
   7580 echo "actions.at:528: bison -o input.c input.y"
   7581 echo actions.at:528 >$at_check_line_file
   7582 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   7583 at_status=$?
   7584 grep '^ *+' $at_stder1 >&2
   7585 grep -v '^ *+' $at_stder1 >$at_stderr
   7586 at_failed=false
   7587 $at_diff $at_devnull $at_stderr || at_failed=:
   7588 $at_diff $at_devnull $at_stdout || at_failed=:
   7589 case $at_status in
   7590    77) echo 77 > $at_status_file
   7591             exit 77;;
   7592    0) ;;
   7593    *) echo "actions.at:528: exit code was $at_status, expected 0"
   7594       at_failed=:;;
   7595 esac
   7596 if $at_failed; then
   7597 
   7598   echo 1 > $at_status_file
   7599   exit 1
   7600 fi
   7601 
   7602 $at_traceon
   7603 
   7604    $at_traceoff
   7605 echo "actions.at:528: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   7606 echo actions.at:528 >$at_check_line_file
   7607 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   7608 at_status=$?
   7609 grep '^ *+' $at_stder1 >&2
   7610 grep -v '^ *+' $at_stder1 >$at_stderr
   7611 at_failed=false
   7612 echo stderr:; cat $at_stderr
   7613 echo stdout:; cat $at_stdout
   7614 case $at_status in
   7615    77) echo 77 > $at_status_file
   7616             exit 77;;
   7617    0) ;;
   7618    *) echo "actions.at:528: exit code was $at_status, expected 0"
   7619       at_failed=:;;
   7620 esac
   7621 if $at_failed; then
   7622 
   7623   echo 1 > $at_status_file
   7624   exit 1
   7625 fi
   7626 
   7627 $at_traceon
   7628 
   7629 
   7630 
   7631 # Check the location of "empty"
   7632 # -----------------------------
   7633 # I.e., epsilon-reductions, as in "(x)" which ends by reducing
   7634 # an empty "line" nterm.
   7635 # FIXME: This location is not satisfying.  Depend on the lookahead?
   7636 $at_traceoff
   7637 echo "actions.at:528: \$PREPARSER ./input '(x)'"
   7638 echo actions.at:528 >$at_check_line_file
   7639 ( $at_traceon; $PREPARSER ./input '(x)' ) >$at_stdout 2>$at_stder1
   7640 at_status=$?
   7641 grep '^ *+' $at_stder1 >&2
   7642 grep -v '^ *+' $at_stder1 >$at_stderr
   7643 at_failed=false
   7644 $at_diff $at_devnull $at_stderr || at_failed=:
   7645 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   7646 sending: 'x' (1@10-19)
   7647 thing (1@10-19): 'x' (1@10-19)
   7648 sending: ')' (2@20-29)
   7649 line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
   7650 sending: EOF (3@30-39)
   7651 input (0@29-29): /* Nothing */
   7652 input (2@0-29): line (0@0-29) input (0@29-29)
   7653 Freeing nterm input (2@0-29)
   7654 Successful parse.
   7655 " | $at_diff - $at_stdout || at_failed=:
   7656 case $at_status in
   7657    77) echo 77 > $at_status_file
   7658             exit 77;;
   7659    0) ;;
   7660    *) echo "actions.at:528: exit code was $at_status, expected 0"
   7661       at_failed=:;;
   7662 esac
   7663 if $at_failed; then
   7664 
   7665   echo 1 > $at_status_file
   7666   exit 1
   7667 fi
   7668 
   7669 $at_traceon
   7670 
   7671 
   7672 
   7673 # Check locations in error recovery
   7674 # ---------------------------------
   7675 # '(y)' is an error, but can be recovered from.  But what's the location
   7676 # of the error itself ('y'), and of the resulting reduction ('(error)').
   7677 $at_traceoff
   7678 echo "actions.at:528: \$PREPARSER ./input '(y)'"
   7679 echo actions.at:528 >$at_check_line_file
   7680 ( $at_traceon; $PREPARSER ./input '(y)' ) >$at_stdout 2>$at_stder1
   7681 at_status=$?
   7682 grep '^ *+' $at_stder1 >&2
   7683 grep -v '^ *+' $at_stder1 >$at_stderr
   7684 at_failed=false
   7685 $at_diff $at_devnull $at_stderr || at_failed=:
   7686 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   7687 sending: 'y' (1@10-19)
   7688 10-19: syntax error, unexpected 'y', expecting 'x'
   7689 Freeing token 'y' (1@10-19)
   7690 sending: ')' (2@20-29)
   7691 line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
   7692 sending: EOF (3@30-39)
   7693 input (0@29-29): /* Nothing */
   7694 input (2@0-29): line (-1@0-29) input (0@29-29)
   7695 Freeing nterm input (2@0-29)
   7696 Successful parse.
   7697 " | $at_diff - $at_stdout || at_failed=:
   7698 case $at_status in
   7699    77) echo 77 > $at_status_file
   7700             exit 77;;
   7701    0) ;;
   7702    *) echo "actions.at:528: exit code was $at_status, expected 0"
   7703       at_failed=:;;
   7704 esac
   7705 if $at_failed; then
   7706 
   7707   echo 1 > $at_status_file
   7708   exit 1
   7709 fi
   7710 
   7711 $at_traceon
   7712 
   7713 
   7714 
   7715 # Syntax errors caught by the parser
   7716 # ----------------------------------
   7717 # Exercise the discarding of stack top and input until `error'
   7718 # can be reduced.
   7719 #
   7720 #     '(', 'x', 'x', 'x', 'x', 'x', ')',
   7721 #
   7722 # Load the stack and provoke an error that cannot be caught by the
   7723 # grammar, to check that the stack is cleared.  And make sure the
   7724 # lookahead is freed.
   7725 #
   7726 #     '(', 'x', ')',
   7727 #     '(', 'x', ')',
   7728 #     'y'
   7729 $at_traceoff
   7730 echo "actions.at:528: \$PREPARSER ./input '(xxxxx)(x)(x)y'"
   7731 echo actions.at:528 >$at_check_line_file
   7732 ( $at_traceon; $PREPARSER ./input '(xxxxx)(x)(x)y' ) >$at_stdout 2>$at_stder1
   7733 at_status=$?
   7734 grep '^ *+' $at_stder1 >&2
   7735 grep -v '^ *+' $at_stder1 >$at_stderr
   7736 at_failed=false
   7737 $at_diff $at_devnull $at_stderr || at_failed=:
   7738 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   7739 sending: 'x' (1@10-19)
   7740 thing (1@10-19): 'x' (1@10-19)
   7741 sending: 'x' (2@20-29)
   7742 thing (2@20-29): 'x' (2@20-29)
   7743 sending: 'x' (3@30-39)
   7744 30-39: syntax error, unexpected 'x', expecting ')'
   7745 Freeing nterm thing (2@20-29)
   7746 Freeing nterm thing (1@10-19)
   7747 Freeing token 'x' (3@30-39)
   7748 sending: 'x' (4@40-49)
   7749 Freeing token 'x' (4@40-49)
   7750 sending: 'x' (5@50-59)
   7751 Freeing token 'x' (5@50-59)
   7752 sending: ')' (6@60-69)
   7753 line (-1@0-69): '(' (0@0-9) error (@10-59) ')' (6@60-69)
   7754 sending: '(' (7@70-79)
   7755 sending: 'x' (8@80-89)
   7756 thing (8@80-89): 'x' (8@80-89)
   7757 sending: ')' (9@90-99)
   7758 line (7@70-99): '(' (7@70-79) thing (8@80-89) ')' (9@90-99)
   7759 sending: '(' (10@100-109)
   7760 sending: 'x' (11@110-119)
   7761 thing (11@110-119): 'x' (11@110-119)
   7762 sending: ')' (12@120-129)
   7763 line (10@100-129): '(' (10@100-109) thing (11@110-119) ')' (12@120-129)
   7764 sending: 'y' (13@130-139)
   7765 input (0@129-129): /* Nothing */
   7766 input (2@100-129): line (10@100-129) input (0@129-129)
   7767 input (2@70-129): line (7@70-99) input (2@100-129)
   7768 input (2@0-129): line (-1@0-69) input (2@70-129)
   7769 130-139: syntax error, unexpected 'y', expecting \$end
   7770 Freeing nterm input (2@0-129)
   7771 Freeing token 'y' (13@130-139)
   7772 Parsing FAILED.
   7773 " | $at_diff - $at_stdout || at_failed=:
   7774 case $at_status in
   7775    77) echo 77 > $at_status_file
   7776             exit 77;;
   7777    1) ;;
   7778    *) echo "actions.at:528: exit code was $at_status, expected 1"
   7779       at_failed=:;;
   7780 esac
   7781 if $at_failed; then
   7782 
   7783   echo 1 > $at_status_file
   7784   exit 1
   7785 fi
   7786 
   7787 $at_traceon
   7788 
   7789 
   7790 # Check destruction upon stack overflow
   7791 # -------------------------------------
   7792 # Upon stack overflow, all symbols on the stack should be destroyed.
   7793 # Only check for yacc.c.
   7794 
   7795 $at_traceoff
   7796 echo "actions.at:528: \$PREPARSER ./input '(x)(x)(x)(x)(x)(x)(x)'"
   7797 echo actions.at:528 >$at_check_line_file
   7798 ( $at_traceon; $PREPARSER ./input '(x)(x)(x)(x)(x)(x)(x)' ) >$at_stdout 2>$at_stder1
   7799 at_status=$?
   7800 grep '^ *+' $at_stder1 >&2
   7801 grep -v '^ *+' $at_stder1 >$at_stderr
   7802 at_failed=false
   7803 $at_diff $at_devnull $at_stderr || at_failed=:
   7804 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   7805 sending: 'x' (1@10-19)
   7806 thing (1@10-19): 'x' (1@10-19)
   7807 sending: ')' (2@20-29)
   7808 line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
   7809 sending: '(' (3@30-39)
   7810 sending: 'x' (4@40-49)
   7811 thing (4@40-49): 'x' (4@40-49)
   7812 sending: ')' (5@50-59)
   7813 line (3@30-59): '(' (3@30-39) thing (4@40-49) ')' (5@50-59)
   7814 sending: '(' (6@60-69)
   7815 sending: 'x' (7@70-79)
   7816 thing (7@70-79): 'x' (7@70-79)
   7817 sending: ')' (8@80-89)
   7818 line (6@60-89): '(' (6@60-69) thing (7@70-79) ')' (8@80-89)
   7819 sending: '(' (9@90-99)
   7820 sending: 'x' (10@100-109)
   7821 thing (10@100-109): 'x' (10@100-109)
   7822 sending: ')' (11@110-119)
   7823 line (9@90-119): '(' (9@90-99) thing (10@100-109) ')' (11@110-119)
   7824 sending: '(' (12@120-129)
   7825 sending: 'x' (13@130-139)
   7826 thing (13@130-139): 'x' (13@130-139)
   7827 sending: ')' (14@140-149)
   7828 line (12@120-149): '(' (12@120-129) thing (13@130-139) ')' (14@140-149)
   7829 sending: '(' (15@150-159)
   7830 sending: 'x' (16@160-169)
   7831 thing (16@160-169): 'x' (16@160-169)
   7832 sending: ')' (17@170-179)
   7833 line (15@150-179): '(' (15@150-159) thing (16@160-169) ')' (17@170-179)
   7834 sending: '(' (18@180-189)
   7835 sending: 'x' (19@190-199)
   7836 thing (19@190-199): 'x' (19@190-199)
   7837 sending: ')' (20@200-209)
   7838 200-209: memory exhausted
   7839 Freeing nterm thing (19@190-199)
   7840 Freeing nterm line (15@150-179)
   7841 Freeing nterm line (12@120-149)
   7842 Freeing nterm line (9@90-119)
   7843 Freeing nterm line (6@60-89)
   7844 Freeing nterm line (3@30-59)
   7845 Freeing nterm line (0@0-29)
   7846 Parsing FAILED (status 2).
   7847 " | $at_diff - $at_stdout || at_failed=:
   7848 case $at_status in
   7849    77) echo 77 > $at_status_file
   7850             exit 77;;
   7851    2) ;;
   7852    *) echo "actions.at:528: exit code was $at_status, expected 2"
   7853       at_failed=:;;
   7854 esac
   7855 if $at_failed; then
   7856 
   7857   echo 1 > $at_status_file
   7858   exit 1
   7859 fi
   7860 
   7861 $at_traceon
   7862 
   7863 
   7864 
   7865 
   7866 
   7867       $at_traceoff
   7868       $at_times_p && times >$at_times_file
   7869     ) 5>&1 2>&1 | eval $at_tee_pipe
   7870     at_status=`cat $at_status_file`
   7871     ;;
   7872 
   7873   54 ) # 54. actions.at:533: Printers and Destructors : %defines %skeleton "lalr1.cc"
   7874     at_setup_line='actions.at:533'
   7875     at_desc='Printers and Destructors : %defines %skeleton "lalr1.cc"'
   7876     $at_quiet $ECHO_N " 54: Printers and Destructors : %defines %skeleton "lalr1.cc"$ECHO_C"
   7877     at_xfail=no
   7878     (
   7879       echo "54. actions.at:533: testing ..."
   7880       $at_traceon
   7881 
   7882 
   7883 
   7884 # Make sure complex $n work.
   7885 
   7886 # Be sure to pass all the %directives to this macro to have correct
   7887 # helping macros.  So don't put any directly in the Bison file.
   7888 
   7889 
   7890 
   7891 
   7892 # Using yacc.c?
   7893 
   7894 
   7895 
   7896 
   7897 
   7898 
   7899 
   7900 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   7901 
   7902 # yyerror always sees the locations (when activated), except if
   7903 # yacc & pure & !param.
   7904 
   7905 
   7906 # The interface is pure: either because %pure-parser, or because we
   7907 # are using the C++ parsers.
   7908 
   7909 
   7910 
   7911 
   7912 
   7913 
   7914 
   7915 
   7916 
   7917 
   7918 
   7919 cat >input.y <<'_ATEOF'
   7920 %{
   7921 #ifdef HAVE_CONFIG_H
   7922 # include <config.h>
   7923   /* We don't need perfect functions for these tests. */
   7924 # undef malloc
   7925 # undef memcmp
   7926 # undef realloc
   7927 #endif
   7928 %}
   7929 
   7930 %{
   7931 #include <stdio.h>
   7932 #include <stdlib.h>
   7933 #include <assert.h>
   7934 
   7935 #define YYINITDEPTH 10
   7936 #define YYMAXDEPTH 10
   7937 #define RANGE(Location) (Location).begin.line, (Location).end.line
   7938 %}
   7939 
   7940 %error-verbose
   7941 %debug
   7942 %verbose
   7943 %locations
   7944 %defines %skeleton "lalr1.cc"
   7945 
   7946 %define "global_tokens_and_yystype"
   7947 
   7948 %{
   7949 typedef yy::location YYLTYPE;
   7950                 #define YYSTYPE int
   7951 static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
   7952 
   7953 %}
   7954 
   7955 
   7956 
   7957 %printer
   7958   {
   7959     debug_stream () << $$;;
   7960   }
   7961   input line thing 'x' 'y'
   7962 
   7963 %destructor
   7964   { printf ("Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
   7965   input
   7966 
   7967 %destructor
   7968   { printf ("Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); }
   7969   line
   7970 
   7971 %destructor
   7972   { printf ("Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
   7973   thing
   7974 
   7975 %destructor
   7976   { printf ("Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
   7977   'x'
   7978 
   7979 %destructor
   7980   { printf ("Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); }
   7981   'y'
   7982 
   7983 %%
   7984 /*
   7985    This grammar is made to exercise error recovery.
   7986    "Lines" starting with `(' support error recovery, with
   7987    ')' as synchronizing token.  Lines starting with 'x' can never
   7988    be recovered from if in error.
   7989 */
   7990 
   7991 input:
   7992   /* Nothing. */
   7993     {
   7994       $$ = 0;
   7995       printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
   7996     }
   7997 | line input /* Right recursive to load the stack so that popping at
   7998 		EOF can	be exercised.  */
   7999     {
   8000       $$ = 2;
   8001       printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
   8002 	      $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
   8003     }
   8004 ;
   8005 
   8006 line:
   8007   thing thing thing ';'
   8008     {
   8009       $$ = $1;
   8010       printf ("line (%d@%d-%d): thing (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ';' (%d@%d-%d)\n",
   8011               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   8012               $3, RANGE (@3), $4, RANGE (@4));
   8013     }
   8014 | '(' thing thing ')'
   8015     {
   8016       $$ = $1;
   8017       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   8018               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   8019               $3, RANGE (@3), $4, RANGE (@4));
   8020     }
   8021 | '(' thing ')'
   8022     {
   8023       $$ = $1;
   8024       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   8025               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), $3, RANGE (@3));
   8026     }
   8027 | '(' error ')'
   8028     {
   8029       $$ = -1;
   8030       printf ("line (%d@%d-%d): '(' (%d@%d-%d) error (@%d-%d) ')' (%d@%d-%d)\n",
   8031               $$, RANGE (@$), $1, RANGE (@1), RANGE (@2), $3, RANGE (@3));
   8032     }
   8033 ;
   8034 
   8035 thing:
   8036   'x'
   8037     {
   8038       $$ = $1;
   8039       printf ("thing (%d@%d-%d): 'x' (%d@%d-%d)\n",
   8040               $$, RANGE (@$), $1, RANGE (@1));
   8041     }
   8042 ;
   8043 %%
   8044 /* Alias to ARGV[1]. */
   8045 const char *source = 0;
   8046 
   8047 static int
   8048 yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
   8049 {
   8050   static unsigned int counter = 0;
   8051 
   8052   int c = (*lvalp) = counter++;
   8053   /* As in BASIC, line numbers go from 10 to 10.  */
   8054  (*llocp).begin.line = (*llocp).begin.column = 10 * c;
   8055   (*llocp).end.line = (*llocp).end.column = (*llocp).begin.line + 9;
   8056 
   8057 
   8058   if (source[c])
   8059     printf ("sending: '%c'", source[c]);
   8060   else
   8061     printf ("sending: EOF");
   8062   printf (" (%d@%d-%d)\n", c, RANGE ((*llocp)));
   8063   return source[c];
   8064 }
   8065 
   8066 /* A C++ error reporting function. */
   8067 void
   8068 yy::parser::error (const location& l, const std::string& m)
   8069 {
   8070   printf ("%d-%d: %s\n", RANGE (l), m.c_str());
   8071 }
   8072 
   8073 static bool yydebug;
   8074 int
   8075 yyparse ()
   8076 {
   8077   yy::parser parser;
   8078   parser.set_debug_level (yydebug);
   8079   return parser.parse ();
   8080 }
   8081 
   8082 
   8083 int
   8084 main (int argc, const char *argv[])
   8085 {
   8086   int status;
   8087   yydebug = !!getenv ("YYDEBUG");
   8088   assert (argc == 2);
   8089   source = argv[1];
   8090   status = yyparse ();
   8091   switch (status)
   8092     {
   8093       case 0: printf ("Successful parse.\n"); break;
   8094       case 1: printf ("Parsing FAILED.\n"); break;
   8095       default: printf ("Parsing FAILED (status %d).\n", status); break;
   8096     }
   8097   return status;
   8098 }
   8099 _ATEOF
   8100 
   8101 
   8102 
   8103 $at_traceoff
   8104 echo "actions.at:533: bison -o input.cc input.y"
   8105 echo actions.at:533 >$at_check_line_file
   8106 ( $at_traceon; bison -o input.cc input.y ) >$at_stdout 2>$at_stder1
   8107 at_status=$?
   8108 grep '^ *+' $at_stder1 >&2
   8109 grep -v '^ *+' $at_stder1 >$at_stderr
   8110 at_failed=false
   8111 $at_diff $at_devnull $at_stderr || at_failed=:
   8112 $at_diff $at_devnull $at_stdout || at_failed=:
   8113 case $at_status in
   8114    77) echo 77 > $at_status_file
   8115             exit 77;;
   8116    0) ;;
   8117    *) echo "actions.at:533: exit code was $at_status, expected 0"
   8118       at_failed=:;;
   8119 esac
   8120 if $at_failed; then
   8121 
   8122   echo 1 > $at_status_file
   8123   exit 1
   8124 fi
   8125 
   8126 $at_traceon
   8127 
   8128 
   8129 $at_traceoff
   8130 echo "actions.at:533: \$BISON_CXX_WORKS"
   8131 echo actions.at:533 >$at_check_line_file
   8132 ( $at_traceon; $BISON_CXX_WORKS ) >$at_stdout 2>$at_stder1
   8133 at_status=$?
   8134 grep '^ *+' $at_stder1 >&2
   8135 grep -v '^ *+' $at_stder1 >$at_stderr
   8136 at_failed=false
   8137 echo stderr:; cat $at_stderr
   8138 echo stdout:; cat $at_stdout
   8139 case $at_status in
   8140    77) echo 77 > $at_status_file
   8141             exit 77;;
   8142    0) ;;
   8143    *) echo "actions.at:533: exit code was $at_status, expected 0"
   8144       at_failed=:;;
   8145 esac
   8146 if $at_failed; then
   8147 
   8148   echo 1 > $at_status_file
   8149   exit 1
   8150 fi
   8151 
   8152 $at_traceon
   8153 
   8154 $at_traceoff
   8155 echo "actions.at:533: \$CXX \$CXXFLAGS \$CPPFLAGS \$LDFLAGS -o input input.cc \$LIBS"
   8156 echo actions.at:533 >$at_check_line_file
   8157 ( $at_traceon; $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS -o input input.cc $LIBS ) >$at_stdout 2>$at_stder1
   8158 at_status=$?
   8159 grep '^ *+' $at_stder1 >&2
   8160 grep -v '^ *+' $at_stder1 >$at_stderr
   8161 at_failed=false
   8162 echo stderr:; cat $at_stderr
   8163 echo stdout:; cat $at_stdout
   8164 case $at_status in
   8165    77) echo 77 > $at_status_file
   8166             exit 77;;
   8167    0) ;;
   8168    *) echo "actions.at:533: exit code was $at_status, expected 0"
   8169       at_failed=:;;
   8170 esac
   8171 if $at_failed; then
   8172 
   8173   echo 1 > $at_status_file
   8174   exit 1
   8175 fi
   8176 
   8177 $at_traceon
   8178 
   8179 
   8180 
   8181 # Check the location of "empty"
   8182 # -----------------------------
   8183 # I.e., epsilon-reductions, as in "(x)" which ends by reducing
   8184 # an empty "line" nterm.
   8185 # FIXME: This location is not satisfying.  Depend on the lookahead?
   8186 $at_traceoff
   8187 echo "actions.at:533: \$PREPARSER ./input '(x)'"
   8188 echo actions.at:533 >$at_check_line_file
   8189 ( $at_traceon; $PREPARSER ./input '(x)' ) >$at_stdout 2>$at_stder1
   8190 at_status=$?
   8191 grep '^ *+' $at_stder1 >&2
   8192 grep -v '^ *+' $at_stder1 >$at_stderr
   8193 at_failed=false
   8194 $at_diff $at_devnull $at_stderr || at_failed=:
   8195 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   8196 sending: 'x' (1@10-19)
   8197 thing (1@10-19): 'x' (1@10-19)
   8198 sending: ')' (2@20-29)
   8199 line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
   8200 sending: EOF (3@30-39)
   8201 input (0@29-29): /* Nothing */
   8202 input (2@0-29): line (0@0-29) input (0@29-29)
   8203 Freeing nterm input (2@0-29)
   8204 Successful parse.
   8205 " | $at_diff - $at_stdout || at_failed=:
   8206 case $at_status in
   8207    77) echo 77 > $at_status_file
   8208             exit 77;;
   8209    0) ;;
   8210    *) echo "actions.at:533: exit code was $at_status, expected 0"
   8211       at_failed=:;;
   8212 esac
   8213 if $at_failed; then
   8214 
   8215   echo 1 > $at_status_file
   8216   exit 1
   8217 fi
   8218 
   8219 $at_traceon
   8220 
   8221 
   8222 
   8223 # Check locations in error recovery
   8224 # ---------------------------------
   8225 # '(y)' is an error, but can be recovered from.  But what's the location
   8226 # of the error itself ('y'), and of the resulting reduction ('(error)').
   8227 $at_traceoff
   8228 echo "actions.at:533: \$PREPARSER ./input '(y)'"
   8229 echo actions.at:533 >$at_check_line_file
   8230 ( $at_traceon; $PREPARSER ./input '(y)' ) >$at_stdout 2>$at_stder1
   8231 at_status=$?
   8232 grep '^ *+' $at_stder1 >&2
   8233 grep -v '^ *+' $at_stder1 >$at_stderr
   8234 at_failed=false
   8235 $at_diff $at_devnull $at_stderr || at_failed=:
   8236 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   8237 sending: 'y' (1@10-19)
   8238 10-19: syntax error, unexpected 'y', expecting 'x'
   8239 Freeing token 'y' (1@10-19)
   8240 sending: ')' (2@20-29)
   8241 line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
   8242 sending: EOF (3@30-39)
   8243 input (0@29-29): /* Nothing */
   8244 input (2@0-29): line (-1@0-29) input (0@29-29)
   8245 Freeing nterm input (2@0-29)
   8246 Successful parse.
   8247 " | $at_diff - $at_stdout || at_failed=:
   8248 case $at_status in
   8249    77) echo 77 > $at_status_file
   8250             exit 77;;
   8251    0) ;;
   8252    *) echo "actions.at:533: exit code was $at_status, expected 0"
   8253       at_failed=:;;
   8254 esac
   8255 if $at_failed; then
   8256 
   8257   echo 1 > $at_status_file
   8258   exit 1
   8259 fi
   8260 
   8261 $at_traceon
   8262 
   8263 
   8264 
   8265 # Syntax errors caught by the parser
   8266 # ----------------------------------
   8267 # Exercise the discarding of stack top and input until `error'
   8268 # can be reduced.
   8269 #
   8270 #     '(', 'x', 'x', 'x', 'x', 'x', ')',
   8271 #
   8272 # Load the stack and provoke an error that cannot be caught by the
   8273 # grammar, to check that the stack is cleared.  And make sure the
   8274 # lookahead is freed.
   8275 #
   8276 #     '(', 'x', ')',
   8277 #     '(', 'x', ')',
   8278 #     'y'
   8279 $at_traceoff
   8280 echo "actions.at:533: \$PREPARSER ./input '(xxxxx)(x)(x)y'"
   8281 echo actions.at:533 >$at_check_line_file
   8282 ( $at_traceon; $PREPARSER ./input '(xxxxx)(x)(x)y' ) >$at_stdout 2>$at_stder1
   8283 at_status=$?
   8284 grep '^ *+' $at_stder1 >&2
   8285 grep -v '^ *+' $at_stder1 >$at_stderr
   8286 at_failed=false
   8287 $at_diff $at_devnull $at_stderr || at_failed=:
   8288 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   8289 sending: 'x' (1@10-19)
   8290 thing (1@10-19): 'x' (1@10-19)
   8291 sending: 'x' (2@20-29)
   8292 thing (2@20-29): 'x' (2@20-29)
   8293 sending: 'x' (3@30-39)
   8294 30-39: syntax error, unexpected 'x', expecting ')'
   8295 Freeing nterm thing (2@20-29)
   8296 Freeing nterm thing (1@10-19)
   8297 Freeing token 'x' (3@30-39)
   8298 sending: 'x' (4@40-49)
   8299 Freeing token 'x' (4@40-49)
   8300 sending: 'x' (5@50-59)
   8301 Freeing token 'x' (5@50-59)
   8302 sending: ')' (6@60-69)
   8303 line (-1@0-69): '(' (0@0-9) error (@10-59) ')' (6@60-69)
   8304 sending: '(' (7@70-79)
   8305 sending: 'x' (8@80-89)
   8306 thing (8@80-89): 'x' (8@80-89)
   8307 sending: ')' (9@90-99)
   8308 line (7@70-99): '(' (7@70-79) thing (8@80-89) ')' (9@90-99)
   8309 sending: '(' (10@100-109)
   8310 sending: 'x' (11@110-119)
   8311 thing (11@110-119): 'x' (11@110-119)
   8312 sending: ')' (12@120-129)
   8313 line (10@100-129): '(' (10@100-109) thing (11@110-119) ')' (12@120-129)
   8314 sending: 'y' (13@130-139)
   8315 input (0@129-129): /* Nothing */
   8316 input (2@100-129): line (10@100-129) input (0@129-129)
   8317 input (2@70-129): line (7@70-99) input (2@100-129)
   8318 input (2@0-129): line (-1@0-69) input (2@70-129)
   8319 130-139: syntax error, unexpected 'y', expecting \$end
   8320 Freeing nterm input (2@0-129)
   8321 Freeing token 'y' (13@130-139)
   8322 Parsing FAILED.
   8323 " | $at_diff - $at_stdout || at_failed=:
   8324 case $at_status in
   8325    77) echo 77 > $at_status_file
   8326             exit 77;;
   8327    1) ;;
   8328    *) echo "actions.at:533: exit code was $at_status, expected 1"
   8329       at_failed=:;;
   8330 esac
   8331 if $at_failed; then
   8332 
   8333   echo 1 > $at_status_file
   8334   exit 1
   8335 fi
   8336 
   8337 $at_traceon
   8338 
   8339 
   8340 # Check destruction upon stack overflow
   8341 # -------------------------------------
   8342 # Upon stack overflow, all symbols on the stack should be destroyed.
   8343 # Only check for yacc.c.
   8344 
   8345 
   8346 
   8347 
   8348       $at_traceoff
   8349       $at_times_p && times >$at_times_file
   8350     ) 5>&1 2>&1 | eval $at_tee_pipe
   8351     at_status=`cat $at_status_file`
   8352     ;;
   8353 
   8354   55 ) # 55. actions.at:534: Printers and Destructors with union: %defines %skeleton "lalr1.cc"
   8355     at_setup_line='actions.at:534'
   8356     at_desc='Printers and Destructors with union: %defines %skeleton "lalr1.cc"'
   8357     $at_quiet $ECHO_N " 55: Printers and Destructors with union: %defines %skeleton "lalr1.cc"$ECHO_C"
   8358     at_xfail=no
   8359     (
   8360       echo "55. actions.at:534: testing ..."
   8361       $at_traceon
   8362 
   8363 
   8364 
   8365 # Make sure complex $n work.
   8366 
   8367 # Be sure to pass all the %directives to this macro to have correct
   8368 # helping macros.  So don't put any directly in the Bison file.
   8369 
   8370 
   8371 
   8372 
   8373 # Using yacc.c?
   8374 
   8375 
   8376 
   8377 
   8378 
   8379 
   8380 
   8381 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   8382 
   8383 # yyerror always sees the locations (when activated), except if
   8384 # yacc & pure & !param.
   8385 
   8386 
   8387 # The interface is pure: either because %pure-parser, or because we
   8388 # are using the C++ parsers.
   8389 
   8390 
   8391 
   8392 
   8393 
   8394 
   8395 
   8396 
   8397 
   8398 
   8399 
   8400 cat >input.y <<'_ATEOF'
   8401 %{
   8402 #ifdef HAVE_CONFIG_H
   8403 # include <config.h>
   8404   /* We don't need perfect functions for these tests. */
   8405 # undef malloc
   8406 # undef memcmp
   8407 # undef realloc
   8408 #endif
   8409 %}
   8410 
   8411 %{
   8412 #include <stdio.h>
   8413 #include <stdlib.h>
   8414 #include <assert.h>
   8415 
   8416 #define YYINITDEPTH 10
   8417 #define YYMAXDEPTH 10
   8418 #define RANGE(Location) (Location).begin.line, (Location).end.line
   8419 %}
   8420 
   8421 %error-verbose
   8422 %debug
   8423 %verbose
   8424 %locations
   8425 %defines %skeleton "lalr1.cc"
   8426 %union
   8427 {
   8428   int ival;
   8429 }
   8430 %define "global_tokens_and_yystype"
   8431 
   8432 %{
   8433 typedef yy::location YYLTYPE;
   8434 
   8435 static int yylex (YYSTYPE *lvalp, YYLTYPE *llocp);
   8436 
   8437 %}
   8438 
   8439 %type <ival> '(' 'x' 'y' ')' ';' thing line input
   8440 
   8441 %printer
   8442   {
   8443     debug_stream () << $$;;
   8444   }
   8445   input line thing 'x' 'y'
   8446 
   8447 %destructor
   8448   { printf ("Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
   8449   input
   8450 
   8451 %destructor
   8452   { printf ("Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); }
   8453   line
   8454 
   8455 %destructor
   8456   { printf ("Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
   8457   thing
   8458 
   8459 %destructor
   8460   { printf ("Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
   8461   'x'
   8462 
   8463 %destructor
   8464   { printf ("Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); }
   8465   'y'
   8466 
   8467 %%
   8468 /*
   8469    This grammar is made to exercise error recovery.
   8470    "Lines" starting with `(' support error recovery, with
   8471    ')' as synchronizing token.  Lines starting with 'x' can never
   8472    be recovered from if in error.
   8473 */
   8474 
   8475 input:
   8476   /* Nothing. */
   8477     {
   8478       $$ = 0;
   8479       printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
   8480     }
   8481 | line input /* Right recursive to load the stack so that popping at
   8482 		EOF can	be exercised.  */
   8483     {
   8484       $$ = 2;
   8485       printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
   8486 	      $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
   8487     }
   8488 ;
   8489 
   8490 line:
   8491   thing thing thing ';'
   8492     {
   8493       $$ = $1;
   8494       printf ("line (%d@%d-%d): thing (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ';' (%d@%d-%d)\n",
   8495               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   8496               $3, RANGE (@3), $4, RANGE (@4));
   8497     }
   8498 | '(' thing thing ')'
   8499     {
   8500       $$ = $1;
   8501       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   8502               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   8503               $3, RANGE (@3), $4, RANGE (@4));
   8504     }
   8505 | '(' thing ')'
   8506     {
   8507       $$ = $1;
   8508       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   8509               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), $3, RANGE (@3));
   8510     }
   8511 | '(' error ')'
   8512     {
   8513       $$ = -1;
   8514       printf ("line (%d@%d-%d): '(' (%d@%d-%d) error (@%d-%d) ')' (%d@%d-%d)\n",
   8515               $$, RANGE (@$), $1, RANGE (@1), RANGE (@2), $3, RANGE (@3));
   8516     }
   8517 ;
   8518 
   8519 thing:
   8520   'x'
   8521     {
   8522       $$ = $1;
   8523       printf ("thing (%d@%d-%d): 'x' (%d@%d-%d)\n",
   8524               $$, RANGE (@$), $1, RANGE (@1));
   8525     }
   8526 ;
   8527 %%
   8528 /* Alias to ARGV[1]. */
   8529 const char *source = 0;
   8530 
   8531 static int
   8532 yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
   8533 {
   8534   static unsigned int counter = 0;
   8535 
   8536   int c = (*lvalp).ival = counter++;
   8537   /* As in BASIC, line numbers go from 10 to 10.  */
   8538  (*llocp).begin.line = (*llocp).begin.column = 10 * c;
   8539   (*llocp).end.line = (*llocp).end.column = (*llocp).begin.line + 9;
   8540 
   8541 
   8542   if (source[c])
   8543     printf ("sending: '%c'", source[c]);
   8544   else
   8545     printf ("sending: EOF");
   8546   printf (" (%d@%d-%d)\n", c, RANGE ((*llocp)));
   8547   return source[c];
   8548 }
   8549 
   8550 /* A C++ error reporting function. */
   8551 void
   8552 yy::parser::error (const location& l, const std::string& m)
   8553 {
   8554   printf ("%d-%d: %s\n", RANGE (l), m.c_str());
   8555 }
   8556 
   8557 static bool yydebug;
   8558 int
   8559 yyparse ()
   8560 {
   8561   yy::parser parser;
   8562   parser.set_debug_level (yydebug);
   8563   return parser.parse ();
   8564 }
   8565 
   8566 
   8567 int
   8568 main (int argc, const char *argv[])
   8569 {
   8570   int status;
   8571   yydebug = !!getenv ("YYDEBUG");
   8572   assert (argc == 2);
   8573   source = argv[1];
   8574   status = yyparse ();
   8575   switch (status)
   8576     {
   8577       case 0: printf ("Successful parse.\n"); break;
   8578       case 1: printf ("Parsing FAILED.\n"); break;
   8579       default: printf ("Parsing FAILED (status %d).\n", status); break;
   8580     }
   8581   return status;
   8582 }
   8583 _ATEOF
   8584 
   8585 
   8586 
   8587 $at_traceoff
   8588 echo "actions.at:534: bison -o input.cc input.y"
   8589 echo actions.at:534 >$at_check_line_file
   8590 ( $at_traceon; bison -o input.cc input.y ) >$at_stdout 2>$at_stder1
   8591 at_status=$?
   8592 grep '^ *+' $at_stder1 >&2
   8593 grep -v '^ *+' $at_stder1 >$at_stderr
   8594 at_failed=false
   8595 $at_diff $at_devnull $at_stderr || at_failed=:
   8596 $at_diff $at_devnull $at_stdout || at_failed=:
   8597 case $at_status in
   8598    77) echo 77 > $at_status_file
   8599             exit 77;;
   8600    0) ;;
   8601    *) echo "actions.at:534: exit code was $at_status, expected 0"
   8602       at_failed=:;;
   8603 esac
   8604 if $at_failed; then
   8605 
   8606   echo 1 > $at_status_file
   8607   exit 1
   8608 fi
   8609 
   8610 $at_traceon
   8611 
   8612 
   8613 $at_traceoff
   8614 echo "actions.at:534: \$BISON_CXX_WORKS"
   8615 echo actions.at:534 >$at_check_line_file
   8616 ( $at_traceon; $BISON_CXX_WORKS ) >$at_stdout 2>$at_stder1
   8617 at_status=$?
   8618 grep '^ *+' $at_stder1 >&2
   8619 grep -v '^ *+' $at_stder1 >$at_stderr
   8620 at_failed=false
   8621 echo stderr:; cat $at_stderr
   8622 echo stdout:; cat $at_stdout
   8623 case $at_status in
   8624    77) echo 77 > $at_status_file
   8625             exit 77;;
   8626    0) ;;
   8627    *) echo "actions.at:534: exit code was $at_status, expected 0"
   8628       at_failed=:;;
   8629 esac
   8630 if $at_failed; then
   8631 
   8632   echo 1 > $at_status_file
   8633   exit 1
   8634 fi
   8635 
   8636 $at_traceon
   8637 
   8638 $at_traceoff
   8639 echo "actions.at:534: \$CXX \$CXXFLAGS \$CPPFLAGS \$LDFLAGS -o input input.cc \$LIBS"
   8640 echo actions.at:534 >$at_check_line_file
   8641 ( $at_traceon; $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS -o input input.cc $LIBS ) >$at_stdout 2>$at_stder1
   8642 at_status=$?
   8643 grep '^ *+' $at_stder1 >&2
   8644 grep -v '^ *+' $at_stder1 >$at_stderr
   8645 at_failed=false
   8646 echo stderr:; cat $at_stderr
   8647 echo stdout:; cat $at_stdout
   8648 case $at_status in
   8649    77) echo 77 > $at_status_file
   8650             exit 77;;
   8651    0) ;;
   8652    *) echo "actions.at:534: exit code was $at_status, expected 0"
   8653       at_failed=:;;
   8654 esac
   8655 if $at_failed; then
   8656 
   8657   echo 1 > $at_status_file
   8658   exit 1
   8659 fi
   8660 
   8661 $at_traceon
   8662 
   8663 
   8664 
   8665 # Check the location of "empty"
   8666 # -----------------------------
   8667 # I.e., epsilon-reductions, as in "(x)" which ends by reducing
   8668 # an empty "line" nterm.
   8669 # FIXME: This location is not satisfying.  Depend on the lookahead?
   8670 $at_traceoff
   8671 echo "actions.at:534: \$PREPARSER ./input '(x)'"
   8672 echo actions.at:534 >$at_check_line_file
   8673 ( $at_traceon; $PREPARSER ./input '(x)' ) >$at_stdout 2>$at_stder1
   8674 at_status=$?
   8675 grep '^ *+' $at_stder1 >&2
   8676 grep -v '^ *+' $at_stder1 >$at_stderr
   8677 at_failed=false
   8678 $at_diff $at_devnull $at_stderr || at_failed=:
   8679 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   8680 sending: 'x' (1@10-19)
   8681 thing (1@10-19): 'x' (1@10-19)
   8682 sending: ')' (2@20-29)
   8683 line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
   8684 sending: EOF (3@30-39)
   8685 input (0@29-29): /* Nothing */
   8686 input (2@0-29): line (0@0-29) input (0@29-29)
   8687 Freeing nterm input (2@0-29)
   8688 Successful parse.
   8689 " | $at_diff - $at_stdout || at_failed=:
   8690 case $at_status in
   8691    77) echo 77 > $at_status_file
   8692             exit 77;;
   8693    0) ;;
   8694    *) echo "actions.at:534: exit code was $at_status, expected 0"
   8695       at_failed=:;;
   8696 esac
   8697 if $at_failed; then
   8698 
   8699   echo 1 > $at_status_file
   8700   exit 1
   8701 fi
   8702 
   8703 $at_traceon
   8704 
   8705 
   8706 
   8707 # Check locations in error recovery
   8708 # ---------------------------------
   8709 # '(y)' is an error, but can be recovered from.  But what's the location
   8710 # of the error itself ('y'), and of the resulting reduction ('(error)').
   8711 $at_traceoff
   8712 echo "actions.at:534: \$PREPARSER ./input '(y)'"
   8713 echo actions.at:534 >$at_check_line_file
   8714 ( $at_traceon; $PREPARSER ./input '(y)' ) >$at_stdout 2>$at_stder1
   8715 at_status=$?
   8716 grep '^ *+' $at_stder1 >&2
   8717 grep -v '^ *+' $at_stder1 >$at_stderr
   8718 at_failed=false
   8719 $at_diff $at_devnull $at_stderr || at_failed=:
   8720 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   8721 sending: 'y' (1@10-19)
   8722 10-19: syntax error, unexpected 'y', expecting 'x'
   8723 Freeing token 'y' (1@10-19)
   8724 sending: ')' (2@20-29)
   8725 line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
   8726 sending: EOF (3@30-39)
   8727 input (0@29-29): /* Nothing */
   8728 input (2@0-29): line (-1@0-29) input (0@29-29)
   8729 Freeing nterm input (2@0-29)
   8730 Successful parse.
   8731 " | $at_diff - $at_stdout || at_failed=:
   8732 case $at_status in
   8733    77) echo 77 > $at_status_file
   8734             exit 77;;
   8735    0) ;;
   8736    *) echo "actions.at:534: exit code was $at_status, expected 0"
   8737       at_failed=:;;
   8738 esac
   8739 if $at_failed; then
   8740 
   8741   echo 1 > $at_status_file
   8742   exit 1
   8743 fi
   8744 
   8745 $at_traceon
   8746 
   8747 
   8748 
   8749 # Syntax errors caught by the parser
   8750 # ----------------------------------
   8751 # Exercise the discarding of stack top and input until `error'
   8752 # can be reduced.
   8753 #
   8754 #     '(', 'x', 'x', 'x', 'x', 'x', ')',
   8755 #
   8756 # Load the stack and provoke an error that cannot be caught by the
   8757 # grammar, to check that the stack is cleared.  And make sure the
   8758 # lookahead is freed.
   8759 #
   8760 #     '(', 'x', ')',
   8761 #     '(', 'x', ')',
   8762 #     'y'
   8763 $at_traceoff
   8764 echo "actions.at:534: \$PREPARSER ./input '(xxxxx)(x)(x)y'"
   8765 echo actions.at:534 >$at_check_line_file
   8766 ( $at_traceon; $PREPARSER ./input '(xxxxx)(x)(x)y' ) >$at_stdout 2>$at_stder1
   8767 at_status=$?
   8768 grep '^ *+' $at_stder1 >&2
   8769 grep -v '^ *+' $at_stder1 >$at_stderr
   8770 at_failed=false
   8771 $at_diff $at_devnull $at_stderr || at_failed=:
   8772 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   8773 sending: 'x' (1@10-19)
   8774 thing (1@10-19): 'x' (1@10-19)
   8775 sending: 'x' (2@20-29)
   8776 thing (2@20-29): 'x' (2@20-29)
   8777 sending: 'x' (3@30-39)
   8778 30-39: syntax error, unexpected 'x', expecting ')'
   8779 Freeing nterm thing (2@20-29)
   8780 Freeing nterm thing (1@10-19)
   8781 Freeing token 'x' (3@30-39)
   8782 sending: 'x' (4@40-49)
   8783 Freeing token 'x' (4@40-49)
   8784 sending: 'x' (5@50-59)
   8785 Freeing token 'x' (5@50-59)
   8786 sending: ')' (6@60-69)
   8787 line (-1@0-69): '(' (0@0-9) error (@10-59) ')' (6@60-69)
   8788 sending: '(' (7@70-79)
   8789 sending: 'x' (8@80-89)
   8790 thing (8@80-89): 'x' (8@80-89)
   8791 sending: ')' (9@90-99)
   8792 line (7@70-99): '(' (7@70-79) thing (8@80-89) ')' (9@90-99)
   8793 sending: '(' (10@100-109)
   8794 sending: 'x' (11@110-119)
   8795 thing (11@110-119): 'x' (11@110-119)
   8796 sending: ')' (12@120-129)
   8797 line (10@100-129): '(' (10@100-109) thing (11@110-119) ')' (12@120-129)
   8798 sending: 'y' (13@130-139)
   8799 input (0@129-129): /* Nothing */
   8800 input (2@100-129): line (10@100-129) input (0@129-129)
   8801 input (2@70-129): line (7@70-99) input (2@100-129)
   8802 input (2@0-129): line (-1@0-69) input (2@70-129)
   8803 130-139: syntax error, unexpected 'y', expecting \$end
   8804 Freeing nterm input (2@0-129)
   8805 Freeing token 'y' (13@130-139)
   8806 Parsing FAILED.
   8807 " | $at_diff - $at_stdout || at_failed=:
   8808 case $at_status in
   8809    77) echo 77 > $at_status_file
   8810             exit 77;;
   8811    1) ;;
   8812    *) echo "actions.at:534: exit code was $at_status, expected 1"
   8813       at_failed=:;;
   8814 esac
   8815 if $at_failed; then
   8816 
   8817   echo 1 > $at_status_file
   8818   exit 1
   8819 fi
   8820 
   8821 $at_traceon
   8822 
   8823 
   8824 # Check destruction upon stack overflow
   8825 # -------------------------------------
   8826 # Upon stack overflow, all symbols on the stack should be destroyed.
   8827 # Only check for yacc.c.
   8828 
   8829 
   8830 
   8831 
   8832       $at_traceoff
   8833       $at_times_p && times >$at_times_file
   8834     ) 5>&1 2>&1 | eval $at_tee_pipe
   8835     at_status=`cat $at_status_file`
   8836     ;;
   8837 
   8838   56 ) # 56. actions.at:536: Printers and Destructors : %glr-parser
   8839     at_setup_line='actions.at:536'
   8840     at_desc='Printers and Destructors : %glr-parser'
   8841     $at_quiet $ECHO_N " 56: Printers and Destructors : %glr-parser       $ECHO_C"
   8842     at_xfail=no
   8843     (
   8844       echo "56. actions.at:536: testing ..."
   8845       $at_traceon
   8846 
   8847 
   8848 
   8849 # Make sure complex $n work.
   8850 
   8851 # Be sure to pass all the %directives to this macro to have correct
   8852 # helping macros.  So don't put any directly in the Bison file.
   8853 
   8854 
   8855 
   8856 
   8857 # Using yacc.c?
   8858 
   8859 
   8860 
   8861 
   8862 
   8863 
   8864 
   8865 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   8866 
   8867 # yyerror always sees the locations (when activated), except if
   8868 # yacc & pure & !param.
   8869 
   8870 
   8871 # The interface is pure: either because %pure-parser, or because we
   8872 # are using the C++ parsers.
   8873 
   8874 
   8875 
   8876 
   8877 
   8878 
   8879 
   8880 
   8881 
   8882 
   8883 
   8884 cat >input.y <<'_ATEOF'
   8885 %{
   8886 #ifdef HAVE_CONFIG_H
   8887 # include <config.h>
   8888   /* We don't need perfect functions for these tests. */
   8889 # undef malloc
   8890 # undef memcmp
   8891 # undef realloc
   8892 #endif
   8893 %}
   8894 
   8895 %{
   8896 #include <stdio.h>
   8897 #include <stdlib.h>
   8898 #include <assert.h>
   8899 
   8900 #define YYINITDEPTH 10
   8901 #define YYMAXDEPTH 10
   8902 #define RANGE(Location) (Location).first_line, (Location).last_line
   8903 %}
   8904 
   8905 %error-verbose
   8906 %debug
   8907 %verbose
   8908 %locations
   8909 %glr-parser
   8910 
   8911 
   8912 
   8913 %{
   8914 
   8915 static int yylex (void);
   8916 static void yyerror (const char *msg);
   8917 %}
   8918 
   8919 
   8920 
   8921 %printer
   8922   {
   8923     fprintf (yyoutput, "%d", $$);
   8924   }
   8925   input line thing 'x' 'y'
   8926 
   8927 %destructor
   8928   { printf ("Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
   8929   input
   8930 
   8931 %destructor
   8932   { printf ("Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); }
   8933   line
   8934 
   8935 %destructor
   8936   { printf ("Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
   8937   thing
   8938 
   8939 %destructor
   8940   { printf ("Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
   8941   'x'
   8942 
   8943 %destructor
   8944   { printf ("Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); }
   8945   'y'
   8946 
   8947 %%
   8948 /*
   8949    This grammar is made to exercise error recovery.
   8950    "Lines" starting with `(' support error recovery, with
   8951    ')' as synchronizing token.  Lines starting with 'x' can never
   8952    be recovered from if in error.
   8953 */
   8954 
   8955 input:
   8956   /* Nothing. */
   8957     {
   8958       $$ = 0;
   8959       printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
   8960     }
   8961 | line input /* Right recursive to load the stack so that popping at
   8962 		EOF can	be exercised.  */
   8963     {
   8964       $$ = 2;
   8965       printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
   8966 	      $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
   8967     }
   8968 ;
   8969 
   8970 line:
   8971   thing thing thing ';'
   8972     {
   8973       $$ = $1;
   8974       printf ("line (%d@%d-%d): thing (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ';' (%d@%d-%d)\n",
   8975               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   8976               $3, RANGE (@3), $4, RANGE (@4));
   8977     }
   8978 | '(' thing thing ')'
   8979     {
   8980       $$ = $1;
   8981       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   8982               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   8983               $3, RANGE (@3), $4, RANGE (@4));
   8984     }
   8985 | '(' thing ')'
   8986     {
   8987       $$ = $1;
   8988       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   8989               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), $3, RANGE (@3));
   8990     }
   8991 | '(' error ')'
   8992     {
   8993       $$ = -1;
   8994       printf ("line (%d@%d-%d): '(' (%d@%d-%d) error (@%d-%d) ')' (%d@%d-%d)\n",
   8995               $$, RANGE (@$), $1, RANGE (@1), RANGE (@2), $3, RANGE (@3));
   8996     }
   8997 ;
   8998 
   8999 thing:
   9000   'x'
   9001     {
   9002       $$ = $1;
   9003       printf ("thing (%d@%d-%d): 'x' (%d@%d-%d)\n",
   9004               $$, RANGE (@$), $1, RANGE (@1));
   9005     }
   9006 ;
   9007 %%
   9008 /* Alias to ARGV[1]. */
   9009 const char *source = 0;
   9010 
   9011 static int
   9012 yylex (void)
   9013 {
   9014   static unsigned int counter = 0;
   9015 
   9016   int c = (yylval) = counter++;
   9017   /* As in BASIC, line numbers go from 10 to 10.  */
   9018  (yylloc).first_line = (yylloc).first_column = 10 * c;
   9019   (yylloc).last_line = (yylloc).last_column = (yylloc).first_line + 9;
   9020 
   9021 
   9022   if (source[c])
   9023     printf ("sending: '%c'", source[c]);
   9024   else
   9025     printf ("sending: EOF");
   9026   printf (" (%d@%d-%d)\n", c, RANGE ((yylloc)));
   9027   return source[c];
   9028 }
   9029 
   9030 static void
   9031 yyerror (const char *msg)
   9032 {
   9033   printf ("%d-%d: %s\n", RANGE (yylloc), msg);
   9034 }
   9035 
   9036 int
   9037 main (int argc, const char *argv[])
   9038 {
   9039   int status;
   9040   yydebug = !!getenv ("YYDEBUG");
   9041   assert (argc == 2);
   9042   source = argv[1];
   9043   status = yyparse ();
   9044   switch (status)
   9045     {
   9046       case 0: printf ("Successful parse.\n"); break;
   9047       case 1: printf ("Parsing FAILED.\n"); break;
   9048       default: printf ("Parsing FAILED (status %d).\n", status); break;
   9049     }
   9050   return status;
   9051 }
   9052 _ATEOF
   9053 
   9054 
   9055 
   9056 $at_traceoff
   9057 echo "actions.at:536: bison -o input.c input.y"
   9058 echo actions.at:536 >$at_check_line_file
   9059 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   9060 at_status=$?
   9061 grep '^ *+' $at_stder1 >&2
   9062 grep -v '^ *+' $at_stder1 >$at_stderr
   9063 at_failed=false
   9064 $at_diff $at_devnull $at_stderr || at_failed=:
   9065 $at_diff $at_devnull $at_stdout || at_failed=:
   9066 case $at_status in
   9067    77) echo 77 > $at_status_file
   9068             exit 77;;
   9069    0) ;;
   9070    *) echo "actions.at:536: exit code was $at_status, expected 0"
   9071       at_failed=:;;
   9072 esac
   9073 if $at_failed; then
   9074 
   9075   echo 1 > $at_status_file
   9076   exit 1
   9077 fi
   9078 
   9079 $at_traceon
   9080 
   9081    $at_traceoff
   9082 echo "actions.at:536: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   9083 echo actions.at:536 >$at_check_line_file
   9084 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   9085 at_status=$?
   9086 grep '^ *+' $at_stder1 >&2
   9087 grep -v '^ *+' $at_stder1 >$at_stderr
   9088 at_failed=false
   9089 echo stderr:; cat $at_stderr
   9090 echo stdout:; cat $at_stdout
   9091 case $at_status in
   9092    77) echo 77 > $at_status_file
   9093             exit 77;;
   9094    0) ;;
   9095    *) echo "actions.at:536: exit code was $at_status, expected 0"
   9096       at_failed=:;;
   9097 esac
   9098 if $at_failed; then
   9099 
   9100   echo 1 > $at_status_file
   9101   exit 1
   9102 fi
   9103 
   9104 $at_traceon
   9105 
   9106 
   9107 
   9108 # Check the location of "empty"
   9109 # -----------------------------
   9110 # I.e., epsilon-reductions, as in "(x)" which ends by reducing
   9111 # an empty "line" nterm.
   9112 # FIXME: This location is not satisfying.  Depend on the lookahead?
   9113 $at_traceoff
   9114 echo "actions.at:536: \$PREPARSER ./input '(x)'"
   9115 echo actions.at:536 >$at_check_line_file
   9116 ( $at_traceon; $PREPARSER ./input '(x)' ) >$at_stdout 2>$at_stder1
   9117 at_status=$?
   9118 grep '^ *+' $at_stder1 >&2
   9119 grep -v '^ *+' $at_stder1 >$at_stderr
   9120 at_failed=false
   9121 $at_diff $at_devnull $at_stderr || at_failed=:
   9122 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   9123 sending: 'x' (1@10-19)
   9124 thing (1@10-19): 'x' (1@10-19)
   9125 sending: ')' (2@20-29)
   9126 line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
   9127 sending: EOF (3@30-39)
   9128 input (0@29-29): /* Nothing */
   9129 input (2@0-29): line (0@0-29) input (0@29-29)
   9130 Freeing nterm input (2@0-29)
   9131 Successful parse.
   9132 " | $at_diff - $at_stdout || at_failed=:
   9133 case $at_status in
   9134    77) echo 77 > $at_status_file
   9135             exit 77;;
   9136    0) ;;
   9137    *) echo "actions.at:536: exit code was $at_status, expected 0"
   9138       at_failed=:;;
   9139 esac
   9140 if $at_failed; then
   9141 
   9142   echo 1 > $at_status_file
   9143   exit 1
   9144 fi
   9145 
   9146 $at_traceon
   9147 
   9148 
   9149 
   9150 # Check locations in error recovery
   9151 # ---------------------------------
   9152 # '(y)' is an error, but can be recovered from.  But what's the location
   9153 # of the error itself ('y'), and of the resulting reduction ('(error)').
   9154 $at_traceoff
   9155 echo "actions.at:536: \$PREPARSER ./input '(y)'"
   9156 echo actions.at:536 >$at_check_line_file
   9157 ( $at_traceon; $PREPARSER ./input '(y)' ) >$at_stdout 2>$at_stder1
   9158 at_status=$?
   9159 grep '^ *+' $at_stder1 >&2
   9160 grep -v '^ *+' $at_stder1 >$at_stderr
   9161 at_failed=false
   9162 $at_diff $at_devnull $at_stderr || at_failed=:
   9163 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   9164 sending: 'y' (1@10-19)
   9165 10-19: syntax error, unexpected 'y', expecting 'x'
   9166 Freeing token 'y' (1@10-19)
   9167 sending: ')' (2@20-29)
   9168 line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
   9169 sending: EOF (3@30-39)
   9170 input (0@29-29): /* Nothing */
   9171 input (2@0-29): line (-1@0-29) input (0@29-29)
   9172 Freeing nterm input (2@0-29)
   9173 Successful parse.
   9174 " | $at_diff - $at_stdout || at_failed=:
   9175 case $at_status in
   9176    77) echo 77 > $at_status_file
   9177             exit 77;;
   9178    0) ;;
   9179    *) echo "actions.at:536: exit code was $at_status, expected 0"
   9180       at_failed=:;;
   9181 esac
   9182 if $at_failed; then
   9183 
   9184   echo 1 > $at_status_file
   9185   exit 1
   9186 fi
   9187 
   9188 $at_traceon
   9189 
   9190 
   9191 
   9192 # Syntax errors caught by the parser
   9193 # ----------------------------------
   9194 # Exercise the discarding of stack top and input until `error'
   9195 # can be reduced.
   9196 #
   9197 #     '(', 'x', 'x', 'x', 'x', 'x', ')',
   9198 #
   9199 # Load the stack and provoke an error that cannot be caught by the
   9200 # grammar, to check that the stack is cleared.  And make sure the
   9201 # lookahead is freed.
   9202 #
   9203 #     '(', 'x', ')',
   9204 #     '(', 'x', ')',
   9205 #     'y'
   9206 $at_traceoff
   9207 echo "actions.at:536: \$PREPARSER ./input '(xxxxx)(x)(x)y'"
   9208 echo actions.at:536 >$at_check_line_file
   9209 ( $at_traceon; $PREPARSER ./input '(xxxxx)(x)(x)y' ) >$at_stdout 2>$at_stder1
   9210 at_status=$?
   9211 grep '^ *+' $at_stder1 >&2
   9212 grep -v '^ *+' $at_stder1 >$at_stderr
   9213 at_failed=false
   9214 $at_diff $at_devnull $at_stderr || at_failed=:
   9215 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   9216 sending: 'x' (1@10-19)
   9217 thing (1@10-19): 'x' (1@10-19)
   9218 sending: 'x' (2@20-29)
   9219 thing (2@20-29): 'x' (2@20-29)
   9220 sending: 'x' (3@30-39)
   9221 30-39: syntax error, unexpected 'x', expecting ')'
   9222 Freeing nterm thing (2@20-29)
   9223 Freeing nterm thing (1@10-19)
   9224 Freeing token 'x' (3@30-39)
   9225 sending: 'x' (4@40-49)
   9226 Freeing token 'x' (4@40-49)
   9227 sending: 'x' (5@50-59)
   9228 Freeing token 'x' (5@50-59)
   9229 sending: ')' (6@60-69)
   9230 line (-1@0-69): '(' (0@0-9) error (@10-59) ')' (6@60-69)
   9231 sending: '(' (7@70-79)
   9232 sending: 'x' (8@80-89)
   9233 thing (8@80-89): 'x' (8@80-89)
   9234 sending: ')' (9@90-99)
   9235 line (7@70-99): '(' (7@70-79) thing (8@80-89) ')' (9@90-99)
   9236 sending: '(' (10@100-109)
   9237 sending: 'x' (11@110-119)
   9238 thing (11@110-119): 'x' (11@110-119)
   9239 sending: ')' (12@120-129)
   9240 line (10@100-129): '(' (10@100-109) thing (11@110-119) ')' (12@120-129)
   9241 sending: 'y' (13@130-139)
   9242 input (0@129-129): /* Nothing */
   9243 input (2@100-129): line (10@100-129) input (0@129-129)
   9244 input (2@70-129): line (7@70-99) input (2@100-129)
   9245 input (2@0-129): line (-1@0-69) input (2@70-129)
   9246 130-139: syntax error, unexpected 'y', expecting \$end
   9247 Freeing nterm input (2@0-129)
   9248 Freeing token 'y' (13@130-139)
   9249 Parsing FAILED.
   9250 " | $at_diff - $at_stdout || at_failed=:
   9251 case $at_status in
   9252    77) echo 77 > $at_status_file
   9253             exit 77;;
   9254    1) ;;
   9255    *) echo "actions.at:536: exit code was $at_status, expected 1"
   9256       at_failed=:;;
   9257 esac
   9258 if $at_failed; then
   9259 
   9260   echo 1 > $at_status_file
   9261   exit 1
   9262 fi
   9263 
   9264 $at_traceon
   9265 
   9266 
   9267 # Check destruction upon stack overflow
   9268 # -------------------------------------
   9269 # Upon stack overflow, all symbols on the stack should be destroyed.
   9270 # Only check for yacc.c.
   9271 
   9272 
   9273 
   9274 
   9275       $at_traceoff
   9276       $at_times_p && times >$at_times_file
   9277     ) 5>&1 2>&1 | eval $at_tee_pipe
   9278     at_status=`cat $at_status_file`
   9279     ;;
   9280 
   9281   57 ) # 57. actions.at:537: Printers and Destructors with union: %glr-parser
   9282     at_setup_line='actions.at:537'
   9283     at_desc='Printers and Destructors with union: %glr-parser'
   9284     $at_quiet $ECHO_N " 57: Printers and Destructors with union: %glr-parser$ECHO_C"
   9285     at_xfail=no
   9286     (
   9287       echo "57. actions.at:537: testing ..."
   9288       $at_traceon
   9289 
   9290 
   9291 
   9292 # Make sure complex $n work.
   9293 
   9294 # Be sure to pass all the %directives to this macro to have correct
   9295 # helping macros.  So don't put any directly in the Bison file.
   9296 
   9297 
   9298 
   9299 
   9300 # Using yacc.c?
   9301 
   9302 
   9303 
   9304 
   9305 
   9306 
   9307 
   9308 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   9309 
   9310 # yyerror always sees the locations (when activated), except if
   9311 # yacc & pure & !param.
   9312 
   9313 
   9314 # The interface is pure: either because %pure-parser, or because we
   9315 # are using the C++ parsers.
   9316 
   9317 
   9318 
   9319 
   9320 
   9321 
   9322 
   9323 
   9324 
   9325 
   9326 
   9327 cat >input.y <<'_ATEOF'
   9328 %{
   9329 #ifdef HAVE_CONFIG_H
   9330 # include <config.h>
   9331   /* We don't need perfect functions for these tests. */
   9332 # undef malloc
   9333 # undef memcmp
   9334 # undef realloc
   9335 #endif
   9336 %}
   9337 
   9338 %{
   9339 #include <stdio.h>
   9340 #include <stdlib.h>
   9341 #include <assert.h>
   9342 
   9343 #define YYINITDEPTH 10
   9344 #define YYMAXDEPTH 10
   9345 #define RANGE(Location) (Location).first_line, (Location).last_line
   9346 %}
   9347 
   9348 %error-verbose
   9349 %debug
   9350 %verbose
   9351 %locations
   9352 %glr-parser
   9353 %union
   9354 {
   9355   int ival;
   9356 }
   9357 
   9358 
   9359 %{
   9360 
   9361 static int yylex (void);
   9362 static void yyerror (const char *msg);
   9363 %}
   9364 
   9365 %type <ival> '(' 'x' 'y' ')' ';' thing line input
   9366 
   9367 %printer
   9368   {
   9369     fprintf (yyoutput, "%d", $$);
   9370   }
   9371   input line thing 'x' 'y'
   9372 
   9373 %destructor
   9374   { printf ("Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
   9375   input
   9376 
   9377 %destructor
   9378   { printf ("Freeing nterm line (%d@%d-%d)\n", $$, RANGE (@$)); }
   9379   line
   9380 
   9381 %destructor
   9382   { printf ("Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
   9383   thing
   9384 
   9385 %destructor
   9386   { printf ("Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
   9387   'x'
   9388 
   9389 %destructor
   9390   { printf ("Freeing token 'y' (%d@%d-%d)\n", $$, RANGE (@$)); }
   9391   'y'
   9392 
   9393 %%
   9394 /*
   9395    This grammar is made to exercise error recovery.
   9396    "Lines" starting with `(' support error recovery, with
   9397    ')' as synchronizing token.  Lines starting with 'x' can never
   9398    be recovered from if in error.
   9399 */
   9400 
   9401 input:
   9402   /* Nothing. */
   9403     {
   9404       $$ = 0;
   9405       printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
   9406     }
   9407 | line input /* Right recursive to load the stack so that popping at
   9408 		EOF can	be exercised.  */
   9409     {
   9410       $$ = 2;
   9411       printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
   9412 	      $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
   9413     }
   9414 ;
   9415 
   9416 line:
   9417   thing thing thing ';'
   9418     {
   9419       $$ = $1;
   9420       printf ("line (%d@%d-%d): thing (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ';' (%d@%d-%d)\n",
   9421               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   9422               $3, RANGE (@3), $4, RANGE (@4));
   9423     }
   9424 | '(' thing thing ')'
   9425     {
   9426       $$ = $1;
   9427       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   9428               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2),
   9429               $3, RANGE (@3), $4, RANGE (@4));
   9430     }
   9431 | '(' thing ')'
   9432     {
   9433       $$ = $1;
   9434       printf ("line (%d@%d-%d): '(' (%d@%d-%d) thing (%d@%d-%d) ')' (%d@%d-%d)\n",
   9435               $$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2), $3, RANGE (@3));
   9436     }
   9437 | '(' error ')'
   9438     {
   9439       $$ = -1;
   9440       printf ("line (%d@%d-%d): '(' (%d@%d-%d) error (@%d-%d) ')' (%d@%d-%d)\n",
   9441               $$, RANGE (@$), $1, RANGE (@1), RANGE (@2), $3, RANGE (@3));
   9442     }
   9443 ;
   9444 
   9445 thing:
   9446   'x'
   9447     {
   9448       $$ = $1;
   9449       printf ("thing (%d@%d-%d): 'x' (%d@%d-%d)\n",
   9450               $$, RANGE (@$), $1, RANGE (@1));
   9451     }
   9452 ;
   9453 %%
   9454 /* Alias to ARGV[1]. */
   9455 const char *source = 0;
   9456 
   9457 static int
   9458 yylex (void)
   9459 {
   9460   static unsigned int counter = 0;
   9461 
   9462   int c = (yylval).ival = counter++;
   9463   /* As in BASIC, line numbers go from 10 to 10.  */
   9464  (yylloc).first_line = (yylloc).first_column = 10 * c;
   9465   (yylloc).last_line = (yylloc).last_column = (yylloc).first_line + 9;
   9466 
   9467 
   9468   if (source[c])
   9469     printf ("sending: '%c'", source[c]);
   9470   else
   9471     printf ("sending: EOF");
   9472   printf (" (%d@%d-%d)\n", c, RANGE ((yylloc)));
   9473   return source[c];
   9474 }
   9475 
   9476 static void
   9477 yyerror (const char *msg)
   9478 {
   9479   printf ("%d-%d: %s\n", RANGE (yylloc), msg);
   9480 }
   9481 
   9482 int
   9483 main (int argc, const char *argv[])
   9484 {
   9485   int status;
   9486   yydebug = !!getenv ("YYDEBUG");
   9487   assert (argc == 2);
   9488   source = argv[1];
   9489   status = yyparse ();
   9490   switch (status)
   9491     {
   9492       case 0: printf ("Successful parse.\n"); break;
   9493       case 1: printf ("Parsing FAILED.\n"); break;
   9494       default: printf ("Parsing FAILED (status %d).\n", status); break;
   9495     }
   9496   return status;
   9497 }
   9498 _ATEOF
   9499 
   9500 
   9501 
   9502 $at_traceoff
   9503 echo "actions.at:537: bison -o input.c input.y"
   9504 echo actions.at:537 >$at_check_line_file
   9505 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   9506 at_status=$?
   9507 grep '^ *+' $at_stder1 >&2
   9508 grep -v '^ *+' $at_stder1 >$at_stderr
   9509 at_failed=false
   9510 $at_diff $at_devnull $at_stderr || at_failed=:
   9511 $at_diff $at_devnull $at_stdout || at_failed=:
   9512 case $at_status in
   9513    77) echo 77 > $at_status_file
   9514             exit 77;;
   9515    0) ;;
   9516    *) echo "actions.at:537: exit code was $at_status, expected 0"
   9517       at_failed=:;;
   9518 esac
   9519 if $at_failed; then
   9520 
   9521   echo 1 > $at_status_file
   9522   exit 1
   9523 fi
   9524 
   9525 $at_traceon
   9526 
   9527    $at_traceoff
   9528 echo "actions.at:537: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   9529 echo actions.at:537 >$at_check_line_file
   9530 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   9531 at_status=$?
   9532 grep '^ *+' $at_stder1 >&2
   9533 grep -v '^ *+' $at_stder1 >$at_stderr
   9534 at_failed=false
   9535 echo stderr:; cat $at_stderr
   9536 echo stdout:; cat $at_stdout
   9537 case $at_status in
   9538    77) echo 77 > $at_status_file
   9539             exit 77;;
   9540    0) ;;
   9541    *) echo "actions.at:537: exit code was $at_status, expected 0"
   9542       at_failed=:;;
   9543 esac
   9544 if $at_failed; then
   9545 
   9546   echo 1 > $at_status_file
   9547   exit 1
   9548 fi
   9549 
   9550 $at_traceon
   9551 
   9552 
   9553 
   9554 # Check the location of "empty"
   9555 # -----------------------------
   9556 # I.e., epsilon-reductions, as in "(x)" which ends by reducing
   9557 # an empty "line" nterm.
   9558 # FIXME: This location is not satisfying.  Depend on the lookahead?
   9559 $at_traceoff
   9560 echo "actions.at:537: \$PREPARSER ./input '(x)'"
   9561 echo actions.at:537 >$at_check_line_file
   9562 ( $at_traceon; $PREPARSER ./input '(x)' ) >$at_stdout 2>$at_stder1
   9563 at_status=$?
   9564 grep '^ *+' $at_stder1 >&2
   9565 grep -v '^ *+' $at_stder1 >$at_stderr
   9566 at_failed=false
   9567 $at_diff $at_devnull $at_stderr || at_failed=:
   9568 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   9569 sending: 'x' (1@10-19)
   9570 thing (1@10-19): 'x' (1@10-19)
   9571 sending: ')' (2@20-29)
   9572 line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29)
   9573 sending: EOF (3@30-39)
   9574 input (0@29-29): /* Nothing */
   9575 input (2@0-29): line (0@0-29) input (0@29-29)
   9576 Freeing nterm input (2@0-29)
   9577 Successful parse.
   9578 " | $at_diff - $at_stdout || at_failed=:
   9579 case $at_status in
   9580    77) echo 77 > $at_status_file
   9581             exit 77;;
   9582    0) ;;
   9583    *) echo "actions.at:537: exit code was $at_status, expected 0"
   9584       at_failed=:;;
   9585 esac
   9586 if $at_failed; then
   9587 
   9588   echo 1 > $at_status_file
   9589   exit 1
   9590 fi
   9591 
   9592 $at_traceon
   9593 
   9594 
   9595 
   9596 # Check locations in error recovery
   9597 # ---------------------------------
   9598 # '(y)' is an error, but can be recovered from.  But what's the location
   9599 # of the error itself ('y'), and of the resulting reduction ('(error)').
   9600 $at_traceoff
   9601 echo "actions.at:537: \$PREPARSER ./input '(y)'"
   9602 echo actions.at:537 >$at_check_line_file
   9603 ( $at_traceon; $PREPARSER ./input '(y)' ) >$at_stdout 2>$at_stder1
   9604 at_status=$?
   9605 grep '^ *+' $at_stder1 >&2
   9606 grep -v '^ *+' $at_stder1 >$at_stderr
   9607 at_failed=false
   9608 $at_diff $at_devnull $at_stderr || at_failed=:
   9609 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   9610 sending: 'y' (1@10-19)
   9611 10-19: syntax error, unexpected 'y', expecting 'x'
   9612 Freeing token 'y' (1@10-19)
   9613 sending: ')' (2@20-29)
   9614 line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29)
   9615 sending: EOF (3@30-39)
   9616 input (0@29-29): /* Nothing */
   9617 input (2@0-29): line (-1@0-29) input (0@29-29)
   9618 Freeing nterm input (2@0-29)
   9619 Successful parse.
   9620 " | $at_diff - $at_stdout || at_failed=:
   9621 case $at_status in
   9622    77) echo 77 > $at_status_file
   9623             exit 77;;
   9624    0) ;;
   9625    *) echo "actions.at:537: exit code was $at_status, expected 0"
   9626       at_failed=:;;
   9627 esac
   9628 if $at_failed; then
   9629 
   9630   echo 1 > $at_status_file
   9631   exit 1
   9632 fi
   9633 
   9634 $at_traceon
   9635 
   9636 
   9637 
   9638 # Syntax errors caught by the parser
   9639 # ----------------------------------
   9640 # Exercise the discarding of stack top and input until `error'
   9641 # can be reduced.
   9642 #
   9643 #     '(', 'x', 'x', 'x', 'x', 'x', ')',
   9644 #
   9645 # Load the stack and provoke an error that cannot be caught by the
   9646 # grammar, to check that the stack is cleared.  And make sure the
   9647 # lookahead is freed.
   9648 #
   9649 #     '(', 'x', ')',
   9650 #     '(', 'x', ')',
   9651 #     'y'
   9652 $at_traceoff
   9653 echo "actions.at:537: \$PREPARSER ./input '(xxxxx)(x)(x)y'"
   9654 echo actions.at:537 >$at_check_line_file
   9655 ( $at_traceon; $PREPARSER ./input '(xxxxx)(x)(x)y' ) >$at_stdout 2>$at_stder1
   9656 at_status=$?
   9657 grep '^ *+' $at_stder1 >&2
   9658 grep -v '^ *+' $at_stder1 >$at_stderr
   9659 at_failed=false
   9660 $at_diff $at_devnull $at_stderr || at_failed=:
   9661 echo >>$at_stdout; echo "sending: '(' (0@0-9)
   9662 sending: 'x' (1@10-19)
   9663 thing (1@10-19): 'x' (1@10-19)
   9664 sending: 'x' (2@20-29)
   9665 thing (2@20-29): 'x' (2@20-29)
   9666 sending: 'x' (3@30-39)
   9667 30-39: syntax error, unexpected 'x', expecting ')'
   9668 Freeing nterm thing (2@20-29)
   9669 Freeing nterm thing (1@10-19)
   9670 Freeing token 'x' (3@30-39)
   9671 sending: 'x' (4@40-49)
   9672 Freeing token 'x' (4@40-49)
   9673 sending: 'x' (5@50-59)
   9674 Freeing token 'x' (5@50-59)
   9675 sending: ')' (6@60-69)
   9676 line (-1@0-69): '(' (0@0-9) error (@10-59) ')' (6@60-69)
   9677 sending: '(' (7@70-79)
   9678 sending: 'x' (8@80-89)
   9679 thing (8@80-89): 'x' (8@80-89)
   9680 sending: ')' (9@90-99)
   9681 line (7@70-99): '(' (7@70-79) thing (8@80-89) ')' (9@90-99)
   9682 sending: '(' (10@100-109)
   9683 sending: 'x' (11@110-119)
   9684 thing (11@110-119): 'x' (11@110-119)
   9685 sending: ')' (12@120-129)
   9686 line (10@100-129): '(' (10@100-109) thing (11@110-119) ')' (12@120-129)
   9687 sending: 'y' (13@130-139)
   9688 input (0@129-129): /* Nothing */
   9689 input (2@100-129): line (10@100-129) input (0@129-129)
   9690 input (2@70-129): line (7@70-99) input (2@100-129)
   9691 input (2@0-129): line (-1@0-69) input (2@70-129)
   9692 130-139: syntax error, unexpected 'y', expecting \$end
   9693 Freeing nterm input (2@0-129)
   9694 Freeing token 'y' (13@130-139)
   9695 Parsing FAILED.
   9696 " | $at_diff - $at_stdout || at_failed=:
   9697 case $at_status in
   9698    77) echo 77 > $at_status_file
   9699             exit 77;;
   9700    1) ;;
   9701    *) echo "actions.at:537: exit code was $at_status, expected 1"
   9702       at_failed=:;;
   9703 esac
   9704 if $at_failed; then
   9705 
   9706   echo 1 > $at_status_file
   9707   exit 1
   9708 fi
   9709 
   9710 $at_traceon
   9711 
   9712 
   9713 # Check destruction upon stack overflow
   9714 # -------------------------------------
   9715 # Upon stack overflow, all symbols on the stack should be destroyed.
   9716 # Only check for yacc.c.
   9717 
   9718 
   9719 
   9720 
   9721       $at_traceoff
   9722       $at_times_p && times >$at_times_file
   9723     ) 5>&1 2>&1 | eval $at_tee_pipe
   9724     at_status=`cat $at_status_file`
   9725     ;;
   9726 
   9727 
   9728   banner-8 ) # Banner 8. conflicts.at:20
   9729     cat <<\_ATEOF
   9730 
   9731 Conflicts.
   9732 
   9733 _ATEOF
   9734     ;;
   9735 
   9736   58 ) # 58. conflicts.at:32: S/R in initial
   9737     at_setup_line='conflicts.at:32'
   9738     at_desc='S/R in initial'
   9739     $at_quiet $ECHO_N " 58: S/R in initial                               $ECHO_C"
   9740     at_xfail=no
   9741     (
   9742       echo "58. conflicts.at:32: testing ..."
   9743       $at_traceon
   9744 
   9745 
   9746 cat >input.y <<'_ATEOF'
   9747 %expect 1
   9748 %%
   9749 exp: e 'e';
   9750 e: 'e' | /* Nothing. */;
   9751 _ATEOF
   9752 
   9753 
   9754 $at_traceoff
   9755 echo "conflicts.at:43: bison -o input.c input.y"
   9756 echo conflicts.at:43 >$at_check_line_file
   9757 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   9758 at_status=$?
   9759 grep '^ *+' $at_stder1 >&2
   9760 grep -v '^ *+' $at_stder1 >$at_stderr
   9761 at_failed=false
   9762 echo >>$at_stderr; echo "input.y:4.9: warning: rule never reduced because of conflicts: e: /* empty */
   9763 " | $at_diff - $at_stderr || at_failed=:
   9764 $at_diff $at_devnull $at_stdout || at_failed=:
   9765 case $at_status in
   9766    77) echo 77 > $at_status_file
   9767             exit 77;;
   9768    0) ;;
   9769    *) echo "conflicts.at:43: exit code was $at_status, expected 0"
   9770       at_failed=:;;
   9771 esac
   9772 if $at_failed; then
   9773 
   9774   echo 1 > $at_status_file
   9775   exit 1
   9776 fi
   9777 
   9778 $at_traceon
   9779 
   9780 
   9781       $at_traceoff
   9782       $at_times_p && times >$at_times_file
   9783     ) 5>&1 2>&1 | eval $at_tee_pipe
   9784     at_status=`cat $at_status_file`
   9785     ;;
   9786 
   9787   59 ) # 59. conflicts.at:52: %nonassoc and eof
   9788     at_setup_line='conflicts.at:52'
   9789     at_desc='%nonassoc and eof'
   9790     $at_quiet $ECHO_N " 59: %nonassoc and eof                            $ECHO_C"
   9791     at_xfail=no
   9792     (
   9793       echo "59. conflicts.at:52: testing ..."
   9794       $at_traceon
   9795 
   9796 
   9797 cat >input.y <<'_ATEOF'
   9798 %{
   9799 #ifdef HAVE_CONFIG_H
   9800 # include <config.h>
   9801   /* We don't need perfect functions for these tests. */
   9802 # undef malloc
   9803 # undef memcmp
   9804 # undef realloc
   9805 #endif
   9806 %}
   9807 
   9808 
   9809 %{
   9810 #include <stdio.h>
   9811 #include <stdlib.h>
   9812 
   9813 #define YYERROR_VERBOSE 1
   9814 static void
   9815 yyerror (const char *msg)
   9816 {
   9817   fprintf (stderr, "%s\n", msg);
   9818 }
   9819 
   9820 /* The current argument. */
   9821 static const char *input = NULL;
   9822 
   9823 static int
   9824 yylex (void)
   9825 {
   9826   /* No token stands for end of file. */
   9827   if (input && *input)
   9828     return *input++;
   9829   else
   9830     return 0;
   9831 }
   9832 
   9833 %}
   9834 
   9835 %nonassoc '<' '>'
   9836 
   9837 %%
   9838 expr: expr '<' expr
   9839     | expr '>' expr
   9840     | '0'
   9841     ;
   9842 %%
   9843 int
   9844 main (int argc, const char *argv[])
   9845 {
   9846   if (argc > 1)
   9847     input = argv[1];
   9848   return yyparse ();
   9849 }
   9850 _ATEOF
   9851 
   9852 
   9853 
   9854 # Specify the output files to avoid problems on different file systems.
   9855 $at_traceoff
   9856 echo "conflicts.at:100: bison -o input.c input.y"
   9857 echo conflicts.at:100 >$at_check_line_file
   9858 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   9859 at_status=$?
   9860 grep '^ *+' $at_stder1 >&2
   9861 grep -v '^ *+' $at_stder1 >$at_stderr
   9862 at_failed=false
   9863 $at_diff $at_devnull $at_stderr || at_failed=:
   9864 $at_diff $at_devnull $at_stdout || at_failed=:
   9865 case $at_status in
   9866    77) echo 77 > $at_status_file
   9867             exit 77;;
   9868    0) ;;
   9869    *) echo "conflicts.at:100: exit code was $at_status, expected 0"
   9870       at_failed=:;;
   9871 esac
   9872 if $at_failed; then
   9873 
   9874   echo 1 > $at_status_file
   9875   exit 1
   9876 fi
   9877 
   9878 $at_traceon
   9879 
   9880 $at_traceoff
   9881 echo "conflicts.at:101: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o input input.c \$LIBS"
   9882 echo conflicts.at:101 >$at_check_line_file
   9883 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS ) >$at_stdout 2>$at_stder1
   9884 at_status=$?
   9885 grep '^ *+' $at_stder1 >&2
   9886 grep -v '^ *+' $at_stder1 >$at_stderr
   9887 at_failed=false
   9888 echo stderr:; cat $at_stderr
   9889 echo stdout:; cat $at_stdout
   9890 case $at_status in
   9891    77) echo 77 > $at_status_file
   9892             exit 77;;
   9893    0) ;;
   9894    *) echo "conflicts.at:101: exit code was $at_status, expected 0"
   9895       at_failed=:;;
   9896 esac
   9897 if $at_failed; then
   9898 
   9899   echo 1 > $at_status_file
   9900   exit 1
   9901 fi
   9902 
   9903 $at_traceon
   9904 
   9905 
   9906 $at_traceoff
   9907 echo "conflicts.at:103: \$PREPARSER ./input '0<0'"
   9908 echo conflicts.at:103 >$at_check_line_file
   9909 ( $at_traceon; $PREPARSER ./input '0<0' ) >$at_stdout 2>$at_stder1
   9910 at_status=$?
   9911 grep '^ *+' $at_stder1 >&2
   9912 grep -v '^ *+' $at_stder1 >$at_stderr
   9913 at_failed=false
   9914 $at_diff $at_devnull $at_stderr || at_failed=:
   9915 $at_diff $at_devnull $at_stdout || at_failed=:
   9916 case $at_status in
   9917    77) echo 77 > $at_status_file
   9918             exit 77;;
   9919    0) ;;
   9920    *) echo "conflicts.at:103: exit code was $at_status, expected 0"
   9921       at_failed=:;;
   9922 esac
   9923 if $at_failed; then
   9924 
   9925   echo 1 > $at_status_file
   9926   exit 1
   9927 fi
   9928 
   9929 $at_traceon
   9930 
   9931 # FIXME: This is an actual bug, but a new one, in the sense that
   9932 # no one has ever spotted it!  The messages are *wrong*: there should
   9933 # be nothing there, it should be expected eof.
   9934 $at_traceoff
   9935 echo "conflicts.at:109: \$PREPARSER ./input '0<0<0'"
   9936 echo conflicts.at:109 >$at_check_line_file
   9937 ( $at_traceon; $PREPARSER ./input '0<0<0' ) >$at_stdout 2>$at_stder1
   9938 at_status=$?
   9939 grep '^ *+' $at_stder1 >&2
   9940 grep -v '^ *+' $at_stder1 >$at_stderr
   9941 at_failed=false
   9942 echo >>$at_stderr; echo "syntax error, unexpected '<', expecting '<' or '>'
   9943 " | $at_diff - $at_stderr || at_failed=:
   9944 $at_diff $at_devnull $at_stdout || at_failed=:
   9945 case $at_status in
   9946    77) echo 77 > $at_status_file
   9947             exit 77;;
   9948    1) ;;
   9949    *) echo "conflicts.at:109: exit code was $at_status, expected 1"
   9950       at_failed=:;;
   9951 esac
   9952 if $at_failed; then
   9953 
   9954   echo 1 > $at_status_file
   9955   exit 1
   9956 fi
   9957 
   9958 $at_traceon
   9959 
   9960 
   9961 $at_traceoff
   9962 echo "conflicts.at:111: \$PREPARSER ./input '0>0'"
   9963 echo conflicts.at:111 >$at_check_line_file
   9964 ( $at_traceon; $PREPARSER ./input '0>0' ) >$at_stdout 2>$at_stder1
   9965 at_status=$?
   9966 grep '^ *+' $at_stder1 >&2
   9967 grep -v '^ *+' $at_stder1 >$at_stderr
   9968 at_failed=false
   9969 $at_diff $at_devnull $at_stderr || at_failed=:
   9970 $at_diff $at_devnull $at_stdout || at_failed=:
   9971 case $at_status in
   9972    77) echo 77 > $at_status_file
   9973             exit 77;;
   9974    0) ;;
   9975    *) echo "conflicts.at:111: exit code was $at_status, expected 0"
   9976       at_failed=:;;
   9977 esac
   9978 if $at_failed; then
   9979 
   9980   echo 1 > $at_status_file
   9981   exit 1
   9982 fi
   9983 
   9984 $at_traceon
   9985 
   9986 $at_traceoff
   9987 echo "conflicts.at:114: \$PREPARSER ./input '0>0>0'"
   9988 echo conflicts.at:114 >$at_check_line_file
   9989 ( $at_traceon; $PREPARSER ./input '0>0>0' ) >$at_stdout 2>$at_stder1
   9990 at_status=$?
   9991 grep '^ *+' $at_stder1 >&2
   9992 grep -v '^ *+' $at_stder1 >$at_stderr
   9993 at_failed=false
   9994 echo >>$at_stderr; echo "syntax error, unexpected '>', expecting '<' or '>'
   9995 " | $at_diff - $at_stderr || at_failed=:
   9996 $at_diff $at_devnull $at_stdout || at_failed=:
   9997 case $at_status in
   9998    77) echo 77 > $at_status_file
   9999             exit 77;;
   10000    1) ;;
   10001    *) echo "conflicts.at:114: exit code was $at_status, expected 1"
   10002       at_failed=:;;
   10003 esac
   10004 if $at_failed; then
   10005 
   10006   echo 1 > $at_status_file
   10007   exit 1
   10008 fi
   10009 
   10010 $at_traceon
   10011 
   10012 
   10013 $at_traceoff
   10014 echo "conflicts.at:118: \$PREPARSER ./input '0<0>0'"
   10015 echo conflicts.at:118 >$at_check_line_file
   10016 ( $at_traceon; $PREPARSER ./input '0<0>0' ) >$at_stdout 2>$at_stder1
   10017 at_status=$?
   10018 grep '^ *+' $at_stder1 >&2
   10019 grep -v '^ *+' $at_stder1 >$at_stderr
   10020 at_failed=false
   10021 echo >>$at_stderr; echo "syntax error, unexpected '>', expecting '<' or '>'
   10022 " | $at_diff - $at_stderr || at_failed=:
   10023 $at_diff $at_devnull $at_stdout || at_failed=:
   10024 case $at_status in
   10025    77) echo 77 > $at_status_file
   10026             exit 77;;
   10027    1) ;;
   10028    *) echo "conflicts.at:118: exit code was $at_status, expected 1"
   10029       at_failed=:;;
   10030 esac
   10031 if $at_failed; then
   10032 
   10033   echo 1 > $at_status_file
   10034   exit 1
   10035 fi
   10036 
   10037 $at_traceon
   10038 
   10039 
   10040       $at_traceoff
   10041       $at_times_p && times >$at_times_file
   10042     ) 5>&1 2>&1 | eval $at_tee_pipe
   10043     at_status=`cat $at_status_file`
   10044     ;;
   10045 
   10046   60 ) # 60. conflicts.at:128: Unresolved SR Conflicts
   10047     at_setup_line='conflicts.at:128'
   10048     at_desc='Unresolved SR Conflicts'
   10049     $at_quiet $ECHO_N " 60: Unresolved SR Conflicts                      $ECHO_C"
   10050     at_xfail=no
   10051     (
   10052       echo "60. conflicts.at:128: testing ..."
   10053       $at_traceon
   10054 
   10055 
   10056 
   10057 
   10058 cat >input.y <<'_ATEOF'
   10059 %token NUM OP
   10060 %%
   10061 exp: exp OP exp | NUM;
   10062 _ATEOF
   10063 
   10064 
   10065 $at_traceoff
   10066 echo "conflicts.at:140: bison -o input.c --report=all input.y"
   10067 echo conflicts.at:140 >$at_check_line_file
   10068 ( $at_traceon; bison -o input.c --report=all input.y ) >$at_stdout 2>$at_stder1
   10069 at_status=$?
   10070 grep '^ *+' $at_stder1 >&2
   10071 grep -v '^ *+' $at_stder1 >$at_stderr
   10072 at_failed=false
   10073 echo >>$at_stderr; echo "input.y: conflicts: 1 shift/reduce
   10074 " | $at_diff - $at_stderr || at_failed=:
   10075 $at_diff $at_devnull $at_stdout || at_failed=:
   10076 case $at_status in
   10077    77) echo 77 > $at_status_file
   10078             exit 77;;
   10079    0) ;;
   10080    *) echo "conflicts.at:140: exit code was $at_status, expected 0"
   10081       at_failed=:;;
   10082 esac
   10083 if $at_failed; then
   10084 
   10085   echo 1 > $at_status_file
   10086   exit 1
   10087 fi
   10088 
   10089 $at_traceon
   10090 
   10091 
   10092 # Check the contents of the report.
   10093 $at_traceoff
   10094 echo "conflicts.at:225: cat input.output"
   10095 echo conflicts.at:225 >$at_check_line_file
   10096 ( $at_traceon; cat input.output ) >$at_stdout 2>$at_stder1
   10097 at_status=$?
   10098 grep '^ *+' $at_stder1 >&2
   10099 grep -v '^ *+' $at_stder1 >$at_stderr
   10100 at_failed=false
   10101 $at_diff $at_devnull $at_stderr || at_failed=:
   10102 echo >>$at_stdout; echo "State 5 conflicts: 1 shift/reduce
   10103 
   10104 
   10105 Grammar
   10106 
   10107     0 \$accept: exp \$end
   10108 
   10109     1 exp: exp OP exp
   10110     2    | NUM
   10111 
   10112 
   10113 Terminals, with rules where they appear
   10114 
   10115 \$end (0) 0
   10116 error (256)
   10117 NUM (258) 2
   10118 OP (259) 1
   10119 
   10120 
   10121 Nonterminals, with rules where they appear
   10122 
   10123 \$accept (5)
   10124     on left: 0
   10125 exp (6)
   10126     on left: 1 2, on right: 0 1
   10127 
   10128 
   10129 state 0
   10130 
   10131     0 \$accept: . exp \$end
   10132     1 exp: . exp OP exp
   10133     2    | . NUM
   10134 
   10135     NUM  shift, and go to state 1
   10136 
   10137     exp  go to state 2
   10138 
   10139 
   10140 state 1
   10141 
   10142     2 exp: NUM .
   10143 
   10144     \$default  reduce using rule 2 (exp)
   10145 
   10146 
   10147 state 2
   10148 
   10149     0 \$accept: exp . \$end
   10150     1 exp: exp . OP exp
   10151 
   10152     \$end  shift, and go to state 3
   10153     OP    shift, and go to state 4
   10154 
   10155 
   10156 state 3
   10157 
   10158     0 \$accept: exp \$end .
   10159 
   10160     \$default  accept
   10161 
   10162 
   10163 state 4
   10164 
   10165     1 exp: . exp OP exp
   10166     1    | exp OP . exp
   10167     2    | . NUM
   10168 
   10169     NUM  shift, and go to state 1
   10170 
   10171     exp  go to state 5
   10172 
   10173 
   10174 state 5
   10175 
   10176     1 exp: exp . OP exp  [\$end, OP]
   10177     1    | exp OP exp .  [\$end, OP]
   10178 
   10179     OP  shift, and go to state 4
   10180 
   10181     OP        [reduce using rule 1 (exp)]
   10182     \$default  reduce using rule 1 (exp)
   10183 " | $at_diff - $at_stdout || at_failed=:
   10184 case $at_status in
   10185    77) echo 77 > $at_status_file
   10186             exit 77;;
   10187    0) ;;
   10188    *) echo "conflicts.at:225: exit code was $at_status, expected 0"
   10189       at_failed=:;;
   10190 esac
   10191 if $at_failed; then
   10192 
   10193   echo 1 > $at_status_file
   10194   exit 1
   10195 fi
   10196 
   10197 $at_traceon
   10198 
   10199 
   10200       $at_traceoff
   10201       $at_times_p && times >$at_times_file
   10202     ) 5>&1 2>&1 | eval $at_tee_pipe
   10203     at_status=`cat $at_status_file`
   10204     ;;
   10205 
   10206   61 ) # 61. conflicts.at:235: Resolved SR Conflicts
   10207     at_setup_line='conflicts.at:235'
   10208     at_desc='Resolved SR Conflicts'
   10209     $at_quiet $ECHO_N " 61: Resolved SR Conflicts                        $ECHO_C"
   10210     at_xfail=no
   10211     (
   10212       echo "61. conflicts.at:235: testing ..."
   10213       $at_traceon
   10214 
   10215 
   10216 
   10217 
   10218 cat >input.y <<'_ATEOF'
   10219 %token NUM OP
   10220 %left OP
   10221 %%
   10222 exp: exp OP exp | NUM;
   10223 _ATEOF
   10224 
   10225 
   10226 $at_traceoff
   10227 echo "conflicts.at:246: bison -o input.c --report=all input.y"
   10228 echo conflicts.at:246 >$at_check_line_file
   10229 ( $at_traceon; bison -o input.c --report=all input.y ) >$at_stdout 2>$at_stder1
   10230 at_status=$?
   10231 grep '^ *+' $at_stder1 >&2
   10232 grep -v '^ *+' $at_stder1 >$at_stderr
   10233 at_failed=false
   10234 $at_diff $at_devnull $at_stderr || at_failed=:
   10235 $at_diff $at_devnull $at_stdout || at_failed=:
   10236 case $at_status in
   10237    77) echo 77 > $at_status_file
   10238             exit 77;;
   10239    0) ;;
   10240    *) echo "conflicts.at:246: exit code was $at_status, expected 0"
   10241       at_failed=:;;
   10242 esac
   10243 if $at_failed; then
   10244 
   10245   echo 1 > $at_status_file
   10246   exit 1
   10247 fi
   10248 
   10249 $at_traceon
   10250 
   10251 
   10252 # Check the contents of the report.
   10253 $at_traceoff
   10254 echo "conflicts.at:327: cat input.output"
   10255 echo conflicts.at:327 >$at_check_line_file
   10256 ( $at_traceon; cat input.output ) >$at_stdout 2>$at_stder1
   10257 at_status=$?
   10258 grep '^ *+' $at_stder1 >&2
   10259 grep -v '^ *+' $at_stder1 >$at_stderr
   10260 at_failed=false
   10261 $at_diff $at_devnull $at_stderr || at_failed=:
   10262 echo >>$at_stdout; echo "Grammar
   10263 
   10264     0 \$accept: exp \$end
   10265 
   10266     1 exp: exp OP exp
   10267     2    | NUM
   10268 
   10269 
   10270 Terminals, with rules where they appear
   10271 
   10272 \$end (0) 0
   10273 error (256)
   10274 NUM (258) 2
   10275 OP (259) 1
   10276 
   10277 
   10278 Nonterminals, with rules where they appear
   10279 
   10280 \$accept (5)
   10281     on left: 0
   10282 exp (6)
   10283     on left: 1 2, on right: 0 1
   10284 
   10285 
   10286 state 0
   10287 
   10288     0 \$accept: . exp \$end
   10289     1 exp: . exp OP exp
   10290     2    | . NUM
   10291 
   10292     NUM  shift, and go to state 1
   10293 
   10294     exp  go to state 2
   10295 
   10296 
   10297 state 1
   10298 
   10299     2 exp: NUM .
   10300 
   10301     \$default  reduce using rule 2 (exp)
   10302 
   10303 
   10304 state 2
   10305 
   10306     0 \$accept: exp . \$end
   10307     1 exp: exp . OP exp
   10308 
   10309     \$end  shift, and go to state 3
   10310     OP    shift, and go to state 4
   10311 
   10312 
   10313 state 3
   10314 
   10315     0 \$accept: exp \$end .
   10316 
   10317     \$default  accept
   10318 
   10319 
   10320 state 4
   10321 
   10322     1 exp: . exp OP exp
   10323     1    | exp OP . exp
   10324     2    | . NUM
   10325 
   10326     NUM  shift, and go to state 1
   10327 
   10328     exp  go to state 5
   10329 
   10330 
   10331 state 5
   10332 
   10333     1 exp: exp . OP exp  [\$end, OP]
   10334     1    | exp OP exp .  [\$end, OP]
   10335 
   10336     \$default  reduce using rule 1 (exp)
   10337 
   10338     Conflict between rule 1 and token OP resolved as reduce (%left OP).
   10339 " | $at_diff - $at_stdout || at_failed=:
   10340 case $at_status in
   10341    77) echo 77 > $at_status_file
   10342             exit 77;;
   10343    0) ;;
   10344    *) echo "conflicts.at:327: exit code was $at_status, expected 0"
   10345       at_failed=:;;
   10346 esac
   10347 if $at_failed; then
   10348 
   10349   echo 1 > $at_status_file
   10350   exit 1
   10351 fi
   10352 
   10353 $at_traceon
   10354 
   10355 
   10356       $at_traceoff
   10357       $at_times_p && times >$at_times_file
   10358     ) 5>&1 2>&1 | eval $at_tee_pipe
   10359     at_status=`cat $at_status_file`
   10360     ;;
   10361 
   10362   62 ) # 62. conflicts.at:357: Defaulted Conflicted Reduction
   10363     at_setup_line='conflicts.at:357'
   10364     at_desc='Defaulted Conflicted Reduction'
   10365     $at_quiet $ECHO_N " 62: Defaulted Conflicted Reduction               $ECHO_C"
   10366     at_xfail=no
   10367     (
   10368       echo "62. conflicts.at:357: testing ..."
   10369       $at_traceon
   10370 
   10371 
   10372 
   10373 cat >input.y <<'_ATEOF'
   10374 %%
   10375 exp: num | id;
   10376 num: '0';
   10377 id : '0';
   10378 %%
   10379 _ATEOF
   10380 
   10381 
   10382 $at_traceoff
   10383 echo "conflicts.at:371: bison -o input.c --report=all input.y"
   10384 echo conflicts.at:371 >$at_check_line_file
   10385 ( $at_traceon; bison -o input.c --report=all input.y ) >$at_stdout 2>$at_stder1
   10386 at_status=$?
   10387 grep '^ *+' $at_stder1 >&2
   10388 grep -v '^ *+' $at_stder1 >$at_stderr
   10389 at_failed=false
   10390 echo >>$at_stderr; echo "input.y: conflicts: 1 reduce/reduce
   10391 input.y:4.6-8: warning: rule never reduced because of conflicts: id: '0'
   10392 " | $at_diff - $at_stderr || at_failed=:
   10393 $at_diff $at_devnull $at_stdout || at_failed=:
   10394 case $at_status in
   10395    77) echo 77 > $at_status_file
   10396             exit 77;;
   10397    0) ;;
   10398    *) echo "conflicts.at:371: exit code was $at_status, expected 0"
   10399       at_failed=:;;
   10400 esac
   10401 if $at_failed; then
   10402 
   10403   echo 1 > $at_status_file
   10404   exit 1
   10405 fi
   10406 
   10407 $at_traceon
   10408 
   10409 
   10410 # Check the contents of the report.
   10411 $at_traceoff
   10412 echo "conflicts.at:465: cat input.output"
   10413 echo conflicts.at:465 >$at_check_line_file
   10414 ( $at_traceon; cat input.output ) >$at_stdout 2>$at_stder1
   10415 at_status=$?
   10416 grep '^ *+' $at_stder1 >&2
   10417 grep -v '^ *+' $at_stder1 >$at_stderr
   10418 at_failed=false
   10419 $at_diff $at_devnull $at_stderr || at_failed=:
   10420 echo >>$at_stdout; echo "Rules never reduced
   10421 
   10422     4 id: '0'
   10423 
   10424 
   10425 State 1 conflicts: 1 reduce/reduce
   10426 
   10427 
   10428 Grammar
   10429 
   10430     0 \$accept: exp \$end
   10431 
   10432     1 exp: num
   10433     2    | id
   10434 
   10435     3 num: '0'
   10436 
   10437     4 id: '0'
   10438 
   10439 
   10440 Terminals, with rules where they appear
   10441 
   10442 \$end (0) 0
   10443 '0' (48) 3 4
   10444 error (256)
   10445 
   10446 
   10447 Nonterminals, with rules where they appear
   10448 
   10449 \$accept (4)
   10450     on left: 0
   10451 exp (5)
   10452     on left: 1 2, on right: 0
   10453 num (6)
   10454     on left: 3, on right: 1
   10455 id (7)
   10456     on left: 4, on right: 2
   10457 
   10458 
   10459 state 0
   10460 
   10461     0 \$accept: . exp \$end
   10462     1 exp: . num
   10463     2    | . id
   10464     3 num: . '0'
   10465     4 id: . '0'
   10466 
   10467     '0'  shift, and go to state 1
   10468 
   10469     exp  go to state 2
   10470     num  go to state 3
   10471     id   go to state 4
   10472 
   10473 
   10474 state 1
   10475 
   10476     3 num: '0' .  [\$end]
   10477     4 id: '0' .  [\$end]
   10478 
   10479     \$end      reduce using rule 3 (num)
   10480     \$end      [reduce using rule 4 (id)]
   10481     \$default  reduce using rule 3 (num)
   10482 
   10483 
   10484 state 2
   10485 
   10486     0 \$accept: exp . \$end
   10487 
   10488     \$end  shift, and go to state 5
   10489 
   10490 
   10491 state 3
   10492 
   10493     1 exp: num .
   10494 
   10495     \$default  reduce using rule 1 (exp)
   10496 
   10497 
   10498 state 4
   10499 
   10500     2 exp: id .
   10501 
   10502     \$default  reduce using rule 2 (exp)
   10503 
   10504 
   10505 state 5
   10506 
   10507     0 \$accept: exp \$end .
   10508 
   10509     \$default  accept
   10510 " | $at_diff - $at_stdout || at_failed=:
   10511 case $at_status in
   10512    77) echo 77 > $at_status_file
   10513             exit 77;;
   10514    0) ;;
   10515    *) echo "conflicts.at:465: exit code was $at_status, expected 0"
   10516       at_failed=:;;
   10517 esac
   10518 if $at_failed; then
   10519 
   10520   echo 1 > $at_status_file
   10521   exit 1
   10522 fi
   10523 
   10524 $at_traceon
   10525 
   10526 
   10527       $at_traceoff
   10528       $at_times_p && times >$at_times_file
   10529     ) 5>&1 2>&1 | eval $at_tee_pipe
   10530     at_status=`cat $at_status_file`
   10531     ;;
   10532 
   10533   63 ) # 63. conflicts.at:476: %expect not enough
   10534     at_setup_line='conflicts.at:476'
   10535     at_desc='%expect not enough'
   10536     $at_quiet $ECHO_N " 63: %expect not enough                           $ECHO_C"
   10537     at_xfail=no
   10538     (
   10539       echo "63. conflicts.at:476: testing ..."
   10540       $at_traceon
   10541 
   10542 
   10543 cat >input.y <<'_ATEOF'
   10544 %token NUM OP
   10545 %expect 0
   10546 %%
   10547 exp: exp OP exp | NUM;
   10548 _ATEOF
   10549 
   10550 
   10551 $at_traceoff
   10552 echo "conflicts.at:488: bison -o input.c input.y"
   10553 echo conflicts.at:488 >$at_check_line_file
   10554 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   10555 at_status=$?
   10556 grep '^ *+' $at_stder1 >&2
   10557 grep -v '^ *+' $at_stder1 >$at_stderr
   10558 at_failed=false
   10559 echo >>$at_stderr; echo "input.y: conflicts: 1 shift/reduce
   10560 input.y: expected 0 shift/reduce conflicts
   10561 " | $at_diff - $at_stderr || at_failed=:
   10562 $at_diff $at_devnull $at_stdout || at_failed=:
   10563 case $at_status in
   10564    77) echo 77 > $at_status_file
   10565             exit 77;;
   10566    1) ;;
   10567    *) echo "conflicts.at:488: exit code was $at_status, expected 1"
   10568       at_failed=:;;
   10569 esac
   10570 if $at_failed; then
   10571 
   10572   echo 1 > $at_status_file
   10573   exit 1
   10574 fi
   10575 
   10576 $at_traceon
   10577 
   10578       $at_traceoff
   10579       $at_times_p && times >$at_times_file
   10580     ) 5>&1 2>&1 | eval $at_tee_pipe
   10581     at_status=`cat $at_status_file`
   10582     ;;
   10583 
   10584   64 ) # 64. conflicts.at:496: %expect right
   10585     at_setup_line='conflicts.at:496'
   10586     at_desc='%expect right'
   10587     $at_quiet $ECHO_N " 64: %expect right                                $ECHO_C"
   10588     at_xfail=no
   10589     (
   10590       echo "64. conflicts.at:496: testing ..."
   10591       $at_traceon
   10592 
   10593 
   10594 cat >input.y <<'_ATEOF'
   10595 %token NUM OP
   10596 %expect 1
   10597 %%
   10598 exp: exp OP exp | NUM;
   10599 _ATEOF
   10600 
   10601 
   10602 $at_traceoff
   10603 echo "conflicts.at:505: bison -o input.c input.y"
   10604 echo conflicts.at:505 >$at_check_line_file
   10605 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   10606 at_status=$?
   10607 grep '^ *+' $at_stder1 >&2
   10608 grep -v '^ *+' $at_stder1 >$at_stderr
   10609 at_failed=false
   10610 $at_diff $at_devnull $at_stderr || at_failed=:
   10611 $at_diff $at_devnull $at_stdout || at_failed=:
   10612 case $at_status in
   10613    77) echo 77 > $at_status_file
   10614             exit 77;;
   10615    0) ;;
   10616    *) echo "conflicts.at:505: exit code was $at_status, expected 0"
   10617       at_failed=:;;
   10618 esac
   10619 if $at_failed; then
   10620 
   10621   echo 1 > $at_status_file
   10622   exit 1
   10623 fi
   10624 
   10625 $at_traceon
   10626 
   10627       $at_traceoff
   10628       $at_times_p && times >$at_times_file
   10629     ) 5>&1 2>&1 | eval $at_tee_pipe
   10630     at_status=`cat $at_status_file`
   10631     ;;
   10632 
   10633   65 ) # 65. conflicts.at:513: %expect too much
   10634     at_setup_line='conflicts.at:513'
   10635     at_desc='%expect too much'
   10636     $at_quiet $ECHO_N " 65: %expect too much                             $ECHO_C"
   10637     at_xfail=no
   10638     (
   10639       echo "65. conflicts.at:513: testing ..."
   10640       $at_traceon
   10641 
   10642 
   10643 cat >input.y <<'_ATEOF'
   10644 %token NUM OP
   10645 %expect 2
   10646 %%
   10647 exp: exp OP exp | NUM;
   10648 _ATEOF
   10649 
   10650 
   10651 $at_traceoff
   10652 echo "conflicts.at:525: bison -o input.c input.y"
   10653 echo conflicts.at:525 >$at_check_line_file
   10654 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   10655 at_status=$?
   10656 grep '^ *+' $at_stder1 >&2
   10657 grep -v '^ *+' $at_stder1 >$at_stderr
   10658 at_failed=false
   10659 echo >>$at_stderr; echo "input.y: conflicts: 1 shift/reduce
   10660 input.y: expected 2 shift/reduce conflicts
   10661 " | $at_diff - $at_stderr || at_failed=:
   10662 $at_diff $at_devnull $at_stdout || at_failed=:
   10663 case $at_status in
   10664    77) echo 77 > $at_status_file
   10665             exit 77;;
   10666    1) ;;
   10667    *) echo "conflicts.at:525: exit code was $at_status, expected 1"
   10668       at_failed=:;;
   10669 esac
   10670 if $at_failed; then
   10671 
   10672   echo 1 > $at_status_file
   10673   exit 1
   10674 fi
   10675 
   10676 $at_traceon
   10677 
   10678       $at_traceoff
   10679       $at_times_p && times >$at_times_file
   10680     ) 5>&1 2>&1 | eval $at_tee_pipe
   10681     at_status=`cat $at_status_file`
   10682     ;;
   10683 
   10684   66 ) # 66. conflicts.at:533: %expect with reduce conflicts
   10685     at_setup_line='conflicts.at:533'
   10686     at_desc='%expect with reduce conflicts'
   10687     $at_quiet $ECHO_N " 66: %expect with reduce conflicts                $ECHO_C"
   10688     at_xfail=no
   10689     (
   10690       echo "66. conflicts.at:533: testing ..."
   10691       $at_traceon
   10692 
   10693 
   10694 cat >input.y <<'_ATEOF'
   10695 %expect 0
   10696 %%
   10697 program: a 'a' | a a;
   10698 a: 'a';
   10699 _ATEOF
   10700 
   10701 
   10702 $at_traceoff
   10703 echo "conflicts.at:545: bison -o input.c input.y"
   10704 echo conflicts.at:545 >$at_check_line_file
   10705 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   10706 at_status=$?
   10707 grep '^ *+' $at_stder1 >&2
   10708 grep -v '^ *+' $at_stder1 >$at_stderr
   10709 at_failed=false
   10710 echo >>$at_stderr; echo "input.y: conflicts: 1 reduce/reduce
   10711 input.y: expected 0 reduce/reduce conflicts
   10712 " | $at_diff - $at_stderr || at_failed=:
   10713 $at_diff $at_devnull $at_stdout || at_failed=:
   10714 case $at_status in
   10715    77) echo 77 > $at_status_file
   10716             exit 77;;
   10717    1) ;;
   10718    *) echo "conflicts.at:545: exit code was $at_status, expected 1"
   10719       at_failed=:;;
   10720 esac
   10721 if $at_failed; then
   10722 
   10723   echo 1 > $at_status_file
   10724   exit 1
   10725 fi
   10726 
   10727 $at_traceon
   10728 
   10729       $at_traceoff
   10730       $at_times_p && times >$at_times_file
   10731     ) 5>&1 2>&1 | eval $at_tee_pipe
   10732     at_status=`cat $at_status_file`
   10733     ;;
   10734 
   10735   67 ) # 67. conflicts.at:553: %no-default-prec without %prec
   10736     at_setup_line='conflicts.at:553'
   10737     at_desc='%no-default-prec without %prec'
   10738     $at_quiet $ECHO_N " 67: %no-default-prec without %prec               $ECHO_C"
   10739     at_xfail=no
   10740     (
   10741       echo "67. conflicts.at:553: testing ..."
   10742       $at_traceon
   10743 
   10744 
   10745 cat >input.y <<'_ATEOF'
   10746 %left '+'
   10747 %left '*'
   10748 
   10749 %%
   10750 
   10751 %no-default-prec;
   10752 
   10753 e:   e '+' e
   10754    | e '*' e
   10755    | '0'
   10756    ;
   10757 _ATEOF
   10758 
   10759 
   10760 $at_traceoff
   10761 echo "conflicts.at:571: bison -o input.c input.y"
   10762 echo conflicts.at:571 >$at_check_line_file
   10763 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   10764 at_status=$?
   10765 grep '^ *+' $at_stder1 >&2
   10766 grep -v '^ *+' $at_stder1 >$at_stderr
   10767 at_failed=false
   10768 echo >>$at_stderr; echo "input.y: conflicts: 4 shift/reduce
   10769 " | $at_diff - $at_stderr || at_failed=:
   10770 $at_diff $at_devnull $at_stdout || at_failed=:
   10771 case $at_status in
   10772    77) echo 77 > $at_status_file
   10773             exit 77;;
   10774    0) ;;
   10775    *) echo "conflicts.at:571: exit code was $at_status, expected 0"
   10776       at_failed=:;;
   10777 esac
   10778 if $at_failed; then
   10779 
   10780   echo 1 > $at_status_file
   10781   exit 1
   10782 fi
   10783 
   10784 $at_traceon
   10785 
   10786       $at_traceoff
   10787       $at_times_p && times >$at_times_file
   10788     ) 5>&1 2>&1 | eval $at_tee_pipe
   10789     at_status=`cat $at_status_file`
   10790     ;;
   10791 
   10792   68 ) # 68. conflicts.at:579: %no-default-prec with %prec
   10793     at_setup_line='conflicts.at:579'
   10794     at_desc='%no-default-prec with %prec'
   10795     $at_quiet $ECHO_N " 68: %no-default-prec with %prec                  $ECHO_C"
   10796     at_xfail=no
   10797     (
   10798       echo "68. conflicts.at:579: testing ..."
   10799       $at_traceon
   10800 
   10801 
   10802 cat >input.y <<'_ATEOF'
   10803 %left '+'
   10804 %left '*'
   10805 
   10806 %%
   10807 
   10808 %no-default-prec;
   10809 
   10810 e:   e '+' e %prec '+'
   10811    | e '*' e %prec '*'
   10812    | '0'
   10813    ;
   10814 _ATEOF
   10815 
   10816 
   10817 $at_traceoff
   10818 echo "conflicts.at:595: bison -o input.c input.y"
   10819 echo conflicts.at:595 >$at_check_line_file
   10820 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   10821 at_status=$?
   10822 grep '^ *+' $at_stder1 >&2
   10823 grep -v '^ *+' $at_stder1 >$at_stderr
   10824 at_failed=false
   10825 $at_diff $at_devnull $at_stderr || at_failed=:
   10826 $at_diff $at_devnull $at_stdout || at_failed=:
   10827 case $at_status in
   10828    77) echo 77 > $at_status_file
   10829             exit 77;;
   10830    0) ;;
   10831    *) echo "conflicts.at:595: exit code was $at_status, expected 0"
   10832       at_failed=:;;
   10833 esac
   10834 if $at_failed; then
   10835 
   10836   echo 1 > $at_status_file
   10837   exit 1
   10838 fi
   10839 
   10840 $at_traceon
   10841 
   10842       $at_traceoff
   10843       $at_times_p && times >$at_times_file
   10844     ) 5>&1 2>&1 | eval $at_tee_pipe
   10845     at_status=`cat $at_status_file`
   10846     ;;
   10847 
   10848   69 ) # 69. conflicts.at:603: %default-prec
   10849     at_setup_line='conflicts.at:603'
   10850     at_desc='%default-prec'
   10851     $at_quiet $ECHO_N " 69: %default-prec                                $ECHO_C"
   10852     at_xfail=no
   10853     (
   10854       echo "69. conflicts.at:603: testing ..."
   10855       $at_traceon
   10856 
   10857 
   10858 cat >input.y <<'_ATEOF'
   10859 %left '+'
   10860 %left '*'
   10861 
   10862 %%
   10863 
   10864 %default-prec;
   10865 
   10866 e:   e '+' e
   10867    | e '*' e
   10868    | '0'
   10869    ;
   10870 _ATEOF
   10871 
   10872 
   10873 $at_traceoff
   10874 echo "conflicts.at:619: bison -o input.c input.y"
   10875 echo conflicts.at:619 >$at_check_line_file
   10876 ( $at_traceon; bison -o input.c input.y ) >$at_stdout 2>$at_stder1
   10877 at_status=$?
   10878 grep '^ *+' $at_stder1 >&2
   10879 grep -v '^ *+' $at_stder1 >$at_stderr
   10880 at_failed=false
   10881 $at_diff $at_devnull $at_stderr || at_failed=:
   10882 $at_diff $at_devnull $at_stdout || at_failed=:
   10883 case $at_status in
   10884    77) echo 77 > $at_status_file
   10885             exit 77;;
   10886    0) ;;
   10887    *) echo "conflicts.at:619: exit code was $at_status, expected 0"
   10888       at_failed=:;;
   10889 esac
   10890 if $at_failed; then
   10891 
   10892   echo 1 > $at_status_file
   10893   exit 1
   10894 fi
   10895 
   10896 $at_traceon
   10897 
   10898       $at_traceoff
   10899       $at_times_p && times >$at_times_file
   10900     ) 5>&1 2>&1 | eval $at_tee_pipe
   10901     at_status=`cat $at_status_file`
   10902     ;;
   10903 
   10904 
   10905   banner-9 ) # Banner 9. calc.at:541
   10906     cat <<\_ATEOF
   10907 
   10908 Simple LALR(1) Calculator.
   10909 
   10910 _ATEOF
   10911     ;;
   10912 
   10913   70 ) # 70. calc.at:550: Calculator
   10914     at_setup_line='calc.at:550'
   10915     at_desc='Calculator '
   10916     $at_quiet $ECHO_N " 70: Calculator                                   $ECHO_C"
   10917     at_xfail=no
   10918     (
   10919       echo "70. calc.at:550: testing ..."
   10920       $at_traceon
   10921 
   10922 
   10923 
   10924 
   10925 
   10926 
   10927 
   10928 
   10929 # Using yacc.c?
   10930 
   10931 
   10932 
   10933 
   10934 
   10935 
   10936 
   10937 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   10938 
   10939 # yyerror always sees the locations (when activated), except if
   10940 # yacc & pure & !param.
   10941 
   10942 
   10943 # The interface is pure: either because %pure-parser, or because we
   10944 # are using the C++ parsers.
   10945 
   10946 
   10947 
   10948 
   10949 
   10950 
   10951 
   10952 
   10953 
   10954 
   10955 
   10956 
   10957 cat >calc.y <<'_ATEOF'
   10958 %{
   10959 #ifdef HAVE_CONFIG_H
   10960 # include <config.h>
   10961   /* We don't need perfect functions for these tests. */
   10962 # undef malloc
   10963 # undef memcmp
   10964 # undef realloc
   10965 #endif
   10966 %}
   10967 
   10968 /* Infix notation calculator--calc */
   10969 
   10970 
   10971 %{
   10972 #include <stdio.h>
   10973 
   10974 #include <stdlib.h>
   10975 #include <string.h>
   10976 #if HAVE_UNISTD_H
   10977 # include <unistd.h>
   10978 #else
   10979 # undef alarm
   10980 # define alarm(seconds) /* empty */
   10981 #endif
   10982 #include <ctype.h>
   10983 #define USE(Var)
   10984 
   10985 /* Exercise pre-prologue dependency to %union.  */
   10986 typedef int semantic_value;
   10987 
   10988 static semantic_value global_result = 0;
   10989 static int global_count = 0;
   10990 %}
   10991 
   10992 /* Exercise %union. */
   10993 %union
   10994 {
   10995   semantic_value ival;
   10996 };
   10997 
   10998 %{
   10999 static int power (int base, int exponent);
   11000 /* yyerror receives the location if:
   11001    - %location & %pure & %glr
   11002    - %location & %pure & %yacc & %parse-param. */
   11003 static void yyerror (
   11004 
   11005                      const char *s
   11006                      );
   11007 static int yylex (void);
   11008 static int get_char (void);
   11009 static void unget_char ( int c);
   11010 %}
   11011 
   11012 
   11013 
   11014 /* Bison Declarations */
   11015 %token CALC_EOF 0 "end of input"
   11016 %token <ival> NUM "number"
   11017 %type  <ival> exp
   11018 
   11019 %nonassoc '=' /* comparison	       */
   11020 %left '-' '+'
   11021 %left '*' '/'
   11022 %left NEG     /* negation--unary minus */
   11023 %right '^'    /* exponentiation        */
   11024 
   11025 /* Grammar follows */
   11026 %%
   11027 input:
   11028   line
   11029 | input line         {  }
   11030 ;
   11031 
   11032 line:
   11033   '\n'
   11034 | exp '\n'           { USE ($1); }
   11035 ;
   11036 
   11037 exp:
   11038   NUM                { $$ = $1;             }
   11039 | exp '=' exp
   11040   {
   11041     if ($1 != $3)
   11042       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   11043     $$ = $1;
   11044   }
   11045 | exp '+' exp        { $$ = $1 + $3;        }
   11046 | exp '-' exp        { $$ = $1 - $3;        }
   11047 | exp '*' exp        { $$ = $1 * $3;        }
   11048 | exp '/' exp        { $$ = $1 / $3;        }
   11049 | '-' exp  %prec NEG { $$ = -$2;            }
   11050 | exp '^' exp        { $$ = power ($1, $3); }
   11051 | '(' exp ')'        { $$ = $2;             }
   11052 | '(' error ')'      { $$ = 1111;           }
   11053 | '!'                { $$ = 0; YYERROR;     }
   11054 | '-' error          { $$ = 0; YYERROR;     }
   11055 ;
   11056 %%
   11057 /* The input.  */
   11058 static FILE *input;
   11059 
   11060 static void
   11061 yyerror (
   11062 
   11063          const char *s)
   11064 {
   11065 
   11066 
   11067   fprintf (stderr, "%s\n", s);
   11068 }
   11069 
   11070 
   11071 
   11072 static int
   11073 get_char (void)
   11074 {
   11075   int res = getc (input);
   11076   ;
   11077 
   11078   return res;
   11079 }
   11080 
   11081 
   11082 static void
   11083 unget_char ( int c)
   11084 {
   11085   ;
   11086 
   11087   ungetc (c, input);
   11088 }
   11089 
   11090 static int
   11091 read_signed_integer (void)
   11092 {
   11093   int c = get_char ();
   11094   int sign = 1;
   11095   int n = 0;
   11096 
   11097   ;
   11098   if (c == '-')
   11099     {
   11100       c = get_char ();
   11101       sign = -1;
   11102     }
   11103 
   11104   while (isdigit (c))
   11105     {
   11106       n = 10 * n + (c - '0');
   11107       c = get_char ();
   11108     }
   11109 
   11110   unget_char ( c);
   11111 
   11112   return sign * n;
   11113 }
   11114 
   11115 
   11116 
   11117 /*---------------------------------------------------------------.
   11118 | Lexical analyzer returns an integer on the stack and the token |
   11119 | NUM, or the ASCII character read if not a number.  Skips all   |
   11120 | blanks and tabs, returns 0 for EOF.                            |
   11121 `---------------------------------------------------------------*/
   11122 
   11123 static int
   11124 yylex (void)
   11125 {
   11126   static int init = 1;
   11127   int c;
   11128 
   11129   if (init)
   11130     {
   11131       init = 0;
   11132 
   11133     }
   11134 
   11135 
   11136 
   11137   /* Skip white space.  */
   11138   while ((c = get_char ()) == ' ' || c == '\t')
   11139     {
   11140 
   11141     }
   11142 
   11143   /* process numbers   */
   11144   if (c == '.' || isdigit (c))
   11145     {
   11146       unget_char ( c);
   11147       (yylval).ival = read_signed_integer ();
   11148       return NUM;
   11149     }
   11150 
   11151   /* Return end-of-file.  */
   11152   if (c == EOF)
   11153     return CALC_EOF;
   11154 
   11155   /* Return single chars. */
   11156   return c;
   11157 }
   11158 
   11159 static int
   11160 power (int base, int exponent)
   11161 {
   11162   int res = 1;
   11163   if (exponent < 0)
   11164     exit (3);
   11165   for (/* Niente */; exponent; --exponent)
   11166     res *= base;
   11167   return res;
   11168 }
   11169 
   11170 
   11171 int
   11172 main (int argc, const char **argv)
   11173 {
   11174   semantic_value result = 0;
   11175   int count = 0;
   11176   int status;
   11177 
   11178   /* This used to be alarm (10), but that isn't enough time for
   11179      a July 1995 vintage DEC Alphastation 200 4/100 system,
   11180      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   11181   alarm (100);
   11182 
   11183   if (argc == 2)
   11184     input = fopen (argv[1], "r");
   11185   else
   11186     input = stdin;
   11187 
   11188   if (!input)
   11189     {
   11190       perror (argv[1]);
   11191       return 3;
   11192     }
   11193 
   11194 
   11195   status = yyparse ();
   11196   if (global_result != result)
   11197     abort ();
   11198   if (global_count != count)
   11199     abort ();
   11200   return status;
   11201 }
   11202 _ATEOF
   11203 
   11204 
   11205 
   11206 
   11207 
   11208 $at_traceoff
   11209 echo "calc.at:550: bison -o calc.c calc.y"
   11210 echo calc.at:550 >$at_check_line_file
   11211 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   11212 at_status=$?
   11213 grep '^ *+' $at_stder1 >&2
   11214 grep -v '^ *+' $at_stder1 >$at_stderr
   11215 at_failed=false
   11216 $at_diff $at_devnull $at_stderr || at_failed=:
   11217 $at_diff $at_devnull $at_stdout || at_failed=:
   11218 case $at_status in
   11219    77) echo 77 > $at_status_file
   11220             exit 77;;
   11221    0) ;;
   11222    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11223       at_failed=:;;
   11224 esac
   11225 if $at_failed; then
   11226 
   11227   echo 1 > $at_status_file
   11228   exit 1
   11229 fi
   11230 
   11231 $at_traceon
   11232 
   11233    $at_traceoff
   11234 echo "calc.at:550: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   11235 echo calc.at:550 >$at_check_line_file
   11236 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   11237 at_status=$?
   11238 grep '^ *+' $at_stder1 >&2
   11239 grep -v '^ *+' $at_stder1 >$at_stderr
   11240 at_failed=false
   11241 echo stderr:; cat $at_stderr
   11242 echo stdout:; cat $at_stdout
   11243 case $at_status in
   11244    77) echo 77 > $at_status_file
   11245             exit 77;;
   11246    0) ;;
   11247    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11248       at_failed=:;;
   11249 esac
   11250 if $at_failed; then
   11251 
   11252   echo 1 > $at_status_file
   11253   exit 1
   11254 fi
   11255 
   11256 $at_traceon
   11257 
   11258 
   11259 # Test the priorities.
   11260 cat >input <<'_ATEOF'
   11261 1 + 2 * 3 = 7
   11262 1 + 2 * -3 = -5
   11263 
   11264 -1^2 = -1
   11265 (-1)^2 = 1
   11266 
   11267 ---1 = -1
   11268 
   11269 1 - 2 - 3 = -4
   11270 1 - (2 - 3) = 2
   11271 
   11272 2^2^3 = 256
   11273 (2^2)^3 = 64
   11274 _ATEOF
   11275 
   11276 $at_traceoff
   11277 echo "calc.at:550: \$PREPARSER ./calc input"
   11278 echo calc.at:550 >$at_check_line_file
   11279 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   11280 at_status=$?
   11281 grep '^ *+' $at_stder1 >&2
   11282 grep -v '^ *+' $at_stder1 >$at_stderr
   11283 at_failed=false
   11284 echo stderr:; tee stderr <$at_stderr
   11285 $at_diff $at_devnull $at_stdout || at_failed=:
   11286 case $at_status in
   11287    77) echo 77 > $at_status_file
   11288             exit 77;;
   11289    0) ;;
   11290    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11291       at_failed=:;;
   11292 esac
   11293 if $at_failed; then
   11294 
   11295   echo 1 > $at_status_file
   11296   exit 1
   11297 fi
   11298 
   11299 $at_traceon
   11300 
   11301 
   11302 
   11303 # Some syntax errors.
   11304 cat >input <<'_ATEOF'
   11305 0 0
   11306 _ATEOF
   11307 
   11308 $at_traceoff
   11309 echo "calc.at:550: \$PREPARSER ./calc input"
   11310 echo calc.at:550 >$at_check_line_file
   11311 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   11312 at_status=$?
   11313 grep '^ *+' $at_stder1 >&2
   11314 grep -v '^ *+' $at_stder1 >$at_stderr
   11315 at_failed=false
   11316 echo stderr:; tee stderr <$at_stderr
   11317 $at_diff $at_devnull $at_stdout || at_failed=:
   11318 case $at_status in
   11319    77) echo 77 > $at_status_file
   11320             exit 77;;
   11321    1) ;;
   11322    *) echo "calc.at:550: exit code was $at_status, expected 1"
   11323       at_failed=:;;
   11324 esac
   11325 if $at_failed; then
   11326 
   11327   echo 1 > $at_status_file
   11328   exit 1
   11329 fi
   11330 
   11331 $at_traceon
   11332 
   11333 
   11334 # Normalize the observed and expected error messages, depending upon the
   11335 # options.
   11336 # 1. Remove the traces from observed.
   11337 sed '/^Starting/d
   11338 /^Entering/d
   11339 /^Stack/d
   11340 /^Reading/d
   11341 /^Reducing/d
   11342 /^Shifting/d
   11343 /^state/d
   11344 /^Cleanup:/d
   11345 /^Error:/d
   11346 /^Next/d
   11347 /^Discarding/d
   11348 / \$[0-9$]* = /d
   11349 /^yydestructor:/d' stderr >at-stderr
   11350 mv at-stderr stderr
   11351 # 2. Create the reference error message.
   11352 cat >expout <<'_ATEOF'
   11353 1.2: syntax error, unexpected number
   11354 _ATEOF
   11355 
   11356 # 3. If locations are not used, remove them.
   11357 sed 's/^[-0-9.]*: //' expout >at-expout
   11358 mv at-expout expout
   11359 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   11360 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   11361 mv at-expout expout
   11362 # 5. Check
   11363 $at_traceoff
   11364 echo "calc.at:550: cat stderr"
   11365 echo calc.at:550 >$at_check_line_file
   11366 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   11367 at_status=$?
   11368 grep '^ *+' $at_stder1 >&2
   11369 grep -v '^ *+' $at_stder1 >$at_stderr
   11370 at_failed=false
   11371 $at_diff $at_devnull $at_stderr || at_failed=:
   11372 $at_diff expout $at_stdout || at_failed=:
   11373 case $at_status in
   11374    77) echo 77 > $at_status_file
   11375             exit 77;;
   11376    0) ;;
   11377    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11378       at_failed=:;;
   11379 esac
   11380 if $at_failed; then
   11381 
   11382   echo 1 > $at_status_file
   11383   exit 1
   11384 fi
   11385 
   11386 $at_traceon
   11387 
   11388 
   11389 cat >input <<'_ATEOF'
   11390 1//2
   11391 _ATEOF
   11392 
   11393 $at_traceoff
   11394 echo "calc.at:550: \$PREPARSER ./calc input"
   11395 echo calc.at:550 >$at_check_line_file
   11396 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   11397 at_status=$?
   11398 grep '^ *+' $at_stder1 >&2
   11399 grep -v '^ *+' $at_stder1 >$at_stderr
   11400 at_failed=false
   11401 echo stderr:; tee stderr <$at_stderr
   11402 $at_diff $at_devnull $at_stdout || at_failed=:
   11403 case $at_status in
   11404    77) echo 77 > $at_status_file
   11405             exit 77;;
   11406    1) ;;
   11407    *) echo "calc.at:550: exit code was $at_status, expected 1"
   11408       at_failed=:;;
   11409 esac
   11410 if $at_failed; then
   11411 
   11412   echo 1 > $at_status_file
   11413   exit 1
   11414 fi
   11415 
   11416 $at_traceon
   11417 
   11418 
   11419 # Normalize the observed and expected error messages, depending upon the
   11420 # options.
   11421 # 1. Remove the traces from observed.
   11422 sed '/^Starting/d
   11423 /^Entering/d
   11424 /^Stack/d
   11425 /^Reading/d
   11426 /^Reducing/d
   11427 /^Shifting/d
   11428 /^state/d
   11429 /^Cleanup:/d
   11430 /^Error:/d
   11431 /^Next/d
   11432 /^Discarding/d
   11433 / \$[0-9$]* = /d
   11434 /^yydestructor:/d' stderr >at-stderr
   11435 mv at-stderr stderr
   11436 # 2. Create the reference error message.
   11437 cat >expout <<'_ATEOF'
   11438 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   11439 _ATEOF
   11440 
   11441 # 3. If locations are not used, remove them.
   11442 sed 's/^[-0-9.]*: //' expout >at-expout
   11443 mv at-expout expout
   11444 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   11445 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   11446 mv at-expout expout
   11447 # 5. Check
   11448 $at_traceoff
   11449 echo "calc.at:550: cat stderr"
   11450 echo calc.at:550 >$at_check_line_file
   11451 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   11452 at_status=$?
   11453 grep '^ *+' $at_stder1 >&2
   11454 grep -v '^ *+' $at_stder1 >$at_stderr
   11455 at_failed=false
   11456 $at_diff $at_devnull $at_stderr || at_failed=:
   11457 $at_diff expout $at_stdout || at_failed=:
   11458 case $at_status in
   11459    77) echo 77 > $at_status_file
   11460             exit 77;;
   11461    0) ;;
   11462    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11463       at_failed=:;;
   11464 esac
   11465 if $at_failed; then
   11466 
   11467   echo 1 > $at_status_file
   11468   exit 1
   11469 fi
   11470 
   11471 $at_traceon
   11472 
   11473 
   11474 cat >input <<'_ATEOF'
   11475 error
   11476 _ATEOF
   11477 
   11478 $at_traceoff
   11479 echo "calc.at:550: \$PREPARSER ./calc input"
   11480 echo calc.at:550 >$at_check_line_file
   11481 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   11482 at_status=$?
   11483 grep '^ *+' $at_stder1 >&2
   11484 grep -v '^ *+' $at_stder1 >$at_stderr
   11485 at_failed=false
   11486 echo stderr:; tee stderr <$at_stderr
   11487 $at_diff $at_devnull $at_stdout || at_failed=:
   11488 case $at_status in
   11489    77) echo 77 > $at_status_file
   11490             exit 77;;
   11491    1) ;;
   11492    *) echo "calc.at:550: exit code was $at_status, expected 1"
   11493       at_failed=:;;
   11494 esac
   11495 if $at_failed; then
   11496 
   11497   echo 1 > $at_status_file
   11498   exit 1
   11499 fi
   11500 
   11501 $at_traceon
   11502 
   11503 
   11504 # Normalize the observed and expected error messages, depending upon the
   11505 # options.
   11506 # 1. Remove the traces from observed.
   11507 sed '/^Starting/d
   11508 /^Entering/d
   11509 /^Stack/d
   11510 /^Reading/d
   11511 /^Reducing/d
   11512 /^Shifting/d
   11513 /^state/d
   11514 /^Cleanup:/d
   11515 /^Error:/d
   11516 /^Next/d
   11517 /^Discarding/d
   11518 / \$[0-9$]* = /d
   11519 /^yydestructor:/d' stderr >at-stderr
   11520 mv at-stderr stderr
   11521 # 2. Create the reference error message.
   11522 cat >expout <<'_ATEOF'
   11523 1.0: syntax error, unexpected $undefined
   11524 _ATEOF
   11525 
   11526 # 3. If locations are not used, remove them.
   11527 sed 's/^[-0-9.]*: //' expout >at-expout
   11528 mv at-expout expout
   11529 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   11530 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   11531 mv at-expout expout
   11532 # 5. Check
   11533 $at_traceoff
   11534 echo "calc.at:550: cat stderr"
   11535 echo calc.at:550 >$at_check_line_file
   11536 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   11537 at_status=$?
   11538 grep '^ *+' $at_stder1 >&2
   11539 grep -v '^ *+' $at_stder1 >$at_stderr
   11540 at_failed=false
   11541 $at_diff $at_devnull $at_stderr || at_failed=:
   11542 $at_diff expout $at_stdout || at_failed=:
   11543 case $at_status in
   11544    77) echo 77 > $at_status_file
   11545             exit 77;;
   11546    0) ;;
   11547    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11548       at_failed=:;;
   11549 esac
   11550 if $at_failed; then
   11551 
   11552   echo 1 > $at_status_file
   11553   exit 1
   11554 fi
   11555 
   11556 $at_traceon
   11557 
   11558 
   11559 cat >input <<'_ATEOF'
   11560 1 = 2 = 3
   11561 _ATEOF
   11562 
   11563 $at_traceoff
   11564 echo "calc.at:550: \$PREPARSER ./calc input"
   11565 echo calc.at:550 >$at_check_line_file
   11566 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   11567 at_status=$?
   11568 grep '^ *+' $at_stder1 >&2
   11569 grep -v '^ *+' $at_stder1 >$at_stderr
   11570 at_failed=false
   11571 echo stderr:; tee stderr <$at_stderr
   11572 $at_diff $at_devnull $at_stdout || at_failed=:
   11573 case $at_status in
   11574    77) echo 77 > $at_status_file
   11575             exit 77;;
   11576    1) ;;
   11577    *) echo "calc.at:550: exit code was $at_status, expected 1"
   11578       at_failed=:;;
   11579 esac
   11580 if $at_failed; then
   11581 
   11582   echo 1 > $at_status_file
   11583   exit 1
   11584 fi
   11585 
   11586 $at_traceon
   11587 
   11588 
   11589 # Normalize the observed and expected error messages, depending upon the
   11590 # options.
   11591 # 1. Remove the traces from observed.
   11592 sed '/^Starting/d
   11593 /^Entering/d
   11594 /^Stack/d
   11595 /^Reading/d
   11596 /^Reducing/d
   11597 /^Shifting/d
   11598 /^state/d
   11599 /^Cleanup:/d
   11600 /^Error:/d
   11601 /^Next/d
   11602 /^Discarding/d
   11603 / \$[0-9$]* = /d
   11604 /^yydestructor:/d' stderr >at-stderr
   11605 mv at-stderr stderr
   11606 # 2. Create the reference error message.
   11607 cat >expout <<'_ATEOF'
   11608 1.6: syntax error, unexpected '='
   11609 _ATEOF
   11610 
   11611 # 3. If locations are not used, remove them.
   11612 sed 's/^[-0-9.]*: //' expout >at-expout
   11613 mv at-expout expout
   11614 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   11615 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   11616 mv at-expout expout
   11617 # 5. Check
   11618 $at_traceoff
   11619 echo "calc.at:550: cat stderr"
   11620 echo calc.at:550 >$at_check_line_file
   11621 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   11622 at_status=$?
   11623 grep '^ *+' $at_stder1 >&2
   11624 grep -v '^ *+' $at_stder1 >$at_stderr
   11625 at_failed=false
   11626 $at_diff $at_devnull $at_stderr || at_failed=:
   11627 $at_diff expout $at_stdout || at_failed=:
   11628 case $at_status in
   11629    77) echo 77 > $at_status_file
   11630             exit 77;;
   11631    0) ;;
   11632    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11633       at_failed=:;;
   11634 esac
   11635 if $at_failed; then
   11636 
   11637   echo 1 > $at_status_file
   11638   exit 1
   11639 fi
   11640 
   11641 $at_traceon
   11642 
   11643 
   11644 cat >input <<'_ATEOF'
   11645 
   11646 +1
   11647 _ATEOF
   11648 
   11649 $at_traceoff
   11650 echo "calc.at:550: \$PREPARSER ./calc input"
   11651 echo calc.at:550 >$at_check_line_file
   11652 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   11653 at_status=$?
   11654 grep '^ *+' $at_stder1 >&2
   11655 grep -v '^ *+' $at_stder1 >$at_stderr
   11656 at_failed=false
   11657 echo stderr:; tee stderr <$at_stderr
   11658 $at_diff $at_devnull $at_stdout || at_failed=:
   11659 case $at_status in
   11660    77) echo 77 > $at_status_file
   11661             exit 77;;
   11662    1) ;;
   11663    *) echo "calc.at:550: exit code was $at_status, expected 1"
   11664       at_failed=:;;
   11665 esac
   11666 if $at_failed; then
   11667 
   11668   echo 1 > $at_status_file
   11669   exit 1
   11670 fi
   11671 
   11672 $at_traceon
   11673 
   11674 
   11675 # Normalize the observed and expected error messages, depending upon the
   11676 # options.
   11677 # 1. Remove the traces from observed.
   11678 sed '/^Starting/d
   11679 /^Entering/d
   11680 /^Stack/d
   11681 /^Reading/d
   11682 /^Reducing/d
   11683 /^Shifting/d
   11684 /^state/d
   11685 /^Cleanup:/d
   11686 /^Error:/d
   11687 /^Next/d
   11688 /^Discarding/d
   11689 / \$[0-9$]* = /d
   11690 /^yydestructor:/d' stderr >at-stderr
   11691 mv at-stderr stderr
   11692 # 2. Create the reference error message.
   11693 cat >expout <<'_ATEOF'
   11694 2.0: syntax error, unexpected '+'
   11695 _ATEOF
   11696 
   11697 # 3. If locations are not used, remove them.
   11698 sed 's/^[-0-9.]*: //' expout >at-expout
   11699 mv at-expout expout
   11700 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   11701 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   11702 mv at-expout expout
   11703 # 5. Check
   11704 $at_traceoff
   11705 echo "calc.at:550: cat stderr"
   11706 echo calc.at:550 >$at_check_line_file
   11707 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   11708 at_status=$?
   11709 grep '^ *+' $at_stder1 >&2
   11710 grep -v '^ *+' $at_stder1 >$at_stderr
   11711 at_failed=false
   11712 $at_diff $at_devnull $at_stderr || at_failed=:
   11713 $at_diff expout $at_stdout || at_failed=:
   11714 case $at_status in
   11715    77) echo 77 > $at_status_file
   11716             exit 77;;
   11717    0) ;;
   11718    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11719       at_failed=:;;
   11720 esac
   11721 if $at_failed; then
   11722 
   11723   echo 1 > $at_status_file
   11724   exit 1
   11725 fi
   11726 
   11727 $at_traceon
   11728 
   11729 
   11730 # Exercise error messages with EOF: work on an empty file.
   11731 $at_traceoff
   11732 echo "calc.at:550: \$PREPARSER ./calc /dev/null"
   11733 echo calc.at:550 >$at_check_line_file
   11734 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   11735 at_status=$?
   11736 grep '^ *+' $at_stder1 >&2
   11737 grep -v '^ *+' $at_stder1 >$at_stderr
   11738 at_failed=false
   11739 echo stderr:; tee stderr <$at_stderr
   11740 $at_diff $at_devnull $at_stdout || at_failed=:
   11741 case $at_status in
   11742    77) echo 77 > $at_status_file
   11743             exit 77;;
   11744    1) ;;
   11745    *) echo "calc.at:550: exit code was $at_status, expected 1"
   11746       at_failed=:;;
   11747 esac
   11748 if $at_failed; then
   11749 
   11750   echo 1 > $at_status_file
   11751   exit 1
   11752 fi
   11753 
   11754 $at_traceon
   11755 
   11756 
   11757 # Normalize the observed and expected error messages, depending upon the
   11758 # options.
   11759 # 1. Remove the traces from observed.
   11760 sed '/^Starting/d
   11761 /^Entering/d
   11762 /^Stack/d
   11763 /^Reading/d
   11764 /^Reducing/d
   11765 /^Shifting/d
   11766 /^state/d
   11767 /^Cleanup:/d
   11768 /^Error:/d
   11769 /^Next/d
   11770 /^Discarding/d
   11771 / \$[0-9$]* = /d
   11772 /^yydestructor:/d' stderr >at-stderr
   11773 mv at-stderr stderr
   11774 # 2. Create the reference error message.
   11775 cat >expout <<'_ATEOF'
   11776 1.0: syntax error, unexpected end of input
   11777 _ATEOF
   11778 
   11779 # 3. If locations are not used, remove them.
   11780 sed 's/^[-0-9.]*: //' expout >at-expout
   11781 mv at-expout expout
   11782 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   11783 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   11784 mv at-expout expout
   11785 # 5. Check
   11786 $at_traceoff
   11787 echo "calc.at:550: cat stderr"
   11788 echo calc.at:550 >$at_check_line_file
   11789 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   11790 at_status=$?
   11791 grep '^ *+' $at_stder1 >&2
   11792 grep -v '^ *+' $at_stder1 >$at_stderr
   11793 at_failed=false
   11794 $at_diff $at_devnull $at_stderr || at_failed=:
   11795 $at_diff expout $at_stdout || at_failed=:
   11796 case $at_status in
   11797    77) echo 77 > $at_status_file
   11798             exit 77;;
   11799    0) ;;
   11800    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11801       at_failed=:;;
   11802 esac
   11803 if $at_failed; then
   11804 
   11805   echo 1 > $at_status_file
   11806   exit 1
   11807 fi
   11808 
   11809 $at_traceon
   11810 
   11811 
   11812 
   11813 # Exercise the error token: without it, we die at the first error,
   11814 # hence be sure to
   11815 #
   11816 # - have several errors which exercise different shift/discardings
   11817 #   - (): nothing to pop, nothing to discard
   11818 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   11819 #   - (* * *): nothing to pop, a lot to discard
   11820 #   - (1 + 2 * *): some to pop and discard
   11821 #
   11822 # - test the action associated to `error'
   11823 #
   11824 # - check the look-ahead that triggers an error is not discarded
   11825 #   when we enter error recovery.  Below, the look-ahead causing the
   11826 #   first error is ")", which is needed to recover from the error and
   11827 #   produce the "0" that triggers the "0 != 1" error.
   11828 #
   11829 cat >input <<'_ATEOF'
   11830 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   11831 _ATEOF
   11832 
   11833 $at_traceoff
   11834 echo "calc.at:550: \$PREPARSER ./calc input"
   11835 echo calc.at:550 >$at_check_line_file
   11836 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   11837 at_status=$?
   11838 grep '^ *+' $at_stder1 >&2
   11839 grep -v '^ *+' $at_stder1 >$at_stderr
   11840 at_failed=false
   11841 echo stderr:; tee stderr <$at_stderr
   11842 $at_diff $at_devnull $at_stdout || at_failed=:
   11843 case $at_status in
   11844    77) echo 77 > $at_status_file
   11845             exit 77;;
   11846    0) ;;
   11847    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11848       at_failed=:;;
   11849 esac
   11850 if $at_failed; then
   11851 
   11852   echo 1 > $at_status_file
   11853   exit 1
   11854 fi
   11855 
   11856 $at_traceon
   11857 
   11858 
   11859 # Normalize the observed and expected error messages, depending upon the
   11860 # options.
   11861 # 1. Remove the traces from observed.
   11862 sed '/^Starting/d
   11863 /^Entering/d
   11864 /^Stack/d
   11865 /^Reading/d
   11866 /^Reducing/d
   11867 /^Shifting/d
   11868 /^state/d
   11869 /^Cleanup:/d
   11870 /^Error:/d
   11871 /^Next/d
   11872 /^Discarding/d
   11873 / \$[0-9$]* = /d
   11874 /^yydestructor:/d' stderr >at-stderr
   11875 mv at-stderr stderr
   11876 # 2. Create the reference error message.
   11877 cat >expout <<'_ATEOF'
   11878 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   11879 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   11880 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   11881 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   11882 calc: error: 4444 != 1
   11883 _ATEOF
   11884 
   11885 # 3. If locations are not used, remove them.
   11886 sed 's/^[-0-9.]*: //' expout >at-expout
   11887 mv at-expout expout
   11888 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   11889 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   11890 mv at-expout expout
   11891 # 5. Check
   11892 $at_traceoff
   11893 echo "calc.at:550: cat stderr"
   11894 echo calc.at:550 >$at_check_line_file
   11895 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   11896 at_status=$?
   11897 grep '^ *+' $at_stder1 >&2
   11898 grep -v '^ *+' $at_stder1 >$at_stderr
   11899 at_failed=false
   11900 $at_diff $at_devnull $at_stderr || at_failed=:
   11901 $at_diff expout $at_stdout || at_failed=:
   11902 case $at_status in
   11903    77) echo 77 > $at_status_file
   11904             exit 77;;
   11905    0) ;;
   11906    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11907       at_failed=:;;
   11908 esac
   11909 if $at_failed; then
   11910 
   11911   echo 1 > $at_status_file
   11912   exit 1
   11913 fi
   11914 
   11915 $at_traceon
   11916 
   11917 
   11918 
   11919 # The same, but this time exercising explicitly triggered syntax errors.
   11920 # POSIX says the look-ahead causing the error should not be discarded.
   11921 cat >input <<'_ATEOF'
   11922 (!) + (0 0) = 1
   11923 _ATEOF
   11924 
   11925 $at_traceoff
   11926 echo "calc.at:550: \$PREPARSER ./calc input"
   11927 echo calc.at:550 >$at_check_line_file
   11928 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   11929 at_status=$?
   11930 grep '^ *+' $at_stder1 >&2
   11931 grep -v '^ *+' $at_stder1 >$at_stderr
   11932 at_failed=false
   11933 echo stderr:; tee stderr <$at_stderr
   11934 $at_diff $at_devnull $at_stdout || at_failed=:
   11935 case $at_status in
   11936    77) echo 77 > $at_status_file
   11937             exit 77;;
   11938    0) ;;
   11939    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11940       at_failed=:;;
   11941 esac
   11942 if $at_failed; then
   11943 
   11944   echo 1 > $at_status_file
   11945   exit 1
   11946 fi
   11947 
   11948 $at_traceon
   11949 
   11950 
   11951 # Normalize the observed and expected error messages, depending upon the
   11952 # options.
   11953 # 1. Remove the traces from observed.
   11954 sed '/^Starting/d
   11955 /^Entering/d
   11956 /^Stack/d
   11957 /^Reading/d
   11958 /^Reducing/d
   11959 /^Shifting/d
   11960 /^state/d
   11961 /^Cleanup:/d
   11962 /^Error:/d
   11963 /^Next/d
   11964 /^Discarding/d
   11965 / \$[0-9$]* = /d
   11966 /^yydestructor:/d' stderr >at-stderr
   11967 mv at-stderr stderr
   11968 # 2. Create the reference error message.
   11969 cat >expout <<'_ATEOF'
   11970 1.9: syntax error, unexpected number
   11971 calc: error: 2222 != 1
   11972 _ATEOF
   11973 
   11974 # 3. If locations are not used, remove them.
   11975 sed 's/^[-0-9.]*: //' expout >at-expout
   11976 mv at-expout expout
   11977 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   11978 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   11979 mv at-expout expout
   11980 # 5. Check
   11981 $at_traceoff
   11982 echo "calc.at:550: cat stderr"
   11983 echo calc.at:550 >$at_check_line_file
   11984 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   11985 at_status=$?
   11986 grep '^ *+' $at_stder1 >&2
   11987 grep -v '^ *+' $at_stder1 >$at_stderr
   11988 at_failed=false
   11989 $at_diff $at_devnull $at_stderr || at_failed=:
   11990 $at_diff expout $at_stdout || at_failed=:
   11991 case $at_status in
   11992    77) echo 77 > $at_status_file
   11993             exit 77;;
   11994    0) ;;
   11995    *) echo "calc.at:550: exit code was $at_status, expected 0"
   11996       at_failed=:;;
   11997 esac
   11998 if $at_failed; then
   11999 
   12000   echo 1 > $at_status_file
   12001   exit 1
   12002 fi
   12003 
   12004 $at_traceon
   12005 
   12006 
   12007 cat >input <<'_ATEOF'
   12008 (- *) + (0 0) = 1
   12009 _ATEOF
   12010 
   12011 $at_traceoff
   12012 echo "calc.at:550: \$PREPARSER ./calc input"
   12013 echo calc.at:550 >$at_check_line_file
   12014 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   12015 at_status=$?
   12016 grep '^ *+' $at_stder1 >&2
   12017 grep -v '^ *+' $at_stder1 >$at_stderr
   12018 at_failed=false
   12019 echo stderr:; tee stderr <$at_stderr
   12020 $at_diff $at_devnull $at_stdout || at_failed=:
   12021 case $at_status in
   12022    77) echo 77 > $at_status_file
   12023             exit 77;;
   12024    0) ;;
   12025    *) echo "calc.at:550: exit code was $at_status, expected 0"
   12026       at_failed=:;;
   12027 esac
   12028 if $at_failed; then
   12029 
   12030   echo 1 > $at_status_file
   12031   exit 1
   12032 fi
   12033 
   12034 $at_traceon
   12035 
   12036 
   12037 # Normalize the observed and expected error messages, depending upon the
   12038 # options.
   12039 # 1. Remove the traces from observed.
   12040 sed '/^Starting/d
   12041 /^Entering/d
   12042 /^Stack/d
   12043 /^Reading/d
   12044 /^Reducing/d
   12045 /^Shifting/d
   12046 /^state/d
   12047 /^Cleanup:/d
   12048 /^Error:/d
   12049 /^Next/d
   12050 /^Discarding/d
   12051 / \$[0-9$]* = /d
   12052 /^yydestructor:/d' stderr >at-stderr
   12053 mv at-stderr stderr
   12054 # 2. Create the reference error message.
   12055 cat >expout <<'_ATEOF'
   12056 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   12057 1.11: syntax error, unexpected number
   12058 calc: error: 2222 != 1
   12059 _ATEOF
   12060 
   12061 # 3. If locations are not used, remove them.
   12062 sed 's/^[-0-9.]*: //' expout >at-expout
   12063 mv at-expout expout
   12064 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   12065 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   12066 mv at-expout expout
   12067 # 5. Check
   12068 $at_traceoff
   12069 echo "calc.at:550: cat stderr"
   12070 echo calc.at:550 >$at_check_line_file
   12071 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   12072 at_status=$?
   12073 grep '^ *+' $at_stder1 >&2
   12074 grep -v '^ *+' $at_stder1 >$at_stderr
   12075 at_failed=false
   12076 $at_diff $at_devnull $at_stderr || at_failed=:
   12077 $at_diff expout $at_stdout || at_failed=:
   12078 case $at_status in
   12079    77) echo 77 > $at_status_file
   12080             exit 77;;
   12081    0) ;;
   12082    *) echo "calc.at:550: exit code was $at_status, expected 0"
   12083       at_failed=:;;
   12084 esac
   12085 if $at_failed; then
   12086 
   12087   echo 1 > $at_status_file
   12088   exit 1
   12089 fi
   12090 
   12091 $at_traceon
   12092 
   12093 
   12094 
   12095 
   12096 
   12097 
   12098 
   12099 
   12100 
   12101 
   12102 
   12103 
   12104 
   12105 
   12106 
   12107 
   12108 
   12109 
   12110 
   12111 
   12112 
   12113 
   12114 
   12115 
   12116       $at_traceoff
   12117       $at_times_p && times >$at_times_file
   12118     ) 5>&1 2>&1 | eval $at_tee_pipe
   12119     at_status=`cat $at_status_file`
   12120     ;;
   12121 
   12122   71 ) # 71. calc.at:552: Calculator %defines
   12123     at_setup_line='calc.at:552'
   12124     at_desc='Calculator %defines'
   12125     $at_quiet $ECHO_N " 71: Calculator %defines                          $ECHO_C"
   12126     at_xfail=no
   12127     (
   12128       echo "71. calc.at:552: testing ..."
   12129       $at_traceon
   12130 
   12131 
   12132 
   12133 
   12134 
   12135 
   12136 
   12137 
   12138 # Using yacc.c?
   12139 
   12140 
   12141 
   12142 
   12143 
   12144 
   12145 
   12146 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   12147 
   12148 # yyerror always sees the locations (when activated), except if
   12149 # yacc & pure & !param.
   12150 
   12151 
   12152 # The interface is pure: either because %pure-parser, or because we
   12153 # are using the C++ parsers.
   12154 
   12155 
   12156 
   12157 
   12158 
   12159 
   12160 
   12161 
   12162 
   12163 
   12164 
   12165 
   12166 cat >calc.y <<'_ATEOF'
   12167 %{
   12168 #ifdef HAVE_CONFIG_H
   12169 # include <config.h>
   12170   /* We don't need perfect functions for these tests. */
   12171 # undef malloc
   12172 # undef memcmp
   12173 # undef realloc
   12174 #endif
   12175 %}
   12176 
   12177 /* Infix notation calculator--calc */
   12178 %defines
   12179 
   12180 %{
   12181 #include <stdio.h>
   12182 
   12183 #include <stdlib.h>
   12184 #include <string.h>
   12185 #if HAVE_UNISTD_H
   12186 # include <unistd.h>
   12187 #else
   12188 # undef alarm
   12189 # define alarm(seconds) /* empty */
   12190 #endif
   12191 #include <ctype.h>
   12192 #define USE(Var)
   12193 
   12194 /* Exercise pre-prologue dependency to %union.  */
   12195 typedef int semantic_value;
   12196 
   12197 static semantic_value global_result = 0;
   12198 static int global_count = 0;
   12199 %}
   12200 
   12201 /* Exercise %union. */
   12202 %union
   12203 {
   12204   semantic_value ival;
   12205 };
   12206 
   12207 %{
   12208 static int power (int base, int exponent);
   12209 /* yyerror receives the location if:
   12210    - %location & %pure & %glr
   12211    - %location & %pure & %yacc & %parse-param. */
   12212 static void yyerror (
   12213 
   12214                      const char *s
   12215                      );
   12216 static int yylex (void);
   12217 static int get_char (void);
   12218 static void unget_char ( int c);
   12219 %}
   12220 
   12221 
   12222 
   12223 /* Bison Declarations */
   12224 %token CALC_EOF 0 "end of input"
   12225 %token <ival> NUM "number"
   12226 %type  <ival> exp
   12227 
   12228 %nonassoc '=' /* comparison	       */
   12229 %left '-' '+'
   12230 %left '*' '/'
   12231 %left NEG     /* negation--unary minus */
   12232 %right '^'    /* exponentiation        */
   12233 
   12234 /* Grammar follows */
   12235 %%
   12236 input:
   12237   line
   12238 | input line         {  }
   12239 ;
   12240 
   12241 line:
   12242   '\n'
   12243 | exp '\n'           { USE ($1); }
   12244 ;
   12245 
   12246 exp:
   12247   NUM                { $$ = $1;             }
   12248 | exp '=' exp
   12249   {
   12250     if ($1 != $3)
   12251       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   12252     $$ = $1;
   12253   }
   12254 | exp '+' exp        { $$ = $1 + $3;        }
   12255 | exp '-' exp        { $$ = $1 - $3;        }
   12256 | exp '*' exp        { $$ = $1 * $3;        }
   12257 | exp '/' exp        { $$ = $1 / $3;        }
   12258 | '-' exp  %prec NEG { $$ = -$2;            }
   12259 | exp '^' exp        { $$ = power ($1, $3); }
   12260 | '(' exp ')'        { $$ = $2;             }
   12261 | '(' error ')'      { $$ = 1111;           }
   12262 | '!'                { $$ = 0; YYERROR;     }
   12263 | '-' error          { $$ = 0; YYERROR;     }
   12264 ;
   12265 %%
   12266 /* The input.  */
   12267 static FILE *input;
   12268 
   12269 static void
   12270 yyerror (
   12271 
   12272          const char *s)
   12273 {
   12274 
   12275 
   12276   fprintf (stderr, "%s\n", s);
   12277 }
   12278 
   12279 
   12280 
   12281 static int
   12282 get_char (void)
   12283 {
   12284   int res = getc (input);
   12285   ;
   12286 
   12287   return res;
   12288 }
   12289 
   12290 
   12291 static void
   12292 unget_char ( int c)
   12293 {
   12294   ;
   12295 
   12296   ungetc (c, input);
   12297 }
   12298 
   12299 static int
   12300 read_signed_integer (void)
   12301 {
   12302   int c = get_char ();
   12303   int sign = 1;
   12304   int n = 0;
   12305 
   12306   ;
   12307   if (c == '-')
   12308     {
   12309       c = get_char ();
   12310       sign = -1;
   12311     }
   12312 
   12313   while (isdigit (c))
   12314     {
   12315       n = 10 * n + (c - '0');
   12316       c = get_char ();
   12317     }
   12318 
   12319   unget_char ( c);
   12320 
   12321   return sign * n;
   12322 }
   12323 
   12324 
   12325 
   12326 /*---------------------------------------------------------------.
   12327 | Lexical analyzer returns an integer on the stack and the token |
   12328 | NUM, or the ASCII character read if not a number.  Skips all   |
   12329 | blanks and tabs, returns 0 for EOF.                            |
   12330 `---------------------------------------------------------------*/
   12331 
   12332 static int
   12333 yylex (void)
   12334 {
   12335   static int init = 1;
   12336   int c;
   12337 
   12338   if (init)
   12339     {
   12340       init = 0;
   12341 
   12342     }
   12343 
   12344 
   12345 
   12346   /* Skip white space.  */
   12347   while ((c = get_char ()) == ' ' || c == '\t')
   12348     {
   12349 
   12350     }
   12351 
   12352   /* process numbers   */
   12353   if (c == '.' || isdigit (c))
   12354     {
   12355       unget_char ( c);
   12356       (yylval).ival = read_signed_integer ();
   12357       return NUM;
   12358     }
   12359 
   12360   /* Return end-of-file.  */
   12361   if (c == EOF)
   12362     return CALC_EOF;
   12363 
   12364   /* Return single chars. */
   12365   return c;
   12366 }
   12367 
   12368 static int
   12369 power (int base, int exponent)
   12370 {
   12371   int res = 1;
   12372   if (exponent < 0)
   12373     exit (3);
   12374   for (/* Niente */; exponent; --exponent)
   12375     res *= base;
   12376   return res;
   12377 }
   12378 
   12379 
   12380 int
   12381 main (int argc, const char **argv)
   12382 {
   12383   semantic_value result = 0;
   12384   int count = 0;
   12385   int status;
   12386 
   12387   /* This used to be alarm (10), but that isn't enough time for
   12388      a July 1995 vintage DEC Alphastation 200 4/100 system,
   12389      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   12390   alarm (100);
   12391 
   12392   if (argc == 2)
   12393     input = fopen (argv[1], "r");
   12394   else
   12395     input = stdin;
   12396 
   12397   if (!input)
   12398     {
   12399       perror (argv[1]);
   12400       return 3;
   12401     }
   12402 
   12403 
   12404   status = yyparse ();
   12405   if (global_result != result)
   12406     abort ();
   12407   if (global_count != count)
   12408     abort ();
   12409   return status;
   12410 }
   12411 _ATEOF
   12412 
   12413 
   12414 
   12415 
   12416 
   12417 $at_traceoff
   12418 echo "calc.at:552: bison -o calc.c calc.y"
   12419 echo calc.at:552 >$at_check_line_file
   12420 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   12421 at_status=$?
   12422 grep '^ *+' $at_stder1 >&2
   12423 grep -v '^ *+' $at_stder1 >$at_stderr
   12424 at_failed=false
   12425 $at_diff $at_devnull $at_stderr || at_failed=:
   12426 $at_diff $at_devnull $at_stdout || at_failed=:
   12427 case $at_status in
   12428    77) echo 77 > $at_status_file
   12429             exit 77;;
   12430    0) ;;
   12431    *) echo "calc.at:552: exit code was $at_status, expected 0"
   12432       at_failed=:;;
   12433 esac
   12434 if $at_failed; then
   12435 
   12436   echo 1 > $at_status_file
   12437   exit 1
   12438 fi
   12439 
   12440 $at_traceon
   12441 
   12442    $at_traceoff
   12443 echo "calc.at:552: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   12444 echo calc.at:552 >$at_check_line_file
   12445 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   12446 at_status=$?
   12447 grep '^ *+' $at_stder1 >&2
   12448 grep -v '^ *+' $at_stder1 >$at_stderr
   12449 at_failed=false
   12450 echo stderr:; cat $at_stderr
   12451 echo stdout:; cat $at_stdout
   12452 case $at_status in
   12453    77) echo 77 > $at_status_file
   12454             exit 77;;
   12455    0) ;;
   12456    *) echo "calc.at:552: exit code was $at_status, expected 0"
   12457       at_failed=:;;
   12458 esac
   12459 if $at_failed; then
   12460 
   12461   echo 1 > $at_status_file
   12462   exit 1
   12463 fi
   12464 
   12465 $at_traceon
   12466 
   12467 
   12468 # Test the priorities.
   12469 cat >input <<'_ATEOF'
   12470 1 + 2 * 3 = 7
   12471 1 + 2 * -3 = -5
   12472 
   12473 -1^2 = -1
   12474 (-1)^2 = 1
   12475 
   12476 ---1 = -1
   12477 
   12478 1 - 2 - 3 = -4
   12479 1 - (2 - 3) = 2
   12480 
   12481 2^2^3 = 256
   12482 (2^2)^3 = 64
   12483 _ATEOF
   12484 
   12485 $at_traceoff
   12486 echo "calc.at:552: \$PREPARSER ./calc input"
   12487 echo calc.at:552 >$at_check_line_file
   12488 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   12489 at_status=$?
   12490 grep '^ *+' $at_stder1 >&2
   12491 grep -v '^ *+' $at_stder1 >$at_stderr
   12492 at_failed=false
   12493 echo stderr:; tee stderr <$at_stderr
   12494 $at_diff $at_devnull $at_stdout || at_failed=:
   12495 case $at_status in
   12496    77) echo 77 > $at_status_file
   12497             exit 77;;
   12498    0) ;;
   12499    *) echo "calc.at:552: exit code was $at_status, expected 0"
   12500       at_failed=:;;
   12501 esac
   12502 if $at_failed; then
   12503 
   12504   echo 1 > $at_status_file
   12505   exit 1
   12506 fi
   12507 
   12508 $at_traceon
   12509 
   12510 
   12511 
   12512 # Some syntax errors.
   12513 cat >input <<'_ATEOF'
   12514 0 0
   12515 _ATEOF
   12516 
   12517 $at_traceoff
   12518 echo "calc.at:552: \$PREPARSER ./calc input"
   12519 echo calc.at:552 >$at_check_line_file
   12520 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   12521 at_status=$?
   12522 grep '^ *+' $at_stder1 >&2
   12523 grep -v '^ *+' $at_stder1 >$at_stderr
   12524 at_failed=false
   12525 echo stderr:; tee stderr <$at_stderr
   12526 $at_diff $at_devnull $at_stdout || at_failed=:
   12527 case $at_status in
   12528    77) echo 77 > $at_status_file
   12529             exit 77;;
   12530    1) ;;
   12531    *) echo "calc.at:552: exit code was $at_status, expected 1"
   12532       at_failed=:;;
   12533 esac
   12534 if $at_failed; then
   12535 
   12536   echo 1 > $at_status_file
   12537   exit 1
   12538 fi
   12539 
   12540 $at_traceon
   12541 
   12542 
   12543 # Normalize the observed and expected error messages, depending upon the
   12544 # options.
   12545 # 1. Remove the traces from observed.
   12546 sed '/^Starting/d
   12547 /^Entering/d
   12548 /^Stack/d
   12549 /^Reading/d
   12550 /^Reducing/d
   12551 /^Shifting/d
   12552 /^state/d
   12553 /^Cleanup:/d
   12554 /^Error:/d
   12555 /^Next/d
   12556 /^Discarding/d
   12557 / \$[0-9$]* = /d
   12558 /^yydestructor:/d' stderr >at-stderr
   12559 mv at-stderr stderr
   12560 # 2. Create the reference error message.
   12561 cat >expout <<'_ATEOF'
   12562 1.2: syntax error, unexpected number
   12563 _ATEOF
   12564 
   12565 # 3. If locations are not used, remove them.
   12566 sed 's/^[-0-9.]*: //' expout >at-expout
   12567 mv at-expout expout
   12568 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   12569 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   12570 mv at-expout expout
   12571 # 5. Check
   12572 $at_traceoff
   12573 echo "calc.at:552: cat stderr"
   12574 echo calc.at:552 >$at_check_line_file
   12575 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   12576 at_status=$?
   12577 grep '^ *+' $at_stder1 >&2
   12578 grep -v '^ *+' $at_stder1 >$at_stderr
   12579 at_failed=false
   12580 $at_diff $at_devnull $at_stderr || at_failed=:
   12581 $at_diff expout $at_stdout || at_failed=:
   12582 case $at_status in
   12583    77) echo 77 > $at_status_file
   12584             exit 77;;
   12585    0) ;;
   12586    *) echo "calc.at:552: exit code was $at_status, expected 0"
   12587       at_failed=:;;
   12588 esac
   12589 if $at_failed; then
   12590 
   12591   echo 1 > $at_status_file
   12592   exit 1
   12593 fi
   12594 
   12595 $at_traceon
   12596 
   12597 
   12598 cat >input <<'_ATEOF'
   12599 1//2
   12600 _ATEOF
   12601 
   12602 $at_traceoff
   12603 echo "calc.at:552: \$PREPARSER ./calc input"
   12604 echo calc.at:552 >$at_check_line_file
   12605 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   12606 at_status=$?
   12607 grep '^ *+' $at_stder1 >&2
   12608 grep -v '^ *+' $at_stder1 >$at_stderr
   12609 at_failed=false
   12610 echo stderr:; tee stderr <$at_stderr
   12611 $at_diff $at_devnull $at_stdout || at_failed=:
   12612 case $at_status in
   12613    77) echo 77 > $at_status_file
   12614             exit 77;;
   12615    1) ;;
   12616    *) echo "calc.at:552: exit code was $at_status, expected 1"
   12617       at_failed=:;;
   12618 esac
   12619 if $at_failed; then
   12620 
   12621   echo 1 > $at_status_file
   12622   exit 1
   12623 fi
   12624 
   12625 $at_traceon
   12626 
   12627 
   12628 # Normalize the observed and expected error messages, depending upon the
   12629 # options.
   12630 # 1. Remove the traces from observed.
   12631 sed '/^Starting/d
   12632 /^Entering/d
   12633 /^Stack/d
   12634 /^Reading/d
   12635 /^Reducing/d
   12636 /^Shifting/d
   12637 /^state/d
   12638 /^Cleanup:/d
   12639 /^Error:/d
   12640 /^Next/d
   12641 /^Discarding/d
   12642 / \$[0-9$]* = /d
   12643 /^yydestructor:/d' stderr >at-stderr
   12644 mv at-stderr stderr
   12645 # 2. Create the reference error message.
   12646 cat >expout <<'_ATEOF'
   12647 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   12648 _ATEOF
   12649 
   12650 # 3. If locations are not used, remove them.
   12651 sed 's/^[-0-9.]*: //' expout >at-expout
   12652 mv at-expout expout
   12653 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   12654 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   12655 mv at-expout expout
   12656 # 5. Check
   12657 $at_traceoff
   12658 echo "calc.at:552: cat stderr"
   12659 echo calc.at:552 >$at_check_line_file
   12660 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   12661 at_status=$?
   12662 grep '^ *+' $at_stder1 >&2
   12663 grep -v '^ *+' $at_stder1 >$at_stderr
   12664 at_failed=false
   12665 $at_diff $at_devnull $at_stderr || at_failed=:
   12666 $at_diff expout $at_stdout || at_failed=:
   12667 case $at_status in
   12668    77) echo 77 > $at_status_file
   12669             exit 77;;
   12670    0) ;;
   12671    *) echo "calc.at:552: exit code was $at_status, expected 0"
   12672       at_failed=:;;
   12673 esac
   12674 if $at_failed; then
   12675 
   12676   echo 1 > $at_status_file
   12677   exit 1
   12678 fi
   12679 
   12680 $at_traceon
   12681 
   12682 
   12683 cat >input <<'_ATEOF'
   12684 error
   12685 _ATEOF
   12686 
   12687 $at_traceoff
   12688 echo "calc.at:552: \$PREPARSER ./calc input"
   12689 echo calc.at:552 >$at_check_line_file
   12690 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   12691 at_status=$?
   12692 grep '^ *+' $at_stder1 >&2
   12693 grep -v '^ *+' $at_stder1 >$at_stderr
   12694 at_failed=false
   12695 echo stderr:; tee stderr <$at_stderr
   12696 $at_diff $at_devnull $at_stdout || at_failed=:
   12697 case $at_status in
   12698    77) echo 77 > $at_status_file
   12699             exit 77;;
   12700    1) ;;
   12701    *) echo "calc.at:552: exit code was $at_status, expected 1"
   12702       at_failed=:;;
   12703 esac
   12704 if $at_failed; then
   12705 
   12706   echo 1 > $at_status_file
   12707   exit 1
   12708 fi
   12709 
   12710 $at_traceon
   12711 
   12712 
   12713 # Normalize the observed and expected error messages, depending upon the
   12714 # options.
   12715 # 1. Remove the traces from observed.
   12716 sed '/^Starting/d
   12717 /^Entering/d
   12718 /^Stack/d
   12719 /^Reading/d
   12720 /^Reducing/d
   12721 /^Shifting/d
   12722 /^state/d
   12723 /^Cleanup:/d
   12724 /^Error:/d
   12725 /^Next/d
   12726 /^Discarding/d
   12727 / \$[0-9$]* = /d
   12728 /^yydestructor:/d' stderr >at-stderr
   12729 mv at-stderr stderr
   12730 # 2. Create the reference error message.
   12731 cat >expout <<'_ATEOF'
   12732 1.0: syntax error, unexpected $undefined
   12733 _ATEOF
   12734 
   12735 # 3. If locations are not used, remove them.
   12736 sed 's/^[-0-9.]*: //' expout >at-expout
   12737 mv at-expout expout
   12738 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   12739 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   12740 mv at-expout expout
   12741 # 5. Check
   12742 $at_traceoff
   12743 echo "calc.at:552: cat stderr"
   12744 echo calc.at:552 >$at_check_line_file
   12745 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   12746 at_status=$?
   12747 grep '^ *+' $at_stder1 >&2
   12748 grep -v '^ *+' $at_stder1 >$at_stderr
   12749 at_failed=false
   12750 $at_diff $at_devnull $at_stderr || at_failed=:
   12751 $at_diff expout $at_stdout || at_failed=:
   12752 case $at_status in
   12753    77) echo 77 > $at_status_file
   12754             exit 77;;
   12755    0) ;;
   12756    *) echo "calc.at:552: exit code was $at_status, expected 0"
   12757       at_failed=:;;
   12758 esac
   12759 if $at_failed; then
   12760 
   12761   echo 1 > $at_status_file
   12762   exit 1
   12763 fi
   12764 
   12765 $at_traceon
   12766 
   12767 
   12768 cat >input <<'_ATEOF'
   12769 1 = 2 = 3
   12770 _ATEOF
   12771 
   12772 $at_traceoff
   12773 echo "calc.at:552: \$PREPARSER ./calc input"
   12774 echo calc.at:552 >$at_check_line_file
   12775 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   12776 at_status=$?
   12777 grep '^ *+' $at_stder1 >&2
   12778 grep -v '^ *+' $at_stder1 >$at_stderr
   12779 at_failed=false
   12780 echo stderr:; tee stderr <$at_stderr
   12781 $at_diff $at_devnull $at_stdout || at_failed=:
   12782 case $at_status in
   12783    77) echo 77 > $at_status_file
   12784             exit 77;;
   12785    1) ;;
   12786    *) echo "calc.at:552: exit code was $at_status, expected 1"
   12787       at_failed=:;;
   12788 esac
   12789 if $at_failed; then
   12790 
   12791   echo 1 > $at_status_file
   12792   exit 1
   12793 fi
   12794 
   12795 $at_traceon
   12796 
   12797 
   12798 # Normalize the observed and expected error messages, depending upon the
   12799 # options.
   12800 # 1. Remove the traces from observed.
   12801 sed '/^Starting/d
   12802 /^Entering/d
   12803 /^Stack/d
   12804 /^Reading/d
   12805 /^Reducing/d
   12806 /^Shifting/d
   12807 /^state/d
   12808 /^Cleanup:/d
   12809 /^Error:/d
   12810 /^Next/d
   12811 /^Discarding/d
   12812 / \$[0-9$]* = /d
   12813 /^yydestructor:/d' stderr >at-stderr
   12814 mv at-stderr stderr
   12815 # 2. Create the reference error message.
   12816 cat >expout <<'_ATEOF'
   12817 1.6: syntax error, unexpected '='
   12818 _ATEOF
   12819 
   12820 # 3. If locations are not used, remove them.
   12821 sed 's/^[-0-9.]*: //' expout >at-expout
   12822 mv at-expout expout
   12823 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   12824 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   12825 mv at-expout expout
   12826 # 5. Check
   12827 $at_traceoff
   12828 echo "calc.at:552: cat stderr"
   12829 echo calc.at:552 >$at_check_line_file
   12830 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   12831 at_status=$?
   12832 grep '^ *+' $at_stder1 >&2
   12833 grep -v '^ *+' $at_stder1 >$at_stderr
   12834 at_failed=false
   12835 $at_diff $at_devnull $at_stderr || at_failed=:
   12836 $at_diff expout $at_stdout || at_failed=:
   12837 case $at_status in
   12838    77) echo 77 > $at_status_file
   12839             exit 77;;
   12840    0) ;;
   12841    *) echo "calc.at:552: exit code was $at_status, expected 0"
   12842       at_failed=:;;
   12843 esac
   12844 if $at_failed; then
   12845 
   12846   echo 1 > $at_status_file
   12847   exit 1
   12848 fi
   12849 
   12850 $at_traceon
   12851 
   12852 
   12853 cat >input <<'_ATEOF'
   12854 
   12855 +1
   12856 _ATEOF
   12857 
   12858 $at_traceoff
   12859 echo "calc.at:552: \$PREPARSER ./calc input"
   12860 echo calc.at:552 >$at_check_line_file
   12861 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   12862 at_status=$?
   12863 grep '^ *+' $at_stder1 >&2
   12864 grep -v '^ *+' $at_stder1 >$at_stderr
   12865 at_failed=false
   12866 echo stderr:; tee stderr <$at_stderr
   12867 $at_diff $at_devnull $at_stdout || at_failed=:
   12868 case $at_status in
   12869    77) echo 77 > $at_status_file
   12870             exit 77;;
   12871    1) ;;
   12872    *) echo "calc.at:552: exit code was $at_status, expected 1"
   12873       at_failed=:;;
   12874 esac
   12875 if $at_failed; then
   12876 
   12877   echo 1 > $at_status_file
   12878   exit 1
   12879 fi
   12880 
   12881 $at_traceon
   12882 
   12883 
   12884 # Normalize the observed and expected error messages, depending upon the
   12885 # options.
   12886 # 1. Remove the traces from observed.
   12887 sed '/^Starting/d
   12888 /^Entering/d
   12889 /^Stack/d
   12890 /^Reading/d
   12891 /^Reducing/d
   12892 /^Shifting/d
   12893 /^state/d
   12894 /^Cleanup:/d
   12895 /^Error:/d
   12896 /^Next/d
   12897 /^Discarding/d
   12898 / \$[0-9$]* = /d
   12899 /^yydestructor:/d' stderr >at-stderr
   12900 mv at-stderr stderr
   12901 # 2. Create the reference error message.
   12902 cat >expout <<'_ATEOF'
   12903 2.0: syntax error, unexpected '+'
   12904 _ATEOF
   12905 
   12906 # 3. If locations are not used, remove them.
   12907 sed 's/^[-0-9.]*: //' expout >at-expout
   12908 mv at-expout expout
   12909 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   12910 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   12911 mv at-expout expout
   12912 # 5. Check
   12913 $at_traceoff
   12914 echo "calc.at:552: cat stderr"
   12915 echo calc.at:552 >$at_check_line_file
   12916 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   12917 at_status=$?
   12918 grep '^ *+' $at_stder1 >&2
   12919 grep -v '^ *+' $at_stder1 >$at_stderr
   12920 at_failed=false
   12921 $at_diff $at_devnull $at_stderr || at_failed=:
   12922 $at_diff expout $at_stdout || at_failed=:
   12923 case $at_status in
   12924    77) echo 77 > $at_status_file
   12925             exit 77;;
   12926    0) ;;
   12927    *) echo "calc.at:552: exit code was $at_status, expected 0"
   12928       at_failed=:;;
   12929 esac
   12930 if $at_failed; then
   12931 
   12932   echo 1 > $at_status_file
   12933   exit 1
   12934 fi
   12935 
   12936 $at_traceon
   12937 
   12938 
   12939 # Exercise error messages with EOF: work on an empty file.
   12940 $at_traceoff
   12941 echo "calc.at:552: \$PREPARSER ./calc /dev/null"
   12942 echo calc.at:552 >$at_check_line_file
   12943 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   12944 at_status=$?
   12945 grep '^ *+' $at_stder1 >&2
   12946 grep -v '^ *+' $at_stder1 >$at_stderr
   12947 at_failed=false
   12948 echo stderr:; tee stderr <$at_stderr
   12949 $at_diff $at_devnull $at_stdout || at_failed=:
   12950 case $at_status in
   12951    77) echo 77 > $at_status_file
   12952             exit 77;;
   12953    1) ;;
   12954    *) echo "calc.at:552: exit code was $at_status, expected 1"
   12955       at_failed=:;;
   12956 esac
   12957 if $at_failed; then
   12958 
   12959   echo 1 > $at_status_file
   12960   exit 1
   12961 fi
   12962 
   12963 $at_traceon
   12964 
   12965 
   12966 # Normalize the observed and expected error messages, depending upon the
   12967 # options.
   12968 # 1. Remove the traces from observed.
   12969 sed '/^Starting/d
   12970 /^Entering/d
   12971 /^Stack/d
   12972 /^Reading/d
   12973 /^Reducing/d
   12974 /^Shifting/d
   12975 /^state/d
   12976 /^Cleanup:/d
   12977 /^Error:/d
   12978 /^Next/d
   12979 /^Discarding/d
   12980 / \$[0-9$]* = /d
   12981 /^yydestructor:/d' stderr >at-stderr
   12982 mv at-stderr stderr
   12983 # 2. Create the reference error message.
   12984 cat >expout <<'_ATEOF'
   12985 1.0: syntax error, unexpected end of input
   12986 _ATEOF
   12987 
   12988 # 3. If locations are not used, remove them.
   12989 sed 's/^[-0-9.]*: //' expout >at-expout
   12990 mv at-expout expout
   12991 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   12992 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   12993 mv at-expout expout
   12994 # 5. Check
   12995 $at_traceoff
   12996 echo "calc.at:552: cat stderr"
   12997 echo calc.at:552 >$at_check_line_file
   12998 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   12999 at_status=$?
   13000 grep '^ *+' $at_stder1 >&2
   13001 grep -v '^ *+' $at_stder1 >$at_stderr
   13002 at_failed=false
   13003 $at_diff $at_devnull $at_stderr || at_failed=:
   13004 $at_diff expout $at_stdout || at_failed=:
   13005 case $at_status in
   13006    77) echo 77 > $at_status_file
   13007             exit 77;;
   13008    0) ;;
   13009    *) echo "calc.at:552: exit code was $at_status, expected 0"
   13010       at_failed=:;;
   13011 esac
   13012 if $at_failed; then
   13013 
   13014   echo 1 > $at_status_file
   13015   exit 1
   13016 fi
   13017 
   13018 $at_traceon
   13019 
   13020 
   13021 
   13022 # Exercise the error token: without it, we die at the first error,
   13023 # hence be sure to
   13024 #
   13025 # - have several errors which exercise different shift/discardings
   13026 #   - (): nothing to pop, nothing to discard
   13027 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   13028 #   - (* * *): nothing to pop, a lot to discard
   13029 #   - (1 + 2 * *): some to pop and discard
   13030 #
   13031 # - test the action associated to `error'
   13032 #
   13033 # - check the look-ahead that triggers an error is not discarded
   13034 #   when we enter error recovery.  Below, the look-ahead causing the
   13035 #   first error is ")", which is needed to recover from the error and
   13036 #   produce the "0" that triggers the "0 != 1" error.
   13037 #
   13038 cat >input <<'_ATEOF'
   13039 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   13040 _ATEOF
   13041 
   13042 $at_traceoff
   13043 echo "calc.at:552: \$PREPARSER ./calc input"
   13044 echo calc.at:552 >$at_check_line_file
   13045 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   13046 at_status=$?
   13047 grep '^ *+' $at_stder1 >&2
   13048 grep -v '^ *+' $at_stder1 >$at_stderr
   13049 at_failed=false
   13050 echo stderr:; tee stderr <$at_stderr
   13051 $at_diff $at_devnull $at_stdout || at_failed=:
   13052 case $at_status in
   13053    77) echo 77 > $at_status_file
   13054             exit 77;;
   13055    0) ;;
   13056    *) echo "calc.at:552: exit code was $at_status, expected 0"
   13057       at_failed=:;;
   13058 esac
   13059 if $at_failed; then
   13060 
   13061   echo 1 > $at_status_file
   13062   exit 1
   13063 fi
   13064 
   13065 $at_traceon
   13066 
   13067 
   13068 # Normalize the observed and expected error messages, depending upon the
   13069 # options.
   13070 # 1. Remove the traces from observed.
   13071 sed '/^Starting/d
   13072 /^Entering/d
   13073 /^Stack/d
   13074 /^Reading/d
   13075 /^Reducing/d
   13076 /^Shifting/d
   13077 /^state/d
   13078 /^Cleanup:/d
   13079 /^Error:/d
   13080 /^Next/d
   13081 /^Discarding/d
   13082 / \$[0-9$]* = /d
   13083 /^yydestructor:/d' stderr >at-stderr
   13084 mv at-stderr stderr
   13085 # 2. Create the reference error message.
   13086 cat >expout <<'_ATEOF'
   13087 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   13088 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   13089 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   13090 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   13091 calc: error: 4444 != 1
   13092 _ATEOF
   13093 
   13094 # 3. If locations are not used, remove them.
   13095 sed 's/^[-0-9.]*: //' expout >at-expout
   13096 mv at-expout expout
   13097 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   13098 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   13099 mv at-expout expout
   13100 # 5. Check
   13101 $at_traceoff
   13102 echo "calc.at:552: cat stderr"
   13103 echo calc.at:552 >$at_check_line_file
   13104 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   13105 at_status=$?
   13106 grep '^ *+' $at_stder1 >&2
   13107 grep -v '^ *+' $at_stder1 >$at_stderr
   13108 at_failed=false
   13109 $at_diff $at_devnull $at_stderr || at_failed=:
   13110 $at_diff expout $at_stdout || at_failed=:
   13111 case $at_status in
   13112    77) echo 77 > $at_status_file
   13113             exit 77;;
   13114    0) ;;
   13115    *) echo "calc.at:552: exit code was $at_status, expected 0"
   13116       at_failed=:;;
   13117 esac
   13118 if $at_failed; then
   13119 
   13120   echo 1 > $at_status_file
   13121   exit 1
   13122 fi
   13123 
   13124 $at_traceon
   13125 
   13126 
   13127 
   13128 # The same, but this time exercising explicitly triggered syntax errors.
   13129 # POSIX says the look-ahead causing the error should not be discarded.
   13130 cat >input <<'_ATEOF'
   13131 (!) + (0 0) = 1
   13132 _ATEOF
   13133 
   13134 $at_traceoff
   13135 echo "calc.at:552: \$PREPARSER ./calc input"
   13136 echo calc.at:552 >$at_check_line_file
   13137 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   13138 at_status=$?
   13139 grep '^ *+' $at_stder1 >&2
   13140 grep -v '^ *+' $at_stder1 >$at_stderr
   13141 at_failed=false
   13142 echo stderr:; tee stderr <$at_stderr
   13143 $at_diff $at_devnull $at_stdout || at_failed=:
   13144 case $at_status in
   13145    77) echo 77 > $at_status_file
   13146             exit 77;;
   13147    0) ;;
   13148    *) echo "calc.at:552: exit code was $at_status, expected 0"
   13149       at_failed=:;;
   13150 esac
   13151 if $at_failed; then
   13152 
   13153   echo 1 > $at_status_file
   13154   exit 1
   13155 fi
   13156 
   13157 $at_traceon
   13158 
   13159 
   13160 # Normalize the observed and expected error messages, depending upon the
   13161 # options.
   13162 # 1. Remove the traces from observed.
   13163 sed '/^Starting/d
   13164 /^Entering/d
   13165 /^Stack/d
   13166 /^Reading/d
   13167 /^Reducing/d
   13168 /^Shifting/d
   13169 /^state/d
   13170 /^Cleanup:/d
   13171 /^Error:/d
   13172 /^Next/d
   13173 /^Discarding/d
   13174 / \$[0-9$]* = /d
   13175 /^yydestructor:/d' stderr >at-stderr
   13176 mv at-stderr stderr
   13177 # 2. Create the reference error message.
   13178 cat >expout <<'_ATEOF'
   13179 1.9: syntax error, unexpected number
   13180 calc: error: 2222 != 1
   13181 _ATEOF
   13182 
   13183 # 3. If locations are not used, remove them.
   13184 sed 's/^[-0-9.]*: //' expout >at-expout
   13185 mv at-expout expout
   13186 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   13187 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   13188 mv at-expout expout
   13189 # 5. Check
   13190 $at_traceoff
   13191 echo "calc.at:552: cat stderr"
   13192 echo calc.at:552 >$at_check_line_file
   13193 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   13194 at_status=$?
   13195 grep '^ *+' $at_stder1 >&2
   13196 grep -v '^ *+' $at_stder1 >$at_stderr
   13197 at_failed=false
   13198 $at_diff $at_devnull $at_stderr || at_failed=:
   13199 $at_diff expout $at_stdout || at_failed=:
   13200 case $at_status in
   13201    77) echo 77 > $at_status_file
   13202             exit 77;;
   13203    0) ;;
   13204    *) echo "calc.at:552: exit code was $at_status, expected 0"
   13205       at_failed=:;;
   13206 esac
   13207 if $at_failed; then
   13208 
   13209   echo 1 > $at_status_file
   13210   exit 1
   13211 fi
   13212 
   13213 $at_traceon
   13214 
   13215 
   13216 cat >input <<'_ATEOF'
   13217 (- *) + (0 0) = 1
   13218 _ATEOF
   13219 
   13220 $at_traceoff
   13221 echo "calc.at:552: \$PREPARSER ./calc input"
   13222 echo calc.at:552 >$at_check_line_file
   13223 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   13224 at_status=$?
   13225 grep '^ *+' $at_stder1 >&2
   13226 grep -v '^ *+' $at_stder1 >$at_stderr
   13227 at_failed=false
   13228 echo stderr:; tee stderr <$at_stderr
   13229 $at_diff $at_devnull $at_stdout || at_failed=:
   13230 case $at_status in
   13231    77) echo 77 > $at_status_file
   13232             exit 77;;
   13233    0) ;;
   13234    *) echo "calc.at:552: exit code was $at_status, expected 0"
   13235       at_failed=:;;
   13236 esac
   13237 if $at_failed; then
   13238 
   13239   echo 1 > $at_status_file
   13240   exit 1
   13241 fi
   13242 
   13243 $at_traceon
   13244 
   13245 
   13246 # Normalize the observed and expected error messages, depending upon the
   13247 # options.
   13248 # 1. Remove the traces from observed.
   13249 sed '/^Starting/d
   13250 /^Entering/d
   13251 /^Stack/d
   13252 /^Reading/d
   13253 /^Reducing/d
   13254 /^Shifting/d
   13255 /^state/d
   13256 /^Cleanup:/d
   13257 /^Error:/d
   13258 /^Next/d
   13259 /^Discarding/d
   13260 / \$[0-9$]* = /d
   13261 /^yydestructor:/d' stderr >at-stderr
   13262 mv at-stderr stderr
   13263 # 2. Create the reference error message.
   13264 cat >expout <<'_ATEOF'
   13265 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   13266 1.11: syntax error, unexpected number
   13267 calc: error: 2222 != 1
   13268 _ATEOF
   13269 
   13270 # 3. If locations are not used, remove them.
   13271 sed 's/^[-0-9.]*: //' expout >at-expout
   13272 mv at-expout expout
   13273 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   13274 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   13275 mv at-expout expout
   13276 # 5. Check
   13277 $at_traceoff
   13278 echo "calc.at:552: cat stderr"
   13279 echo calc.at:552 >$at_check_line_file
   13280 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   13281 at_status=$?
   13282 grep '^ *+' $at_stder1 >&2
   13283 grep -v '^ *+' $at_stder1 >$at_stderr
   13284 at_failed=false
   13285 $at_diff $at_devnull $at_stderr || at_failed=:
   13286 $at_diff expout $at_stdout || at_failed=:
   13287 case $at_status in
   13288    77) echo 77 > $at_status_file
   13289             exit 77;;
   13290    0) ;;
   13291    *) echo "calc.at:552: exit code was $at_status, expected 0"
   13292       at_failed=:;;
   13293 esac
   13294 if $at_failed; then
   13295 
   13296   echo 1 > $at_status_file
   13297   exit 1
   13298 fi
   13299 
   13300 $at_traceon
   13301 
   13302 
   13303 
   13304 
   13305 
   13306 
   13307 
   13308 
   13309 
   13310 
   13311 
   13312 
   13313 
   13314 
   13315 
   13316 
   13317 
   13318 
   13319 
   13320 
   13321 
   13322 
   13323 
   13324 
   13325       $at_traceoff
   13326       $at_times_p && times >$at_times_file
   13327     ) 5>&1 2>&1 | eval $at_tee_pipe
   13328     at_status=`cat $at_status_file`
   13329     ;;
   13330 
   13331   72 ) # 72. calc.at:553: Calculator %locations
   13332     at_setup_line='calc.at:553'
   13333     at_desc='Calculator %locations'
   13334     $at_quiet $ECHO_N " 72: Calculator %locations                        $ECHO_C"
   13335     at_xfail=no
   13336     (
   13337       echo "72. calc.at:553: testing ..."
   13338       $at_traceon
   13339 
   13340 
   13341 
   13342 
   13343 
   13344 
   13345 
   13346 
   13347 # Using yacc.c?
   13348 
   13349 
   13350 
   13351 
   13352 
   13353 
   13354 
   13355 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   13356 
   13357 # yyerror always sees the locations (when activated), except if
   13358 # yacc & pure & !param.
   13359 
   13360 
   13361 # The interface is pure: either because %pure-parser, or because we
   13362 # are using the C++ parsers.
   13363 
   13364 
   13365 
   13366 
   13367 
   13368 
   13369 
   13370 
   13371 
   13372 
   13373 
   13374 
   13375 cat >calc.y <<'_ATEOF'
   13376 %{
   13377 #ifdef HAVE_CONFIG_H
   13378 # include <config.h>
   13379   /* We don't need perfect functions for these tests. */
   13380 # undef malloc
   13381 # undef memcmp
   13382 # undef realloc
   13383 #endif
   13384 %}
   13385 
   13386 /* Infix notation calculator--calc */
   13387 %locations
   13388 
   13389 %{
   13390 #include <stdio.h>
   13391 
   13392 #include <stdlib.h>
   13393 #include <string.h>
   13394 #if HAVE_UNISTD_H
   13395 # include <unistd.h>
   13396 #else
   13397 # undef alarm
   13398 # define alarm(seconds) /* empty */
   13399 #endif
   13400 #include <ctype.h>
   13401 #define USE(Var)
   13402 
   13403 /* Exercise pre-prologue dependency to %union.  */
   13404 typedef int semantic_value;
   13405 
   13406 static semantic_value global_result = 0;
   13407 static int global_count = 0;
   13408 %}
   13409 
   13410 /* Exercise %union. */
   13411 %union
   13412 {
   13413   semantic_value ival;
   13414 };
   13415 
   13416 %{
   13417 static int power (int base, int exponent);
   13418 /* yyerror receives the location if:
   13419    - %location & %pure & %glr
   13420    - %location & %pure & %yacc & %parse-param. */
   13421 static void yyerror (
   13422 
   13423                      const char *s
   13424                      );
   13425 static int yylex (void);
   13426 static int get_char (void);
   13427 static void unget_char ( int c);
   13428 %}
   13429 
   13430 
   13431 
   13432 /* Bison Declarations */
   13433 %token CALC_EOF 0 "end of input"
   13434 %token <ival> NUM "number"
   13435 %type  <ival> exp
   13436 
   13437 %nonassoc '=' /* comparison	       */
   13438 %left '-' '+'
   13439 %left '*' '/'
   13440 %left NEG     /* negation--unary minus */
   13441 %right '^'    /* exponentiation        */
   13442 
   13443 /* Grammar follows */
   13444 %%
   13445 input:
   13446   line
   13447 | input line         {  }
   13448 ;
   13449 
   13450 line:
   13451   '\n'
   13452 | exp '\n'           { USE ($1); }
   13453 ;
   13454 
   13455 exp:
   13456   NUM                { $$ = $1;             }
   13457 | exp '=' exp
   13458   {
   13459     if ($1 != $3)
   13460       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   13461     $$ = $1;
   13462   }
   13463 | exp '+' exp        { $$ = $1 + $3;        }
   13464 | exp '-' exp        { $$ = $1 - $3;        }
   13465 | exp '*' exp        { $$ = $1 * $3;        }
   13466 | exp '/' exp        { $$ = $1 / $3;        }
   13467 | '-' exp  %prec NEG { $$ = -$2;            }
   13468 | exp '^' exp        { $$ = power ($1, $3); }
   13469 | '(' exp ')'        { $$ = $2;             }
   13470 | '(' error ')'      { $$ = 1111;           }
   13471 | '!'                { $$ = 0; YYERROR;     }
   13472 | '-' error          { $$ = 0; YYERROR;     }
   13473 ;
   13474 %%
   13475 /* The input.  */
   13476 static FILE *input;
   13477 
   13478 static void
   13479 yyerror (
   13480 
   13481          const char *s)
   13482 {
   13483 
   13484 
   13485   fprintf (stderr, "%d.%d",
   13486            (yylloc).first_line, (yylloc).first_column);
   13487   if ((yylloc).first_line != (yylloc).last_line)
   13488     fprintf (stderr, "-%d.%d",
   13489 	     (yylloc).last_line,  (yylloc).last_column - 1);
   13490   else if ((yylloc).first_column != (yylloc).last_column - 1)
   13491     fprintf (stderr, "-%d",
   13492 	     (yylloc).last_column - 1);
   13493   fprintf (stderr, ": ");
   13494   fprintf (stderr, "%s\n", s);
   13495 }
   13496 
   13497 
   13498 
   13499 static YYLTYPE last_yylloc;
   13500 
   13501 static int
   13502 get_char (void)
   13503 {
   13504   int res = getc (input);
   13505   ;
   13506 
   13507   last_yylloc = (yylloc);
   13508   if (res == '\n')
   13509     {
   13510       (yylloc).last_line++;
   13511       (yylloc).last_column = 0;
   13512     }
   13513   else
   13514     (yylloc).last_column++;
   13515 
   13516   return res;
   13517 }
   13518 
   13519 
   13520 static void
   13521 unget_char ( int c)
   13522 {
   13523   ;
   13524 
   13525   /* Wrong when C == `\n'. */
   13526   (yylloc) = last_yylloc;
   13527 
   13528   ungetc (c, input);
   13529 }
   13530 
   13531 static int
   13532 read_signed_integer (void)
   13533 {
   13534   int c = get_char ();
   13535   int sign = 1;
   13536   int n = 0;
   13537 
   13538   ;
   13539   if (c == '-')
   13540     {
   13541       c = get_char ();
   13542       sign = -1;
   13543     }
   13544 
   13545   while (isdigit (c))
   13546     {
   13547       n = 10 * n + (c - '0');
   13548       c = get_char ();
   13549     }
   13550 
   13551   unget_char ( c);
   13552 
   13553   return sign * n;
   13554 }
   13555 
   13556 
   13557 
   13558 /*---------------------------------------------------------------.
   13559 | Lexical analyzer returns an integer on the stack and the token |
   13560 | NUM, or the ASCII character read if not a number.  Skips all   |
   13561 | blanks and tabs, returns 0 for EOF.                            |
   13562 `---------------------------------------------------------------*/
   13563 
   13564 static int
   13565 yylex (void)
   13566 {
   13567   static int init = 1;
   13568   int c;
   13569 
   13570   if (init)
   13571     {
   13572       init = 0;
   13573 
   13574       (yylloc).last_column = 0;
   13575       (yylloc).last_line = 1;
   13576 
   13577     }
   13578 
   13579 
   13580  (yylloc).first_column = (yylloc).last_column;
   13581   (yylloc).first_line   = (yylloc).last_line;
   13582 
   13583 
   13584   /* Skip white space.  */
   13585   while ((c = get_char ()) == ' ' || c == '\t')
   13586     {
   13587      (yylloc).first_column = (yylloc).last_column;
   13588       (yylloc).first_line   = (yylloc).last_line;
   13589 
   13590     }
   13591 
   13592   /* process numbers   */
   13593   if (c == '.' || isdigit (c))
   13594     {
   13595       unget_char ( c);
   13596       (yylval).ival = read_signed_integer ();
   13597       return NUM;
   13598     }
   13599 
   13600   /* Return end-of-file.  */
   13601   if (c == EOF)
   13602     return CALC_EOF;
   13603 
   13604   /* Return single chars. */
   13605   return c;
   13606 }
   13607 
   13608 static int
   13609 power (int base, int exponent)
   13610 {
   13611   int res = 1;
   13612   if (exponent < 0)
   13613     exit (3);
   13614   for (/* Niente */; exponent; --exponent)
   13615     res *= base;
   13616   return res;
   13617 }
   13618 
   13619 
   13620 int
   13621 main (int argc, const char **argv)
   13622 {
   13623   semantic_value result = 0;
   13624   int count = 0;
   13625   int status;
   13626 
   13627   /* This used to be alarm (10), but that isn't enough time for
   13628      a July 1995 vintage DEC Alphastation 200 4/100 system,
   13629      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   13630   alarm (100);
   13631 
   13632   if (argc == 2)
   13633     input = fopen (argv[1], "r");
   13634   else
   13635     input = stdin;
   13636 
   13637   if (!input)
   13638     {
   13639       perror (argv[1]);
   13640       return 3;
   13641     }
   13642 
   13643 
   13644   status = yyparse ();
   13645   if (global_result != result)
   13646     abort ();
   13647   if (global_count != count)
   13648     abort ();
   13649   return status;
   13650 }
   13651 _ATEOF
   13652 
   13653 
   13654 
   13655 
   13656 
   13657 $at_traceoff
   13658 echo "calc.at:553: bison -o calc.c calc.y"
   13659 echo calc.at:553 >$at_check_line_file
   13660 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   13661 at_status=$?
   13662 grep '^ *+' $at_stder1 >&2
   13663 grep -v '^ *+' $at_stder1 >$at_stderr
   13664 at_failed=false
   13665 $at_diff $at_devnull $at_stderr || at_failed=:
   13666 $at_diff $at_devnull $at_stdout || at_failed=:
   13667 case $at_status in
   13668    77) echo 77 > $at_status_file
   13669             exit 77;;
   13670    0) ;;
   13671    *) echo "calc.at:553: exit code was $at_status, expected 0"
   13672       at_failed=:;;
   13673 esac
   13674 if $at_failed; then
   13675 
   13676   echo 1 > $at_status_file
   13677   exit 1
   13678 fi
   13679 
   13680 $at_traceon
   13681 
   13682    $at_traceoff
   13683 echo "calc.at:553: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   13684 echo calc.at:553 >$at_check_line_file
   13685 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   13686 at_status=$?
   13687 grep '^ *+' $at_stder1 >&2
   13688 grep -v '^ *+' $at_stder1 >$at_stderr
   13689 at_failed=false
   13690 echo stderr:; cat $at_stderr
   13691 echo stdout:; cat $at_stdout
   13692 case $at_status in
   13693    77) echo 77 > $at_status_file
   13694             exit 77;;
   13695    0) ;;
   13696    *) echo "calc.at:553: exit code was $at_status, expected 0"
   13697       at_failed=:;;
   13698 esac
   13699 if $at_failed; then
   13700 
   13701   echo 1 > $at_status_file
   13702   exit 1
   13703 fi
   13704 
   13705 $at_traceon
   13706 
   13707 
   13708 # Test the priorities.
   13709 cat >input <<'_ATEOF'
   13710 1 + 2 * 3 = 7
   13711 1 + 2 * -3 = -5
   13712 
   13713 -1^2 = -1
   13714 (-1)^2 = 1
   13715 
   13716 ---1 = -1
   13717 
   13718 1 - 2 - 3 = -4
   13719 1 - (2 - 3) = 2
   13720 
   13721 2^2^3 = 256
   13722 (2^2)^3 = 64
   13723 _ATEOF
   13724 
   13725 $at_traceoff
   13726 echo "calc.at:553: \$PREPARSER ./calc input"
   13727 echo calc.at:553 >$at_check_line_file
   13728 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   13729 at_status=$?
   13730 grep '^ *+' $at_stder1 >&2
   13731 grep -v '^ *+' $at_stder1 >$at_stderr
   13732 at_failed=false
   13733 echo stderr:; tee stderr <$at_stderr
   13734 $at_diff $at_devnull $at_stdout || at_failed=:
   13735 case $at_status in
   13736    77) echo 77 > $at_status_file
   13737             exit 77;;
   13738    0) ;;
   13739    *) echo "calc.at:553: exit code was $at_status, expected 0"
   13740       at_failed=:;;
   13741 esac
   13742 if $at_failed; then
   13743 
   13744   echo 1 > $at_status_file
   13745   exit 1
   13746 fi
   13747 
   13748 $at_traceon
   13749 
   13750 
   13751 
   13752 # Some syntax errors.
   13753 cat >input <<'_ATEOF'
   13754 0 0
   13755 _ATEOF
   13756 
   13757 $at_traceoff
   13758 echo "calc.at:553: \$PREPARSER ./calc input"
   13759 echo calc.at:553 >$at_check_line_file
   13760 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   13761 at_status=$?
   13762 grep '^ *+' $at_stder1 >&2
   13763 grep -v '^ *+' $at_stder1 >$at_stderr
   13764 at_failed=false
   13765 echo stderr:; tee stderr <$at_stderr
   13766 $at_diff $at_devnull $at_stdout || at_failed=:
   13767 case $at_status in
   13768    77) echo 77 > $at_status_file
   13769             exit 77;;
   13770    1) ;;
   13771    *) echo "calc.at:553: exit code was $at_status, expected 1"
   13772       at_failed=:;;
   13773 esac
   13774 if $at_failed; then
   13775 
   13776   echo 1 > $at_status_file
   13777   exit 1
   13778 fi
   13779 
   13780 $at_traceon
   13781 
   13782 
   13783 # Normalize the observed and expected error messages, depending upon the
   13784 # options.
   13785 # 1. Remove the traces from observed.
   13786 sed '/^Starting/d
   13787 /^Entering/d
   13788 /^Stack/d
   13789 /^Reading/d
   13790 /^Reducing/d
   13791 /^Shifting/d
   13792 /^state/d
   13793 /^Cleanup:/d
   13794 /^Error:/d
   13795 /^Next/d
   13796 /^Discarding/d
   13797 / \$[0-9$]* = /d
   13798 /^yydestructor:/d' stderr >at-stderr
   13799 mv at-stderr stderr
   13800 # 2. Create the reference error message.
   13801 cat >expout <<'_ATEOF'
   13802 1.2: syntax error, unexpected number
   13803 _ATEOF
   13804 
   13805 # 3. If locations are not used, remove them.
   13806 
   13807 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   13808 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   13809 mv at-expout expout
   13810 # 5. Check
   13811 $at_traceoff
   13812 echo "calc.at:553: cat stderr"
   13813 echo calc.at:553 >$at_check_line_file
   13814 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   13815 at_status=$?
   13816 grep '^ *+' $at_stder1 >&2
   13817 grep -v '^ *+' $at_stder1 >$at_stderr
   13818 at_failed=false
   13819 $at_diff $at_devnull $at_stderr || at_failed=:
   13820 $at_diff expout $at_stdout || at_failed=:
   13821 case $at_status in
   13822    77) echo 77 > $at_status_file
   13823             exit 77;;
   13824    0) ;;
   13825    *) echo "calc.at:553: exit code was $at_status, expected 0"
   13826       at_failed=:;;
   13827 esac
   13828 if $at_failed; then
   13829 
   13830   echo 1 > $at_status_file
   13831   exit 1
   13832 fi
   13833 
   13834 $at_traceon
   13835 
   13836 
   13837 cat >input <<'_ATEOF'
   13838 1//2
   13839 _ATEOF
   13840 
   13841 $at_traceoff
   13842 echo "calc.at:553: \$PREPARSER ./calc input"
   13843 echo calc.at:553 >$at_check_line_file
   13844 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   13845 at_status=$?
   13846 grep '^ *+' $at_stder1 >&2
   13847 grep -v '^ *+' $at_stder1 >$at_stderr
   13848 at_failed=false
   13849 echo stderr:; tee stderr <$at_stderr
   13850 $at_diff $at_devnull $at_stdout || at_failed=:
   13851 case $at_status in
   13852    77) echo 77 > $at_status_file
   13853             exit 77;;
   13854    1) ;;
   13855    *) echo "calc.at:553: exit code was $at_status, expected 1"
   13856       at_failed=:;;
   13857 esac
   13858 if $at_failed; then
   13859 
   13860   echo 1 > $at_status_file
   13861   exit 1
   13862 fi
   13863 
   13864 $at_traceon
   13865 
   13866 
   13867 # Normalize the observed and expected error messages, depending upon the
   13868 # options.
   13869 # 1. Remove the traces from observed.
   13870 sed '/^Starting/d
   13871 /^Entering/d
   13872 /^Stack/d
   13873 /^Reading/d
   13874 /^Reducing/d
   13875 /^Shifting/d
   13876 /^state/d
   13877 /^Cleanup:/d
   13878 /^Error:/d
   13879 /^Next/d
   13880 /^Discarding/d
   13881 / \$[0-9$]* = /d
   13882 /^yydestructor:/d' stderr >at-stderr
   13883 mv at-stderr stderr
   13884 # 2. Create the reference error message.
   13885 cat >expout <<'_ATEOF'
   13886 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   13887 _ATEOF
   13888 
   13889 # 3. If locations are not used, remove them.
   13890 
   13891 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   13892 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   13893 mv at-expout expout
   13894 # 5. Check
   13895 $at_traceoff
   13896 echo "calc.at:553: cat stderr"
   13897 echo calc.at:553 >$at_check_line_file
   13898 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   13899 at_status=$?
   13900 grep '^ *+' $at_stder1 >&2
   13901 grep -v '^ *+' $at_stder1 >$at_stderr
   13902 at_failed=false
   13903 $at_diff $at_devnull $at_stderr || at_failed=:
   13904 $at_diff expout $at_stdout || at_failed=:
   13905 case $at_status in
   13906    77) echo 77 > $at_status_file
   13907             exit 77;;
   13908    0) ;;
   13909    *) echo "calc.at:553: exit code was $at_status, expected 0"
   13910       at_failed=:;;
   13911 esac
   13912 if $at_failed; then
   13913 
   13914   echo 1 > $at_status_file
   13915   exit 1
   13916 fi
   13917 
   13918 $at_traceon
   13919 
   13920 
   13921 cat >input <<'_ATEOF'
   13922 error
   13923 _ATEOF
   13924 
   13925 $at_traceoff
   13926 echo "calc.at:553: \$PREPARSER ./calc input"
   13927 echo calc.at:553 >$at_check_line_file
   13928 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   13929 at_status=$?
   13930 grep '^ *+' $at_stder1 >&2
   13931 grep -v '^ *+' $at_stder1 >$at_stderr
   13932 at_failed=false
   13933 echo stderr:; tee stderr <$at_stderr
   13934 $at_diff $at_devnull $at_stdout || at_failed=:
   13935 case $at_status in
   13936    77) echo 77 > $at_status_file
   13937             exit 77;;
   13938    1) ;;
   13939    *) echo "calc.at:553: exit code was $at_status, expected 1"
   13940       at_failed=:;;
   13941 esac
   13942 if $at_failed; then
   13943 
   13944   echo 1 > $at_status_file
   13945   exit 1
   13946 fi
   13947 
   13948 $at_traceon
   13949 
   13950 
   13951 # Normalize the observed and expected error messages, depending upon the
   13952 # options.
   13953 # 1. Remove the traces from observed.
   13954 sed '/^Starting/d
   13955 /^Entering/d
   13956 /^Stack/d
   13957 /^Reading/d
   13958 /^Reducing/d
   13959 /^Shifting/d
   13960 /^state/d
   13961 /^Cleanup:/d
   13962 /^Error:/d
   13963 /^Next/d
   13964 /^Discarding/d
   13965 / \$[0-9$]* = /d
   13966 /^yydestructor:/d' stderr >at-stderr
   13967 mv at-stderr stderr
   13968 # 2. Create the reference error message.
   13969 cat >expout <<'_ATEOF'
   13970 1.0: syntax error, unexpected $undefined
   13971 _ATEOF
   13972 
   13973 # 3. If locations are not used, remove them.
   13974 
   13975 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   13976 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   13977 mv at-expout expout
   13978 # 5. Check
   13979 $at_traceoff
   13980 echo "calc.at:553: cat stderr"
   13981 echo calc.at:553 >$at_check_line_file
   13982 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   13983 at_status=$?
   13984 grep '^ *+' $at_stder1 >&2
   13985 grep -v '^ *+' $at_stder1 >$at_stderr
   13986 at_failed=false
   13987 $at_diff $at_devnull $at_stderr || at_failed=:
   13988 $at_diff expout $at_stdout || at_failed=:
   13989 case $at_status in
   13990    77) echo 77 > $at_status_file
   13991             exit 77;;
   13992    0) ;;
   13993    *) echo "calc.at:553: exit code was $at_status, expected 0"
   13994       at_failed=:;;
   13995 esac
   13996 if $at_failed; then
   13997 
   13998   echo 1 > $at_status_file
   13999   exit 1
   14000 fi
   14001 
   14002 $at_traceon
   14003 
   14004 
   14005 cat >input <<'_ATEOF'
   14006 1 = 2 = 3
   14007 _ATEOF
   14008 
   14009 $at_traceoff
   14010 echo "calc.at:553: \$PREPARSER ./calc input"
   14011 echo calc.at:553 >$at_check_line_file
   14012 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   14013 at_status=$?
   14014 grep '^ *+' $at_stder1 >&2
   14015 grep -v '^ *+' $at_stder1 >$at_stderr
   14016 at_failed=false
   14017 echo stderr:; tee stderr <$at_stderr
   14018 $at_diff $at_devnull $at_stdout || at_failed=:
   14019 case $at_status in
   14020    77) echo 77 > $at_status_file
   14021             exit 77;;
   14022    1) ;;
   14023    *) echo "calc.at:553: exit code was $at_status, expected 1"
   14024       at_failed=:;;
   14025 esac
   14026 if $at_failed; then
   14027 
   14028   echo 1 > $at_status_file
   14029   exit 1
   14030 fi
   14031 
   14032 $at_traceon
   14033 
   14034 
   14035 # Normalize the observed and expected error messages, depending upon the
   14036 # options.
   14037 # 1. Remove the traces from observed.
   14038 sed '/^Starting/d
   14039 /^Entering/d
   14040 /^Stack/d
   14041 /^Reading/d
   14042 /^Reducing/d
   14043 /^Shifting/d
   14044 /^state/d
   14045 /^Cleanup:/d
   14046 /^Error:/d
   14047 /^Next/d
   14048 /^Discarding/d
   14049 / \$[0-9$]* = /d
   14050 /^yydestructor:/d' stderr >at-stderr
   14051 mv at-stderr stderr
   14052 # 2. Create the reference error message.
   14053 cat >expout <<'_ATEOF'
   14054 1.6: syntax error, unexpected '='
   14055 _ATEOF
   14056 
   14057 # 3. If locations are not used, remove them.
   14058 
   14059 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   14060 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   14061 mv at-expout expout
   14062 # 5. Check
   14063 $at_traceoff
   14064 echo "calc.at:553: cat stderr"
   14065 echo calc.at:553 >$at_check_line_file
   14066 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   14067 at_status=$?
   14068 grep '^ *+' $at_stder1 >&2
   14069 grep -v '^ *+' $at_stder1 >$at_stderr
   14070 at_failed=false
   14071 $at_diff $at_devnull $at_stderr || at_failed=:
   14072 $at_diff expout $at_stdout || at_failed=:
   14073 case $at_status in
   14074    77) echo 77 > $at_status_file
   14075             exit 77;;
   14076    0) ;;
   14077    *) echo "calc.at:553: exit code was $at_status, expected 0"
   14078       at_failed=:;;
   14079 esac
   14080 if $at_failed; then
   14081 
   14082   echo 1 > $at_status_file
   14083   exit 1
   14084 fi
   14085 
   14086 $at_traceon
   14087 
   14088 
   14089 cat >input <<'_ATEOF'
   14090 
   14091 +1
   14092 _ATEOF
   14093 
   14094 $at_traceoff
   14095 echo "calc.at:553: \$PREPARSER ./calc input"
   14096 echo calc.at:553 >$at_check_line_file
   14097 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   14098 at_status=$?
   14099 grep '^ *+' $at_stder1 >&2
   14100 grep -v '^ *+' $at_stder1 >$at_stderr
   14101 at_failed=false
   14102 echo stderr:; tee stderr <$at_stderr
   14103 $at_diff $at_devnull $at_stdout || at_failed=:
   14104 case $at_status in
   14105    77) echo 77 > $at_status_file
   14106             exit 77;;
   14107    1) ;;
   14108    *) echo "calc.at:553: exit code was $at_status, expected 1"
   14109       at_failed=:;;
   14110 esac
   14111 if $at_failed; then
   14112 
   14113   echo 1 > $at_status_file
   14114   exit 1
   14115 fi
   14116 
   14117 $at_traceon
   14118 
   14119 
   14120 # Normalize the observed and expected error messages, depending upon the
   14121 # options.
   14122 # 1. Remove the traces from observed.
   14123 sed '/^Starting/d
   14124 /^Entering/d
   14125 /^Stack/d
   14126 /^Reading/d
   14127 /^Reducing/d
   14128 /^Shifting/d
   14129 /^state/d
   14130 /^Cleanup:/d
   14131 /^Error:/d
   14132 /^Next/d
   14133 /^Discarding/d
   14134 / \$[0-9$]* = /d
   14135 /^yydestructor:/d' stderr >at-stderr
   14136 mv at-stderr stderr
   14137 # 2. Create the reference error message.
   14138 cat >expout <<'_ATEOF'
   14139 2.0: syntax error, unexpected '+'
   14140 _ATEOF
   14141 
   14142 # 3. If locations are not used, remove them.
   14143 
   14144 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   14145 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   14146 mv at-expout expout
   14147 # 5. Check
   14148 $at_traceoff
   14149 echo "calc.at:553: cat stderr"
   14150 echo calc.at:553 >$at_check_line_file
   14151 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   14152 at_status=$?
   14153 grep '^ *+' $at_stder1 >&2
   14154 grep -v '^ *+' $at_stder1 >$at_stderr
   14155 at_failed=false
   14156 $at_diff $at_devnull $at_stderr || at_failed=:
   14157 $at_diff expout $at_stdout || at_failed=:
   14158 case $at_status in
   14159    77) echo 77 > $at_status_file
   14160             exit 77;;
   14161    0) ;;
   14162    *) echo "calc.at:553: exit code was $at_status, expected 0"
   14163       at_failed=:;;
   14164 esac
   14165 if $at_failed; then
   14166 
   14167   echo 1 > $at_status_file
   14168   exit 1
   14169 fi
   14170 
   14171 $at_traceon
   14172 
   14173 
   14174 # Exercise error messages with EOF: work on an empty file.
   14175 $at_traceoff
   14176 echo "calc.at:553: \$PREPARSER ./calc /dev/null"
   14177 echo calc.at:553 >$at_check_line_file
   14178 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   14179 at_status=$?
   14180 grep '^ *+' $at_stder1 >&2
   14181 grep -v '^ *+' $at_stder1 >$at_stderr
   14182 at_failed=false
   14183 echo stderr:; tee stderr <$at_stderr
   14184 $at_diff $at_devnull $at_stdout || at_failed=:
   14185 case $at_status in
   14186    77) echo 77 > $at_status_file
   14187             exit 77;;
   14188    1) ;;
   14189    *) echo "calc.at:553: exit code was $at_status, expected 1"
   14190       at_failed=:;;
   14191 esac
   14192 if $at_failed; then
   14193 
   14194   echo 1 > $at_status_file
   14195   exit 1
   14196 fi
   14197 
   14198 $at_traceon
   14199 
   14200 
   14201 # Normalize the observed and expected error messages, depending upon the
   14202 # options.
   14203 # 1. Remove the traces from observed.
   14204 sed '/^Starting/d
   14205 /^Entering/d
   14206 /^Stack/d
   14207 /^Reading/d
   14208 /^Reducing/d
   14209 /^Shifting/d
   14210 /^state/d
   14211 /^Cleanup:/d
   14212 /^Error:/d
   14213 /^Next/d
   14214 /^Discarding/d
   14215 / \$[0-9$]* = /d
   14216 /^yydestructor:/d' stderr >at-stderr
   14217 mv at-stderr stderr
   14218 # 2. Create the reference error message.
   14219 cat >expout <<'_ATEOF'
   14220 1.0: syntax error, unexpected end of input
   14221 _ATEOF
   14222 
   14223 # 3. If locations are not used, remove them.
   14224 
   14225 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   14226 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   14227 mv at-expout expout
   14228 # 5. Check
   14229 $at_traceoff
   14230 echo "calc.at:553: cat stderr"
   14231 echo calc.at:553 >$at_check_line_file
   14232 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   14233 at_status=$?
   14234 grep '^ *+' $at_stder1 >&2
   14235 grep -v '^ *+' $at_stder1 >$at_stderr
   14236 at_failed=false
   14237 $at_diff $at_devnull $at_stderr || at_failed=:
   14238 $at_diff expout $at_stdout || at_failed=:
   14239 case $at_status in
   14240    77) echo 77 > $at_status_file
   14241             exit 77;;
   14242    0) ;;
   14243    *) echo "calc.at:553: exit code was $at_status, expected 0"
   14244       at_failed=:;;
   14245 esac
   14246 if $at_failed; then
   14247 
   14248   echo 1 > $at_status_file
   14249   exit 1
   14250 fi
   14251 
   14252 $at_traceon
   14253 
   14254 
   14255 
   14256 # Exercise the error token: without it, we die at the first error,
   14257 # hence be sure to
   14258 #
   14259 # - have several errors which exercise different shift/discardings
   14260 #   - (): nothing to pop, nothing to discard
   14261 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   14262 #   - (* * *): nothing to pop, a lot to discard
   14263 #   - (1 + 2 * *): some to pop and discard
   14264 #
   14265 # - test the action associated to `error'
   14266 #
   14267 # - check the look-ahead that triggers an error is not discarded
   14268 #   when we enter error recovery.  Below, the look-ahead causing the
   14269 #   first error is ")", which is needed to recover from the error and
   14270 #   produce the "0" that triggers the "0 != 1" error.
   14271 #
   14272 cat >input <<'_ATEOF'
   14273 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   14274 _ATEOF
   14275 
   14276 $at_traceoff
   14277 echo "calc.at:553: \$PREPARSER ./calc input"
   14278 echo calc.at:553 >$at_check_line_file
   14279 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   14280 at_status=$?
   14281 grep '^ *+' $at_stder1 >&2
   14282 grep -v '^ *+' $at_stder1 >$at_stderr
   14283 at_failed=false
   14284 echo stderr:; tee stderr <$at_stderr
   14285 $at_diff $at_devnull $at_stdout || at_failed=:
   14286 case $at_status in
   14287    77) echo 77 > $at_status_file
   14288             exit 77;;
   14289    0) ;;
   14290    *) echo "calc.at:553: exit code was $at_status, expected 0"
   14291       at_failed=:;;
   14292 esac
   14293 if $at_failed; then
   14294 
   14295   echo 1 > $at_status_file
   14296   exit 1
   14297 fi
   14298 
   14299 $at_traceon
   14300 
   14301 
   14302 # Normalize the observed and expected error messages, depending upon the
   14303 # options.
   14304 # 1. Remove the traces from observed.
   14305 sed '/^Starting/d
   14306 /^Entering/d
   14307 /^Stack/d
   14308 /^Reading/d
   14309 /^Reducing/d
   14310 /^Shifting/d
   14311 /^state/d
   14312 /^Cleanup:/d
   14313 /^Error:/d
   14314 /^Next/d
   14315 /^Discarding/d
   14316 / \$[0-9$]* = /d
   14317 /^yydestructor:/d' stderr >at-stderr
   14318 mv at-stderr stderr
   14319 # 2. Create the reference error message.
   14320 cat >expout <<'_ATEOF'
   14321 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   14322 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   14323 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   14324 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   14325 calc: error: 4444 != 1
   14326 _ATEOF
   14327 
   14328 # 3. If locations are not used, remove them.
   14329 
   14330 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   14331 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   14332 mv at-expout expout
   14333 # 5. Check
   14334 $at_traceoff
   14335 echo "calc.at:553: cat stderr"
   14336 echo calc.at:553 >$at_check_line_file
   14337 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   14338 at_status=$?
   14339 grep '^ *+' $at_stder1 >&2
   14340 grep -v '^ *+' $at_stder1 >$at_stderr
   14341 at_failed=false
   14342 $at_diff $at_devnull $at_stderr || at_failed=:
   14343 $at_diff expout $at_stdout || at_failed=:
   14344 case $at_status in
   14345    77) echo 77 > $at_status_file
   14346             exit 77;;
   14347    0) ;;
   14348    *) echo "calc.at:553: exit code was $at_status, expected 0"
   14349       at_failed=:;;
   14350 esac
   14351 if $at_failed; then
   14352 
   14353   echo 1 > $at_status_file
   14354   exit 1
   14355 fi
   14356 
   14357 $at_traceon
   14358 
   14359 
   14360 
   14361 # The same, but this time exercising explicitly triggered syntax errors.
   14362 # POSIX says the look-ahead causing the error should not be discarded.
   14363 cat >input <<'_ATEOF'
   14364 (!) + (0 0) = 1
   14365 _ATEOF
   14366 
   14367 $at_traceoff
   14368 echo "calc.at:553: \$PREPARSER ./calc input"
   14369 echo calc.at:553 >$at_check_line_file
   14370 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   14371 at_status=$?
   14372 grep '^ *+' $at_stder1 >&2
   14373 grep -v '^ *+' $at_stder1 >$at_stderr
   14374 at_failed=false
   14375 echo stderr:; tee stderr <$at_stderr
   14376 $at_diff $at_devnull $at_stdout || at_failed=:
   14377 case $at_status in
   14378    77) echo 77 > $at_status_file
   14379             exit 77;;
   14380    0) ;;
   14381    *) echo "calc.at:553: exit code was $at_status, expected 0"
   14382       at_failed=:;;
   14383 esac
   14384 if $at_failed; then
   14385 
   14386   echo 1 > $at_status_file
   14387   exit 1
   14388 fi
   14389 
   14390 $at_traceon
   14391 
   14392 
   14393 # Normalize the observed and expected error messages, depending upon the
   14394 # options.
   14395 # 1. Remove the traces from observed.
   14396 sed '/^Starting/d
   14397 /^Entering/d
   14398 /^Stack/d
   14399 /^Reading/d
   14400 /^Reducing/d
   14401 /^Shifting/d
   14402 /^state/d
   14403 /^Cleanup:/d
   14404 /^Error:/d
   14405 /^Next/d
   14406 /^Discarding/d
   14407 / \$[0-9$]* = /d
   14408 /^yydestructor:/d' stderr >at-stderr
   14409 mv at-stderr stderr
   14410 # 2. Create the reference error message.
   14411 cat >expout <<'_ATEOF'
   14412 1.9: syntax error, unexpected number
   14413 calc: error: 2222 != 1
   14414 _ATEOF
   14415 
   14416 # 3. If locations are not used, remove them.
   14417 
   14418 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   14419 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   14420 mv at-expout expout
   14421 # 5. Check
   14422 $at_traceoff
   14423 echo "calc.at:553: cat stderr"
   14424 echo calc.at:553 >$at_check_line_file
   14425 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   14426 at_status=$?
   14427 grep '^ *+' $at_stder1 >&2
   14428 grep -v '^ *+' $at_stder1 >$at_stderr
   14429 at_failed=false
   14430 $at_diff $at_devnull $at_stderr || at_failed=:
   14431 $at_diff expout $at_stdout || at_failed=:
   14432 case $at_status in
   14433    77) echo 77 > $at_status_file
   14434             exit 77;;
   14435    0) ;;
   14436    *) echo "calc.at:553: exit code was $at_status, expected 0"
   14437       at_failed=:;;
   14438 esac
   14439 if $at_failed; then
   14440 
   14441   echo 1 > $at_status_file
   14442   exit 1
   14443 fi
   14444 
   14445 $at_traceon
   14446 
   14447 
   14448 cat >input <<'_ATEOF'
   14449 (- *) + (0 0) = 1
   14450 _ATEOF
   14451 
   14452 $at_traceoff
   14453 echo "calc.at:553: \$PREPARSER ./calc input"
   14454 echo calc.at:553 >$at_check_line_file
   14455 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   14456 at_status=$?
   14457 grep '^ *+' $at_stder1 >&2
   14458 grep -v '^ *+' $at_stder1 >$at_stderr
   14459 at_failed=false
   14460 echo stderr:; tee stderr <$at_stderr
   14461 $at_diff $at_devnull $at_stdout || at_failed=:
   14462 case $at_status in
   14463    77) echo 77 > $at_status_file
   14464             exit 77;;
   14465    0) ;;
   14466    *) echo "calc.at:553: exit code was $at_status, expected 0"
   14467       at_failed=:;;
   14468 esac
   14469 if $at_failed; then
   14470 
   14471   echo 1 > $at_status_file
   14472   exit 1
   14473 fi
   14474 
   14475 $at_traceon
   14476 
   14477 
   14478 # Normalize the observed and expected error messages, depending upon the
   14479 # options.
   14480 # 1. Remove the traces from observed.
   14481 sed '/^Starting/d
   14482 /^Entering/d
   14483 /^Stack/d
   14484 /^Reading/d
   14485 /^Reducing/d
   14486 /^Shifting/d
   14487 /^state/d
   14488 /^Cleanup:/d
   14489 /^Error:/d
   14490 /^Next/d
   14491 /^Discarding/d
   14492 / \$[0-9$]* = /d
   14493 /^yydestructor:/d' stderr >at-stderr
   14494 mv at-stderr stderr
   14495 # 2. Create the reference error message.
   14496 cat >expout <<'_ATEOF'
   14497 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   14498 1.11: syntax error, unexpected number
   14499 calc: error: 2222 != 1
   14500 _ATEOF
   14501 
   14502 # 3. If locations are not used, remove them.
   14503 
   14504 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   14505 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   14506 mv at-expout expout
   14507 # 5. Check
   14508 $at_traceoff
   14509 echo "calc.at:553: cat stderr"
   14510 echo calc.at:553 >$at_check_line_file
   14511 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   14512 at_status=$?
   14513 grep '^ *+' $at_stder1 >&2
   14514 grep -v '^ *+' $at_stder1 >$at_stderr
   14515 at_failed=false
   14516 $at_diff $at_devnull $at_stderr || at_failed=:
   14517 $at_diff expout $at_stdout || at_failed=:
   14518 case $at_status in
   14519    77) echo 77 > $at_status_file
   14520             exit 77;;
   14521    0) ;;
   14522    *) echo "calc.at:553: exit code was $at_status, expected 0"
   14523       at_failed=:;;
   14524 esac
   14525 if $at_failed; then
   14526 
   14527   echo 1 > $at_status_file
   14528   exit 1
   14529 fi
   14530 
   14531 $at_traceon
   14532 
   14533 
   14534 
   14535 
   14536 
   14537 
   14538 
   14539 
   14540 
   14541 
   14542 
   14543 
   14544 
   14545 
   14546 
   14547 
   14548 
   14549 
   14550 
   14551 
   14552 
   14553 
   14554 
   14555 
   14556       $at_traceoff
   14557       $at_times_p && times >$at_times_file
   14558     ) 5>&1 2>&1 | eval $at_tee_pipe
   14559     at_status=`cat $at_status_file`
   14560     ;;
   14561 
   14562   73 ) # 73. calc.at:554: Calculator %name-prefix="calc"
   14563     at_setup_line='calc.at:554'
   14564     at_desc='Calculator %name-prefix="calc"'
   14565     $at_quiet $ECHO_N " 73: Calculator %name-prefix="calc"               $ECHO_C"
   14566     at_xfail=no
   14567     (
   14568       echo "73. calc.at:554: testing ..."
   14569       $at_traceon
   14570 
   14571 
   14572 
   14573 
   14574 
   14575 
   14576 
   14577 
   14578 # Using yacc.c?
   14579 
   14580 
   14581 
   14582 
   14583 
   14584 
   14585 
   14586 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   14587 
   14588 # yyerror always sees the locations (when activated), except if
   14589 # yacc & pure & !param.
   14590 
   14591 
   14592 # The interface is pure: either because %pure-parser, or because we
   14593 # are using the C++ parsers.
   14594 
   14595 
   14596 
   14597 
   14598 
   14599 
   14600 
   14601 
   14602 
   14603 
   14604 
   14605 
   14606 cat >calc.y <<'_ATEOF'
   14607 %{
   14608 #ifdef HAVE_CONFIG_H
   14609 # include <config.h>
   14610   /* We don't need perfect functions for these tests. */
   14611 # undef malloc
   14612 # undef memcmp
   14613 # undef realloc
   14614 #endif
   14615 %}
   14616 
   14617 /* Infix notation calculator--calc */
   14618 %name-prefix="calc"
   14619 
   14620 %{
   14621 #include <stdio.h>
   14622 
   14623 #include <stdlib.h>
   14624 #include <string.h>
   14625 #if HAVE_UNISTD_H
   14626 # include <unistd.h>
   14627 #else
   14628 # undef alarm
   14629 # define alarm(seconds) /* empty */
   14630 #endif
   14631 #include <ctype.h>
   14632 #define USE(Var)
   14633 
   14634 /* Exercise pre-prologue dependency to %union.  */
   14635 typedef int semantic_value;
   14636 
   14637 static semantic_value global_result = 0;
   14638 static int global_count = 0;
   14639 %}
   14640 
   14641 /* Exercise %union. */
   14642 %union
   14643 {
   14644   semantic_value ival;
   14645 };
   14646 
   14647 %{
   14648 static int power (int base, int exponent);
   14649 /* yyerror receives the location if:
   14650    - %location & %pure & %glr
   14651    - %location & %pure & %yacc & %parse-param. */
   14652 static void yyerror (
   14653 
   14654                      const char *s
   14655                      );
   14656 static int yylex (void);
   14657 static int get_char (void);
   14658 static void unget_char ( int c);
   14659 %}
   14660 
   14661 
   14662 
   14663 /* Bison Declarations */
   14664 %token CALC_EOF 0 "end of input"
   14665 %token <ival> NUM "number"
   14666 %type  <ival> exp
   14667 
   14668 %nonassoc '=' /* comparison	       */
   14669 %left '-' '+'
   14670 %left '*' '/'
   14671 %left NEG     /* negation--unary minus */
   14672 %right '^'    /* exponentiation        */
   14673 
   14674 /* Grammar follows */
   14675 %%
   14676 input:
   14677   line
   14678 | input line         {  }
   14679 ;
   14680 
   14681 line:
   14682   '\n'
   14683 | exp '\n'           { USE ($1); }
   14684 ;
   14685 
   14686 exp:
   14687   NUM                { $$ = $1;             }
   14688 | exp '=' exp
   14689   {
   14690     if ($1 != $3)
   14691       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   14692     $$ = $1;
   14693   }
   14694 | exp '+' exp        { $$ = $1 + $3;        }
   14695 | exp '-' exp        { $$ = $1 - $3;        }
   14696 | exp '*' exp        { $$ = $1 * $3;        }
   14697 | exp '/' exp        { $$ = $1 / $3;        }
   14698 | '-' exp  %prec NEG { $$ = -$2;            }
   14699 | exp '^' exp        { $$ = power ($1, $3); }
   14700 | '(' exp ')'        { $$ = $2;             }
   14701 | '(' error ')'      { $$ = 1111;           }
   14702 | '!'                { $$ = 0; YYERROR;     }
   14703 | '-' error          { $$ = 0; YYERROR;     }
   14704 ;
   14705 %%
   14706 /* The input.  */
   14707 static FILE *input;
   14708 
   14709 static void
   14710 yyerror (
   14711 
   14712          const char *s)
   14713 {
   14714 
   14715 
   14716   fprintf (stderr, "%s\n", s);
   14717 }
   14718 
   14719 
   14720 
   14721 static int
   14722 get_char (void)
   14723 {
   14724   int res = getc (input);
   14725   ;
   14726 
   14727   return res;
   14728 }
   14729 
   14730 
   14731 static void
   14732 unget_char ( int c)
   14733 {
   14734   ;
   14735 
   14736   ungetc (c, input);
   14737 }
   14738 
   14739 static int
   14740 read_signed_integer (void)
   14741 {
   14742   int c = get_char ();
   14743   int sign = 1;
   14744   int n = 0;
   14745 
   14746   ;
   14747   if (c == '-')
   14748     {
   14749       c = get_char ();
   14750       sign = -1;
   14751     }
   14752 
   14753   while (isdigit (c))
   14754     {
   14755       n = 10 * n + (c - '0');
   14756       c = get_char ();
   14757     }
   14758 
   14759   unget_char ( c);
   14760 
   14761   return sign * n;
   14762 }
   14763 
   14764 
   14765 
   14766 /*---------------------------------------------------------------.
   14767 | Lexical analyzer returns an integer on the stack and the token |
   14768 | NUM, or the ASCII character read if not a number.  Skips all   |
   14769 | blanks and tabs, returns 0 for EOF.                            |
   14770 `---------------------------------------------------------------*/
   14771 
   14772 static int
   14773 yylex (void)
   14774 {
   14775   static int init = 1;
   14776   int c;
   14777 
   14778   if (init)
   14779     {
   14780       init = 0;
   14781 
   14782     }
   14783 
   14784 
   14785 
   14786   /* Skip white space.  */
   14787   while ((c = get_char ()) == ' ' || c == '\t')
   14788     {
   14789 
   14790     }
   14791 
   14792   /* process numbers   */
   14793   if (c == '.' || isdigit (c))
   14794     {
   14795       unget_char ( c);
   14796       (yylval).ival = read_signed_integer ();
   14797       return NUM;
   14798     }
   14799 
   14800   /* Return end-of-file.  */
   14801   if (c == EOF)
   14802     return CALC_EOF;
   14803 
   14804   /* Return single chars. */
   14805   return c;
   14806 }
   14807 
   14808 static int
   14809 power (int base, int exponent)
   14810 {
   14811   int res = 1;
   14812   if (exponent < 0)
   14813     exit (3);
   14814   for (/* Niente */; exponent; --exponent)
   14815     res *= base;
   14816   return res;
   14817 }
   14818 
   14819 
   14820 int
   14821 main (int argc, const char **argv)
   14822 {
   14823   semantic_value result = 0;
   14824   int count = 0;
   14825   int status;
   14826 
   14827   /* This used to be alarm (10), but that isn't enough time for
   14828      a July 1995 vintage DEC Alphastation 200 4/100 system,
   14829      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   14830   alarm (100);
   14831 
   14832   if (argc == 2)
   14833     input = fopen (argv[1], "r");
   14834   else
   14835     input = stdin;
   14836 
   14837   if (!input)
   14838     {
   14839       perror (argv[1]);
   14840       return 3;
   14841     }
   14842 
   14843 
   14844   status = yyparse ();
   14845   if (global_result != result)
   14846     abort ();
   14847   if (global_count != count)
   14848     abort ();
   14849   return status;
   14850 }
   14851 _ATEOF
   14852 
   14853 
   14854 
   14855 
   14856 
   14857 $at_traceoff
   14858 echo "calc.at:554: bison -o calc.c calc.y"
   14859 echo calc.at:554 >$at_check_line_file
   14860 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   14861 at_status=$?
   14862 grep '^ *+' $at_stder1 >&2
   14863 grep -v '^ *+' $at_stder1 >$at_stderr
   14864 at_failed=false
   14865 $at_diff $at_devnull $at_stderr || at_failed=:
   14866 $at_diff $at_devnull $at_stdout || at_failed=:
   14867 case $at_status in
   14868    77) echo 77 > $at_status_file
   14869             exit 77;;
   14870    0) ;;
   14871    *) echo "calc.at:554: exit code was $at_status, expected 0"
   14872       at_failed=:;;
   14873 esac
   14874 if $at_failed; then
   14875 
   14876   echo 1 > $at_status_file
   14877   exit 1
   14878 fi
   14879 
   14880 $at_traceon
   14881 
   14882    $at_traceoff
   14883 echo "calc.at:554: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   14884 echo calc.at:554 >$at_check_line_file
   14885 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   14886 at_status=$?
   14887 grep '^ *+' $at_stder1 >&2
   14888 grep -v '^ *+' $at_stder1 >$at_stderr
   14889 at_failed=false
   14890 echo stderr:; cat $at_stderr
   14891 echo stdout:; cat $at_stdout
   14892 case $at_status in
   14893    77) echo 77 > $at_status_file
   14894             exit 77;;
   14895    0) ;;
   14896    *) echo "calc.at:554: exit code was $at_status, expected 0"
   14897       at_failed=:;;
   14898 esac
   14899 if $at_failed; then
   14900 
   14901   echo 1 > $at_status_file
   14902   exit 1
   14903 fi
   14904 
   14905 $at_traceon
   14906 
   14907 
   14908 # Test the priorities.
   14909 cat >input <<'_ATEOF'
   14910 1 + 2 * 3 = 7
   14911 1 + 2 * -3 = -5
   14912 
   14913 -1^2 = -1
   14914 (-1)^2 = 1
   14915 
   14916 ---1 = -1
   14917 
   14918 1 - 2 - 3 = -4
   14919 1 - (2 - 3) = 2
   14920 
   14921 2^2^3 = 256
   14922 (2^2)^3 = 64
   14923 _ATEOF
   14924 
   14925 $at_traceoff
   14926 echo "calc.at:554: \$PREPARSER ./calc input"
   14927 echo calc.at:554 >$at_check_line_file
   14928 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   14929 at_status=$?
   14930 grep '^ *+' $at_stder1 >&2
   14931 grep -v '^ *+' $at_stder1 >$at_stderr
   14932 at_failed=false
   14933 echo stderr:; tee stderr <$at_stderr
   14934 $at_diff $at_devnull $at_stdout || at_failed=:
   14935 case $at_status in
   14936    77) echo 77 > $at_status_file
   14937             exit 77;;
   14938    0) ;;
   14939    *) echo "calc.at:554: exit code was $at_status, expected 0"
   14940       at_failed=:;;
   14941 esac
   14942 if $at_failed; then
   14943 
   14944   echo 1 > $at_status_file
   14945   exit 1
   14946 fi
   14947 
   14948 $at_traceon
   14949 
   14950 
   14951 
   14952 # Some syntax errors.
   14953 cat >input <<'_ATEOF'
   14954 0 0
   14955 _ATEOF
   14956 
   14957 $at_traceoff
   14958 echo "calc.at:554: \$PREPARSER ./calc input"
   14959 echo calc.at:554 >$at_check_line_file
   14960 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   14961 at_status=$?
   14962 grep '^ *+' $at_stder1 >&2
   14963 grep -v '^ *+' $at_stder1 >$at_stderr
   14964 at_failed=false
   14965 echo stderr:; tee stderr <$at_stderr
   14966 $at_diff $at_devnull $at_stdout || at_failed=:
   14967 case $at_status in
   14968    77) echo 77 > $at_status_file
   14969             exit 77;;
   14970    1) ;;
   14971    *) echo "calc.at:554: exit code was $at_status, expected 1"
   14972       at_failed=:;;
   14973 esac
   14974 if $at_failed; then
   14975 
   14976   echo 1 > $at_status_file
   14977   exit 1
   14978 fi
   14979 
   14980 $at_traceon
   14981 
   14982 
   14983 # Normalize the observed and expected error messages, depending upon the
   14984 # options.
   14985 # 1. Remove the traces from observed.
   14986 sed '/^Starting/d
   14987 /^Entering/d
   14988 /^Stack/d
   14989 /^Reading/d
   14990 /^Reducing/d
   14991 /^Shifting/d
   14992 /^state/d
   14993 /^Cleanup:/d
   14994 /^Error:/d
   14995 /^Next/d
   14996 /^Discarding/d
   14997 / \$[0-9$]* = /d
   14998 /^yydestructor:/d' stderr >at-stderr
   14999 mv at-stderr stderr
   15000 # 2. Create the reference error message.
   15001 cat >expout <<'_ATEOF'
   15002 1.2: syntax error, unexpected number
   15003 _ATEOF
   15004 
   15005 # 3. If locations are not used, remove them.
   15006 sed 's/^[-0-9.]*: //' expout >at-expout
   15007 mv at-expout expout
   15008 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   15009 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   15010 mv at-expout expout
   15011 # 5. Check
   15012 $at_traceoff
   15013 echo "calc.at:554: cat stderr"
   15014 echo calc.at:554 >$at_check_line_file
   15015 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   15016 at_status=$?
   15017 grep '^ *+' $at_stder1 >&2
   15018 grep -v '^ *+' $at_stder1 >$at_stderr
   15019 at_failed=false
   15020 $at_diff $at_devnull $at_stderr || at_failed=:
   15021 $at_diff expout $at_stdout || at_failed=:
   15022 case $at_status in
   15023    77) echo 77 > $at_status_file
   15024             exit 77;;
   15025    0) ;;
   15026    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15027       at_failed=:;;
   15028 esac
   15029 if $at_failed; then
   15030 
   15031   echo 1 > $at_status_file
   15032   exit 1
   15033 fi
   15034 
   15035 $at_traceon
   15036 
   15037 
   15038 cat >input <<'_ATEOF'
   15039 1//2
   15040 _ATEOF
   15041 
   15042 $at_traceoff
   15043 echo "calc.at:554: \$PREPARSER ./calc input"
   15044 echo calc.at:554 >$at_check_line_file
   15045 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   15046 at_status=$?
   15047 grep '^ *+' $at_stder1 >&2
   15048 grep -v '^ *+' $at_stder1 >$at_stderr
   15049 at_failed=false
   15050 echo stderr:; tee stderr <$at_stderr
   15051 $at_diff $at_devnull $at_stdout || at_failed=:
   15052 case $at_status in
   15053    77) echo 77 > $at_status_file
   15054             exit 77;;
   15055    1) ;;
   15056    *) echo "calc.at:554: exit code was $at_status, expected 1"
   15057       at_failed=:;;
   15058 esac
   15059 if $at_failed; then
   15060 
   15061   echo 1 > $at_status_file
   15062   exit 1
   15063 fi
   15064 
   15065 $at_traceon
   15066 
   15067 
   15068 # Normalize the observed and expected error messages, depending upon the
   15069 # options.
   15070 # 1. Remove the traces from observed.
   15071 sed '/^Starting/d
   15072 /^Entering/d
   15073 /^Stack/d
   15074 /^Reading/d
   15075 /^Reducing/d
   15076 /^Shifting/d
   15077 /^state/d
   15078 /^Cleanup:/d
   15079 /^Error:/d
   15080 /^Next/d
   15081 /^Discarding/d
   15082 / \$[0-9$]* = /d
   15083 /^yydestructor:/d' stderr >at-stderr
   15084 mv at-stderr stderr
   15085 # 2. Create the reference error message.
   15086 cat >expout <<'_ATEOF'
   15087 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   15088 _ATEOF
   15089 
   15090 # 3. If locations are not used, remove them.
   15091 sed 's/^[-0-9.]*: //' expout >at-expout
   15092 mv at-expout expout
   15093 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   15094 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   15095 mv at-expout expout
   15096 # 5. Check
   15097 $at_traceoff
   15098 echo "calc.at:554: cat stderr"
   15099 echo calc.at:554 >$at_check_line_file
   15100 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   15101 at_status=$?
   15102 grep '^ *+' $at_stder1 >&2
   15103 grep -v '^ *+' $at_stder1 >$at_stderr
   15104 at_failed=false
   15105 $at_diff $at_devnull $at_stderr || at_failed=:
   15106 $at_diff expout $at_stdout || at_failed=:
   15107 case $at_status in
   15108    77) echo 77 > $at_status_file
   15109             exit 77;;
   15110    0) ;;
   15111    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15112       at_failed=:;;
   15113 esac
   15114 if $at_failed; then
   15115 
   15116   echo 1 > $at_status_file
   15117   exit 1
   15118 fi
   15119 
   15120 $at_traceon
   15121 
   15122 
   15123 cat >input <<'_ATEOF'
   15124 error
   15125 _ATEOF
   15126 
   15127 $at_traceoff
   15128 echo "calc.at:554: \$PREPARSER ./calc input"
   15129 echo calc.at:554 >$at_check_line_file
   15130 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   15131 at_status=$?
   15132 grep '^ *+' $at_stder1 >&2
   15133 grep -v '^ *+' $at_stder1 >$at_stderr
   15134 at_failed=false
   15135 echo stderr:; tee stderr <$at_stderr
   15136 $at_diff $at_devnull $at_stdout || at_failed=:
   15137 case $at_status in
   15138    77) echo 77 > $at_status_file
   15139             exit 77;;
   15140    1) ;;
   15141    *) echo "calc.at:554: exit code was $at_status, expected 1"
   15142       at_failed=:;;
   15143 esac
   15144 if $at_failed; then
   15145 
   15146   echo 1 > $at_status_file
   15147   exit 1
   15148 fi
   15149 
   15150 $at_traceon
   15151 
   15152 
   15153 # Normalize the observed and expected error messages, depending upon the
   15154 # options.
   15155 # 1. Remove the traces from observed.
   15156 sed '/^Starting/d
   15157 /^Entering/d
   15158 /^Stack/d
   15159 /^Reading/d
   15160 /^Reducing/d
   15161 /^Shifting/d
   15162 /^state/d
   15163 /^Cleanup:/d
   15164 /^Error:/d
   15165 /^Next/d
   15166 /^Discarding/d
   15167 / \$[0-9$]* = /d
   15168 /^yydestructor:/d' stderr >at-stderr
   15169 mv at-stderr stderr
   15170 # 2. Create the reference error message.
   15171 cat >expout <<'_ATEOF'
   15172 1.0: syntax error, unexpected $undefined
   15173 _ATEOF
   15174 
   15175 # 3. If locations are not used, remove them.
   15176 sed 's/^[-0-9.]*: //' expout >at-expout
   15177 mv at-expout expout
   15178 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   15179 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   15180 mv at-expout expout
   15181 # 5. Check
   15182 $at_traceoff
   15183 echo "calc.at:554: cat stderr"
   15184 echo calc.at:554 >$at_check_line_file
   15185 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   15186 at_status=$?
   15187 grep '^ *+' $at_stder1 >&2
   15188 grep -v '^ *+' $at_stder1 >$at_stderr
   15189 at_failed=false
   15190 $at_diff $at_devnull $at_stderr || at_failed=:
   15191 $at_diff expout $at_stdout || at_failed=:
   15192 case $at_status in
   15193    77) echo 77 > $at_status_file
   15194             exit 77;;
   15195    0) ;;
   15196    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15197       at_failed=:;;
   15198 esac
   15199 if $at_failed; then
   15200 
   15201   echo 1 > $at_status_file
   15202   exit 1
   15203 fi
   15204 
   15205 $at_traceon
   15206 
   15207 
   15208 cat >input <<'_ATEOF'
   15209 1 = 2 = 3
   15210 _ATEOF
   15211 
   15212 $at_traceoff
   15213 echo "calc.at:554: \$PREPARSER ./calc input"
   15214 echo calc.at:554 >$at_check_line_file
   15215 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   15216 at_status=$?
   15217 grep '^ *+' $at_stder1 >&2
   15218 grep -v '^ *+' $at_stder1 >$at_stderr
   15219 at_failed=false
   15220 echo stderr:; tee stderr <$at_stderr
   15221 $at_diff $at_devnull $at_stdout || at_failed=:
   15222 case $at_status in
   15223    77) echo 77 > $at_status_file
   15224             exit 77;;
   15225    1) ;;
   15226    *) echo "calc.at:554: exit code was $at_status, expected 1"
   15227       at_failed=:;;
   15228 esac
   15229 if $at_failed; then
   15230 
   15231   echo 1 > $at_status_file
   15232   exit 1
   15233 fi
   15234 
   15235 $at_traceon
   15236 
   15237 
   15238 # Normalize the observed and expected error messages, depending upon the
   15239 # options.
   15240 # 1. Remove the traces from observed.
   15241 sed '/^Starting/d
   15242 /^Entering/d
   15243 /^Stack/d
   15244 /^Reading/d
   15245 /^Reducing/d
   15246 /^Shifting/d
   15247 /^state/d
   15248 /^Cleanup:/d
   15249 /^Error:/d
   15250 /^Next/d
   15251 /^Discarding/d
   15252 / \$[0-9$]* = /d
   15253 /^yydestructor:/d' stderr >at-stderr
   15254 mv at-stderr stderr
   15255 # 2. Create the reference error message.
   15256 cat >expout <<'_ATEOF'
   15257 1.6: syntax error, unexpected '='
   15258 _ATEOF
   15259 
   15260 # 3. If locations are not used, remove them.
   15261 sed 's/^[-0-9.]*: //' expout >at-expout
   15262 mv at-expout expout
   15263 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   15264 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   15265 mv at-expout expout
   15266 # 5. Check
   15267 $at_traceoff
   15268 echo "calc.at:554: cat stderr"
   15269 echo calc.at:554 >$at_check_line_file
   15270 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   15271 at_status=$?
   15272 grep '^ *+' $at_stder1 >&2
   15273 grep -v '^ *+' $at_stder1 >$at_stderr
   15274 at_failed=false
   15275 $at_diff $at_devnull $at_stderr || at_failed=:
   15276 $at_diff expout $at_stdout || at_failed=:
   15277 case $at_status in
   15278    77) echo 77 > $at_status_file
   15279             exit 77;;
   15280    0) ;;
   15281    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15282       at_failed=:;;
   15283 esac
   15284 if $at_failed; then
   15285 
   15286   echo 1 > $at_status_file
   15287   exit 1
   15288 fi
   15289 
   15290 $at_traceon
   15291 
   15292 
   15293 cat >input <<'_ATEOF'
   15294 
   15295 +1
   15296 _ATEOF
   15297 
   15298 $at_traceoff
   15299 echo "calc.at:554: \$PREPARSER ./calc input"
   15300 echo calc.at:554 >$at_check_line_file
   15301 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   15302 at_status=$?
   15303 grep '^ *+' $at_stder1 >&2
   15304 grep -v '^ *+' $at_stder1 >$at_stderr
   15305 at_failed=false
   15306 echo stderr:; tee stderr <$at_stderr
   15307 $at_diff $at_devnull $at_stdout || at_failed=:
   15308 case $at_status in
   15309    77) echo 77 > $at_status_file
   15310             exit 77;;
   15311    1) ;;
   15312    *) echo "calc.at:554: exit code was $at_status, expected 1"
   15313       at_failed=:;;
   15314 esac
   15315 if $at_failed; then
   15316 
   15317   echo 1 > $at_status_file
   15318   exit 1
   15319 fi
   15320 
   15321 $at_traceon
   15322 
   15323 
   15324 # Normalize the observed and expected error messages, depending upon the
   15325 # options.
   15326 # 1. Remove the traces from observed.
   15327 sed '/^Starting/d
   15328 /^Entering/d
   15329 /^Stack/d
   15330 /^Reading/d
   15331 /^Reducing/d
   15332 /^Shifting/d
   15333 /^state/d
   15334 /^Cleanup:/d
   15335 /^Error:/d
   15336 /^Next/d
   15337 /^Discarding/d
   15338 / \$[0-9$]* = /d
   15339 /^yydestructor:/d' stderr >at-stderr
   15340 mv at-stderr stderr
   15341 # 2. Create the reference error message.
   15342 cat >expout <<'_ATEOF'
   15343 2.0: syntax error, unexpected '+'
   15344 _ATEOF
   15345 
   15346 # 3. If locations are not used, remove them.
   15347 sed 's/^[-0-9.]*: //' expout >at-expout
   15348 mv at-expout expout
   15349 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   15350 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   15351 mv at-expout expout
   15352 # 5. Check
   15353 $at_traceoff
   15354 echo "calc.at:554: cat stderr"
   15355 echo calc.at:554 >$at_check_line_file
   15356 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   15357 at_status=$?
   15358 grep '^ *+' $at_stder1 >&2
   15359 grep -v '^ *+' $at_stder1 >$at_stderr
   15360 at_failed=false
   15361 $at_diff $at_devnull $at_stderr || at_failed=:
   15362 $at_diff expout $at_stdout || at_failed=:
   15363 case $at_status in
   15364    77) echo 77 > $at_status_file
   15365             exit 77;;
   15366    0) ;;
   15367    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15368       at_failed=:;;
   15369 esac
   15370 if $at_failed; then
   15371 
   15372   echo 1 > $at_status_file
   15373   exit 1
   15374 fi
   15375 
   15376 $at_traceon
   15377 
   15378 
   15379 # Exercise error messages with EOF: work on an empty file.
   15380 $at_traceoff
   15381 echo "calc.at:554: \$PREPARSER ./calc /dev/null"
   15382 echo calc.at:554 >$at_check_line_file
   15383 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   15384 at_status=$?
   15385 grep '^ *+' $at_stder1 >&2
   15386 grep -v '^ *+' $at_stder1 >$at_stderr
   15387 at_failed=false
   15388 echo stderr:; tee stderr <$at_stderr
   15389 $at_diff $at_devnull $at_stdout || at_failed=:
   15390 case $at_status in
   15391    77) echo 77 > $at_status_file
   15392             exit 77;;
   15393    1) ;;
   15394    *) echo "calc.at:554: exit code was $at_status, expected 1"
   15395       at_failed=:;;
   15396 esac
   15397 if $at_failed; then
   15398 
   15399   echo 1 > $at_status_file
   15400   exit 1
   15401 fi
   15402 
   15403 $at_traceon
   15404 
   15405 
   15406 # Normalize the observed and expected error messages, depending upon the
   15407 # options.
   15408 # 1. Remove the traces from observed.
   15409 sed '/^Starting/d
   15410 /^Entering/d
   15411 /^Stack/d
   15412 /^Reading/d
   15413 /^Reducing/d
   15414 /^Shifting/d
   15415 /^state/d
   15416 /^Cleanup:/d
   15417 /^Error:/d
   15418 /^Next/d
   15419 /^Discarding/d
   15420 / \$[0-9$]* = /d
   15421 /^yydestructor:/d' stderr >at-stderr
   15422 mv at-stderr stderr
   15423 # 2. Create the reference error message.
   15424 cat >expout <<'_ATEOF'
   15425 1.0: syntax error, unexpected end of input
   15426 _ATEOF
   15427 
   15428 # 3. If locations are not used, remove them.
   15429 sed 's/^[-0-9.]*: //' expout >at-expout
   15430 mv at-expout expout
   15431 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   15432 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   15433 mv at-expout expout
   15434 # 5. Check
   15435 $at_traceoff
   15436 echo "calc.at:554: cat stderr"
   15437 echo calc.at:554 >$at_check_line_file
   15438 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   15439 at_status=$?
   15440 grep '^ *+' $at_stder1 >&2
   15441 grep -v '^ *+' $at_stder1 >$at_stderr
   15442 at_failed=false
   15443 $at_diff $at_devnull $at_stderr || at_failed=:
   15444 $at_diff expout $at_stdout || at_failed=:
   15445 case $at_status in
   15446    77) echo 77 > $at_status_file
   15447             exit 77;;
   15448    0) ;;
   15449    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15450       at_failed=:;;
   15451 esac
   15452 if $at_failed; then
   15453 
   15454   echo 1 > $at_status_file
   15455   exit 1
   15456 fi
   15457 
   15458 $at_traceon
   15459 
   15460 
   15461 
   15462 # Exercise the error token: without it, we die at the first error,
   15463 # hence be sure to
   15464 #
   15465 # - have several errors which exercise different shift/discardings
   15466 #   - (): nothing to pop, nothing to discard
   15467 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   15468 #   - (* * *): nothing to pop, a lot to discard
   15469 #   - (1 + 2 * *): some to pop and discard
   15470 #
   15471 # - test the action associated to `error'
   15472 #
   15473 # - check the look-ahead that triggers an error is not discarded
   15474 #   when we enter error recovery.  Below, the look-ahead causing the
   15475 #   first error is ")", which is needed to recover from the error and
   15476 #   produce the "0" that triggers the "0 != 1" error.
   15477 #
   15478 cat >input <<'_ATEOF'
   15479 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   15480 _ATEOF
   15481 
   15482 $at_traceoff
   15483 echo "calc.at:554: \$PREPARSER ./calc input"
   15484 echo calc.at:554 >$at_check_line_file
   15485 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   15486 at_status=$?
   15487 grep '^ *+' $at_stder1 >&2
   15488 grep -v '^ *+' $at_stder1 >$at_stderr
   15489 at_failed=false
   15490 echo stderr:; tee stderr <$at_stderr
   15491 $at_diff $at_devnull $at_stdout || at_failed=:
   15492 case $at_status in
   15493    77) echo 77 > $at_status_file
   15494             exit 77;;
   15495    0) ;;
   15496    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15497       at_failed=:;;
   15498 esac
   15499 if $at_failed; then
   15500 
   15501   echo 1 > $at_status_file
   15502   exit 1
   15503 fi
   15504 
   15505 $at_traceon
   15506 
   15507 
   15508 # Normalize the observed and expected error messages, depending upon the
   15509 # options.
   15510 # 1. Remove the traces from observed.
   15511 sed '/^Starting/d
   15512 /^Entering/d
   15513 /^Stack/d
   15514 /^Reading/d
   15515 /^Reducing/d
   15516 /^Shifting/d
   15517 /^state/d
   15518 /^Cleanup:/d
   15519 /^Error:/d
   15520 /^Next/d
   15521 /^Discarding/d
   15522 / \$[0-9$]* = /d
   15523 /^yydestructor:/d' stderr >at-stderr
   15524 mv at-stderr stderr
   15525 # 2. Create the reference error message.
   15526 cat >expout <<'_ATEOF'
   15527 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   15528 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   15529 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   15530 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   15531 calc: error: 4444 != 1
   15532 _ATEOF
   15533 
   15534 # 3. If locations are not used, remove them.
   15535 sed 's/^[-0-9.]*: //' expout >at-expout
   15536 mv at-expout expout
   15537 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   15538 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   15539 mv at-expout expout
   15540 # 5. Check
   15541 $at_traceoff
   15542 echo "calc.at:554: cat stderr"
   15543 echo calc.at:554 >$at_check_line_file
   15544 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   15545 at_status=$?
   15546 grep '^ *+' $at_stder1 >&2
   15547 grep -v '^ *+' $at_stder1 >$at_stderr
   15548 at_failed=false
   15549 $at_diff $at_devnull $at_stderr || at_failed=:
   15550 $at_diff expout $at_stdout || at_failed=:
   15551 case $at_status in
   15552    77) echo 77 > $at_status_file
   15553             exit 77;;
   15554    0) ;;
   15555    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15556       at_failed=:;;
   15557 esac
   15558 if $at_failed; then
   15559 
   15560   echo 1 > $at_status_file
   15561   exit 1
   15562 fi
   15563 
   15564 $at_traceon
   15565 
   15566 
   15567 
   15568 # The same, but this time exercising explicitly triggered syntax errors.
   15569 # POSIX says the look-ahead causing the error should not be discarded.
   15570 cat >input <<'_ATEOF'
   15571 (!) + (0 0) = 1
   15572 _ATEOF
   15573 
   15574 $at_traceoff
   15575 echo "calc.at:554: \$PREPARSER ./calc input"
   15576 echo calc.at:554 >$at_check_line_file
   15577 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   15578 at_status=$?
   15579 grep '^ *+' $at_stder1 >&2
   15580 grep -v '^ *+' $at_stder1 >$at_stderr
   15581 at_failed=false
   15582 echo stderr:; tee stderr <$at_stderr
   15583 $at_diff $at_devnull $at_stdout || at_failed=:
   15584 case $at_status in
   15585    77) echo 77 > $at_status_file
   15586             exit 77;;
   15587    0) ;;
   15588    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15589       at_failed=:;;
   15590 esac
   15591 if $at_failed; then
   15592 
   15593   echo 1 > $at_status_file
   15594   exit 1
   15595 fi
   15596 
   15597 $at_traceon
   15598 
   15599 
   15600 # Normalize the observed and expected error messages, depending upon the
   15601 # options.
   15602 # 1. Remove the traces from observed.
   15603 sed '/^Starting/d
   15604 /^Entering/d
   15605 /^Stack/d
   15606 /^Reading/d
   15607 /^Reducing/d
   15608 /^Shifting/d
   15609 /^state/d
   15610 /^Cleanup:/d
   15611 /^Error:/d
   15612 /^Next/d
   15613 /^Discarding/d
   15614 / \$[0-9$]* = /d
   15615 /^yydestructor:/d' stderr >at-stderr
   15616 mv at-stderr stderr
   15617 # 2. Create the reference error message.
   15618 cat >expout <<'_ATEOF'
   15619 1.9: syntax error, unexpected number
   15620 calc: error: 2222 != 1
   15621 _ATEOF
   15622 
   15623 # 3. If locations are not used, remove them.
   15624 sed 's/^[-0-9.]*: //' expout >at-expout
   15625 mv at-expout expout
   15626 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   15627 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   15628 mv at-expout expout
   15629 # 5. Check
   15630 $at_traceoff
   15631 echo "calc.at:554: cat stderr"
   15632 echo calc.at:554 >$at_check_line_file
   15633 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   15634 at_status=$?
   15635 grep '^ *+' $at_stder1 >&2
   15636 grep -v '^ *+' $at_stder1 >$at_stderr
   15637 at_failed=false
   15638 $at_diff $at_devnull $at_stderr || at_failed=:
   15639 $at_diff expout $at_stdout || at_failed=:
   15640 case $at_status in
   15641    77) echo 77 > $at_status_file
   15642             exit 77;;
   15643    0) ;;
   15644    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15645       at_failed=:;;
   15646 esac
   15647 if $at_failed; then
   15648 
   15649   echo 1 > $at_status_file
   15650   exit 1
   15651 fi
   15652 
   15653 $at_traceon
   15654 
   15655 
   15656 cat >input <<'_ATEOF'
   15657 (- *) + (0 0) = 1
   15658 _ATEOF
   15659 
   15660 $at_traceoff
   15661 echo "calc.at:554: \$PREPARSER ./calc input"
   15662 echo calc.at:554 >$at_check_line_file
   15663 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   15664 at_status=$?
   15665 grep '^ *+' $at_stder1 >&2
   15666 grep -v '^ *+' $at_stder1 >$at_stderr
   15667 at_failed=false
   15668 echo stderr:; tee stderr <$at_stderr
   15669 $at_diff $at_devnull $at_stdout || at_failed=:
   15670 case $at_status in
   15671    77) echo 77 > $at_status_file
   15672             exit 77;;
   15673    0) ;;
   15674    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15675       at_failed=:;;
   15676 esac
   15677 if $at_failed; then
   15678 
   15679   echo 1 > $at_status_file
   15680   exit 1
   15681 fi
   15682 
   15683 $at_traceon
   15684 
   15685 
   15686 # Normalize the observed and expected error messages, depending upon the
   15687 # options.
   15688 # 1. Remove the traces from observed.
   15689 sed '/^Starting/d
   15690 /^Entering/d
   15691 /^Stack/d
   15692 /^Reading/d
   15693 /^Reducing/d
   15694 /^Shifting/d
   15695 /^state/d
   15696 /^Cleanup:/d
   15697 /^Error:/d
   15698 /^Next/d
   15699 /^Discarding/d
   15700 / \$[0-9$]* = /d
   15701 /^yydestructor:/d' stderr >at-stderr
   15702 mv at-stderr stderr
   15703 # 2. Create the reference error message.
   15704 cat >expout <<'_ATEOF'
   15705 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   15706 1.11: syntax error, unexpected number
   15707 calc: error: 2222 != 1
   15708 _ATEOF
   15709 
   15710 # 3. If locations are not used, remove them.
   15711 sed 's/^[-0-9.]*: //' expout >at-expout
   15712 mv at-expout expout
   15713 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   15714 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   15715 mv at-expout expout
   15716 # 5. Check
   15717 $at_traceoff
   15718 echo "calc.at:554: cat stderr"
   15719 echo calc.at:554 >$at_check_line_file
   15720 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   15721 at_status=$?
   15722 grep '^ *+' $at_stder1 >&2
   15723 grep -v '^ *+' $at_stder1 >$at_stderr
   15724 at_failed=false
   15725 $at_diff $at_devnull $at_stderr || at_failed=:
   15726 $at_diff expout $at_stdout || at_failed=:
   15727 case $at_status in
   15728    77) echo 77 > $at_status_file
   15729             exit 77;;
   15730    0) ;;
   15731    *) echo "calc.at:554: exit code was $at_status, expected 0"
   15732       at_failed=:;;
   15733 esac
   15734 if $at_failed; then
   15735 
   15736   echo 1 > $at_status_file
   15737   exit 1
   15738 fi
   15739 
   15740 $at_traceon
   15741 
   15742 
   15743 
   15744 
   15745 
   15746 
   15747 
   15748 
   15749 
   15750 
   15751 
   15752 
   15753 
   15754 
   15755 
   15756 
   15757 
   15758 
   15759 
   15760 
   15761 
   15762 
   15763 
   15764 
   15765       $at_traceoff
   15766       $at_times_p && times >$at_times_file
   15767     ) 5>&1 2>&1 | eval $at_tee_pipe
   15768     at_status=`cat $at_status_file`
   15769     ;;
   15770 
   15771   74 ) # 74. calc.at:555: Calculator %verbose
   15772     at_setup_line='calc.at:555'
   15773     at_desc='Calculator %verbose'
   15774     $at_quiet $ECHO_N " 74: Calculator %verbose                          $ECHO_C"
   15775     at_xfail=no
   15776     (
   15777       echo "74. calc.at:555: testing ..."
   15778       $at_traceon
   15779 
   15780 
   15781 
   15782 
   15783 
   15784 
   15785 
   15786 
   15787 # Using yacc.c?
   15788 
   15789 
   15790 
   15791 
   15792 
   15793 
   15794 
   15795 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   15796 
   15797 # yyerror always sees the locations (when activated), except if
   15798 # yacc & pure & !param.
   15799 
   15800 
   15801 # The interface is pure: either because %pure-parser, or because we
   15802 # are using the C++ parsers.
   15803 
   15804 
   15805 
   15806 
   15807 
   15808 
   15809 
   15810 
   15811 
   15812 
   15813 
   15814 
   15815 cat >calc.y <<'_ATEOF'
   15816 %{
   15817 #ifdef HAVE_CONFIG_H
   15818 # include <config.h>
   15819   /* We don't need perfect functions for these tests. */
   15820 # undef malloc
   15821 # undef memcmp
   15822 # undef realloc
   15823 #endif
   15824 %}
   15825 
   15826 /* Infix notation calculator--calc */
   15827 %verbose
   15828 
   15829 %{
   15830 #include <stdio.h>
   15831 
   15832 #include <stdlib.h>
   15833 #include <string.h>
   15834 #if HAVE_UNISTD_H
   15835 # include <unistd.h>
   15836 #else
   15837 # undef alarm
   15838 # define alarm(seconds) /* empty */
   15839 #endif
   15840 #include <ctype.h>
   15841 #define USE(Var)
   15842 
   15843 /* Exercise pre-prologue dependency to %union.  */
   15844 typedef int semantic_value;
   15845 
   15846 static semantic_value global_result = 0;
   15847 static int global_count = 0;
   15848 %}
   15849 
   15850 /* Exercise %union. */
   15851 %union
   15852 {
   15853   semantic_value ival;
   15854 };
   15855 
   15856 %{
   15857 static int power (int base, int exponent);
   15858 /* yyerror receives the location if:
   15859    - %location & %pure & %glr
   15860    - %location & %pure & %yacc & %parse-param. */
   15861 static void yyerror (
   15862 
   15863                      const char *s
   15864                      );
   15865 static int yylex (void);
   15866 static int get_char (void);
   15867 static void unget_char ( int c);
   15868 %}
   15869 
   15870 
   15871 
   15872 /* Bison Declarations */
   15873 %token CALC_EOF 0 "end of input"
   15874 %token <ival> NUM "number"
   15875 %type  <ival> exp
   15876 
   15877 %nonassoc '=' /* comparison	       */
   15878 %left '-' '+'
   15879 %left '*' '/'
   15880 %left NEG     /* negation--unary minus */
   15881 %right '^'    /* exponentiation        */
   15882 
   15883 /* Grammar follows */
   15884 %%
   15885 input:
   15886   line
   15887 | input line         {  }
   15888 ;
   15889 
   15890 line:
   15891   '\n'
   15892 | exp '\n'           { USE ($1); }
   15893 ;
   15894 
   15895 exp:
   15896   NUM                { $$ = $1;             }
   15897 | exp '=' exp
   15898   {
   15899     if ($1 != $3)
   15900       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   15901     $$ = $1;
   15902   }
   15903 | exp '+' exp        { $$ = $1 + $3;        }
   15904 | exp '-' exp        { $$ = $1 - $3;        }
   15905 | exp '*' exp        { $$ = $1 * $3;        }
   15906 | exp '/' exp        { $$ = $1 / $3;        }
   15907 | '-' exp  %prec NEG { $$ = -$2;            }
   15908 | exp '^' exp        { $$ = power ($1, $3); }
   15909 | '(' exp ')'        { $$ = $2;             }
   15910 | '(' error ')'      { $$ = 1111;           }
   15911 | '!'                { $$ = 0; YYERROR;     }
   15912 | '-' error          { $$ = 0; YYERROR;     }
   15913 ;
   15914 %%
   15915 /* The input.  */
   15916 static FILE *input;
   15917 
   15918 static void
   15919 yyerror (
   15920 
   15921          const char *s)
   15922 {
   15923 
   15924 
   15925   fprintf (stderr, "%s\n", s);
   15926 }
   15927 
   15928 
   15929 
   15930 static int
   15931 get_char (void)
   15932 {
   15933   int res = getc (input);
   15934   ;
   15935 
   15936   return res;
   15937 }
   15938 
   15939 
   15940 static void
   15941 unget_char ( int c)
   15942 {
   15943   ;
   15944 
   15945   ungetc (c, input);
   15946 }
   15947 
   15948 static int
   15949 read_signed_integer (void)
   15950 {
   15951   int c = get_char ();
   15952   int sign = 1;
   15953   int n = 0;
   15954 
   15955   ;
   15956   if (c == '-')
   15957     {
   15958       c = get_char ();
   15959       sign = -1;
   15960     }
   15961 
   15962   while (isdigit (c))
   15963     {
   15964       n = 10 * n + (c - '0');
   15965       c = get_char ();
   15966     }
   15967 
   15968   unget_char ( c);
   15969 
   15970   return sign * n;
   15971 }
   15972 
   15973 
   15974 
   15975 /*---------------------------------------------------------------.
   15976 | Lexical analyzer returns an integer on the stack and the token |
   15977 | NUM, or the ASCII character read if not a number.  Skips all   |
   15978 | blanks and tabs, returns 0 for EOF.                            |
   15979 `---------------------------------------------------------------*/
   15980 
   15981 static int
   15982 yylex (void)
   15983 {
   15984   static int init = 1;
   15985   int c;
   15986 
   15987   if (init)
   15988     {
   15989       init = 0;
   15990 
   15991     }
   15992 
   15993 
   15994 
   15995   /* Skip white space.  */
   15996   while ((c = get_char ()) == ' ' || c == '\t')
   15997     {
   15998 
   15999     }
   16000 
   16001   /* process numbers   */
   16002   if (c == '.' || isdigit (c))
   16003     {
   16004       unget_char ( c);
   16005       (yylval).ival = read_signed_integer ();
   16006       return NUM;
   16007     }
   16008 
   16009   /* Return end-of-file.  */
   16010   if (c == EOF)
   16011     return CALC_EOF;
   16012 
   16013   /* Return single chars. */
   16014   return c;
   16015 }
   16016 
   16017 static int
   16018 power (int base, int exponent)
   16019 {
   16020   int res = 1;
   16021   if (exponent < 0)
   16022     exit (3);
   16023   for (/* Niente */; exponent; --exponent)
   16024     res *= base;
   16025   return res;
   16026 }
   16027 
   16028 
   16029 int
   16030 main (int argc, const char **argv)
   16031 {
   16032   semantic_value result = 0;
   16033   int count = 0;
   16034   int status;
   16035 
   16036   /* This used to be alarm (10), but that isn't enough time for
   16037      a July 1995 vintage DEC Alphastation 200 4/100 system,
   16038      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   16039   alarm (100);
   16040 
   16041   if (argc == 2)
   16042     input = fopen (argv[1], "r");
   16043   else
   16044     input = stdin;
   16045 
   16046   if (!input)
   16047     {
   16048       perror (argv[1]);
   16049       return 3;
   16050     }
   16051 
   16052 
   16053   status = yyparse ();
   16054   if (global_result != result)
   16055     abort ();
   16056   if (global_count != count)
   16057     abort ();
   16058   return status;
   16059 }
   16060 _ATEOF
   16061 
   16062 
   16063 
   16064 
   16065 
   16066 $at_traceoff
   16067 echo "calc.at:555: bison -o calc.c calc.y"
   16068 echo calc.at:555 >$at_check_line_file
   16069 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   16070 at_status=$?
   16071 grep '^ *+' $at_stder1 >&2
   16072 grep -v '^ *+' $at_stder1 >$at_stderr
   16073 at_failed=false
   16074 $at_diff $at_devnull $at_stderr || at_failed=:
   16075 $at_diff $at_devnull $at_stdout || at_failed=:
   16076 case $at_status in
   16077    77) echo 77 > $at_status_file
   16078             exit 77;;
   16079    0) ;;
   16080    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16081       at_failed=:;;
   16082 esac
   16083 if $at_failed; then
   16084 
   16085   echo 1 > $at_status_file
   16086   exit 1
   16087 fi
   16088 
   16089 $at_traceon
   16090 
   16091    $at_traceoff
   16092 echo "calc.at:555: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   16093 echo calc.at:555 >$at_check_line_file
   16094 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   16095 at_status=$?
   16096 grep '^ *+' $at_stder1 >&2
   16097 grep -v '^ *+' $at_stder1 >$at_stderr
   16098 at_failed=false
   16099 echo stderr:; cat $at_stderr
   16100 echo stdout:; cat $at_stdout
   16101 case $at_status in
   16102    77) echo 77 > $at_status_file
   16103             exit 77;;
   16104    0) ;;
   16105    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16106       at_failed=:;;
   16107 esac
   16108 if $at_failed; then
   16109 
   16110   echo 1 > $at_status_file
   16111   exit 1
   16112 fi
   16113 
   16114 $at_traceon
   16115 
   16116 
   16117 # Test the priorities.
   16118 cat >input <<'_ATEOF'
   16119 1 + 2 * 3 = 7
   16120 1 + 2 * -3 = -5
   16121 
   16122 -1^2 = -1
   16123 (-1)^2 = 1
   16124 
   16125 ---1 = -1
   16126 
   16127 1 - 2 - 3 = -4
   16128 1 - (2 - 3) = 2
   16129 
   16130 2^2^3 = 256
   16131 (2^2)^3 = 64
   16132 _ATEOF
   16133 
   16134 $at_traceoff
   16135 echo "calc.at:555: \$PREPARSER ./calc input"
   16136 echo calc.at:555 >$at_check_line_file
   16137 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   16138 at_status=$?
   16139 grep '^ *+' $at_stder1 >&2
   16140 grep -v '^ *+' $at_stder1 >$at_stderr
   16141 at_failed=false
   16142 echo stderr:; tee stderr <$at_stderr
   16143 $at_diff $at_devnull $at_stdout || at_failed=:
   16144 case $at_status in
   16145    77) echo 77 > $at_status_file
   16146             exit 77;;
   16147    0) ;;
   16148    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16149       at_failed=:;;
   16150 esac
   16151 if $at_failed; then
   16152 
   16153   echo 1 > $at_status_file
   16154   exit 1
   16155 fi
   16156 
   16157 $at_traceon
   16158 
   16159 
   16160 
   16161 # Some syntax errors.
   16162 cat >input <<'_ATEOF'
   16163 0 0
   16164 _ATEOF
   16165 
   16166 $at_traceoff
   16167 echo "calc.at:555: \$PREPARSER ./calc input"
   16168 echo calc.at:555 >$at_check_line_file
   16169 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   16170 at_status=$?
   16171 grep '^ *+' $at_stder1 >&2
   16172 grep -v '^ *+' $at_stder1 >$at_stderr
   16173 at_failed=false
   16174 echo stderr:; tee stderr <$at_stderr
   16175 $at_diff $at_devnull $at_stdout || at_failed=:
   16176 case $at_status in
   16177    77) echo 77 > $at_status_file
   16178             exit 77;;
   16179    1) ;;
   16180    *) echo "calc.at:555: exit code was $at_status, expected 1"
   16181       at_failed=:;;
   16182 esac
   16183 if $at_failed; then
   16184 
   16185   echo 1 > $at_status_file
   16186   exit 1
   16187 fi
   16188 
   16189 $at_traceon
   16190 
   16191 
   16192 # Normalize the observed and expected error messages, depending upon the
   16193 # options.
   16194 # 1. Remove the traces from observed.
   16195 sed '/^Starting/d
   16196 /^Entering/d
   16197 /^Stack/d
   16198 /^Reading/d
   16199 /^Reducing/d
   16200 /^Shifting/d
   16201 /^state/d
   16202 /^Cleanup:/d
   16203 /^Error:/d
   16204 /^Next/d
   16205 /^Discarding/d
   16206 / \$[0-9$]* = /d
   16207 /^yydestructor:/d' stderr >at-stderr
   16208 mv at-stderr stderr
   16209 # 2. Create the reference error message.
   16210 cat >expout <<'_ATEOF'
   16211 1.2: syntax error, unexpected number
   16212 _ATEOF
   16213 
   16214 # 3. If locations are not used, remove them.
   16215 sed 's/^[-0-9.]*: //' expout >at-expout
   16216 mv at-expout expout
   16217 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   16218 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   16219 mv at-expout expout
   16220 # 5. Check
   16221 $at_traceoff
   16222 echo "calc.at:555: cat stderr"
   16223 echo calc.at:555 >$at_check_line_file
   16224 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   16225 at_status=$?
   16226 grep '^ *+' $at_stder1 >&2
   16227 grep -v '^ *+' $at_stder1 >$at_stderr
   16228 at_failed=false
   16229 $at_diff $at_devnull $at_stderr || at_failed=:
   16230 $at_diff expout $at_stdout || at_failed=:
   16231 case $at_status in
   16232    77) echo 77 > $at_status_file
   16233             exit 77;;
   16234    0) ;;
   16235    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16236       at_failed=:;;
   16237 esac
   16238 if $at_failed; then
   16239 
   16240   echo 1 > $at_status_file
   16241   exit 1
   16242 fi
   16243 
   16244 $at_traceon
   16245 
   16246 
   16247 cat >input <<'_ATEOF'
   16248 1//2
   16249 _ATEOF
   16250 
   16251 $at_traceoff
   16252 echo "calc.at:555: \$PREPARSER ./calc input"
   16253 echo calc.at:555 >$at_check_line_file
   16254 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   16255 at_status=$?
   16256 grep '^ *+' $at_stder1 >&2
   16257 grep -v '^ *+' $at_stder1 >$at_stderr
   16258 at_failed=false
   16259 echo stderr:; tee stderr <$at_stderr
   16260 $at_diff $at_devnull $at_stdout || at_failed=:
   16261 case $at_status in
   16262    77) echo 77 > $at_status_file
   16263             exit 77;;
   16264    1) ;;
   16265    *) echo "calc.at:555: exit code was $at_status, expected 1"
   16266       at_failed=:;;
   16267 esac
   16268 if $at_failed; then
   16269 
   16270   echo 1 > $at_status_file
   16271   exit 1
   16272 fi
   16273 
   16274 $at_traceon
   16275 
   16276 
   16277 # Normalize the observed and expected error messages, depending upon the
   16278 # options.
   16279 # 1. Remove the traces from observed.
   16280 sed '/^Starting/d
   16281 /^Entering/d
   16282 /^Stack/d
   16283 /^Reading/d
   16284 /^Reducing/d
   16285 /^Shifting/d
   16286 /^state/d
   16287 /^Cleanup:/d
   16288 /^Error:/d
   16289 /^Next/d
   16290 /^Discarding/d
   16291 / \$[0-9$]* = /d
   16292 /^yydestructor:/d' stderr >at-stderr
   16293 mv at-stderr stderr
   16294 # 2. Create the reference error message.
   16295 cat >expout <<'_ATEOF'
   16296 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   16297 _ATEOF
   16298 
   16299 # 3. If locations are not used, remove them.
   16300 sed 's/^[-0-9.]*: //' expout >at-expout
   16301 mv at-expout expout
   16302 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   16303 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   16304 mv at-expout expout
   16305 # 5. Check
   16306 $at_traceoff
   16307 echo "calc.at:555: cat stderr"
   16308 echo calc.at:555 >$at_check_line_file
   16309 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   16310 at_status=$?
   16311 grep '^ *+' $at_stder1 >&2
   16312 grep -v '^ *+' $at_stder1 >$at_stderr
   16313 at_failed=false
   16314 $at_diff $at_devnull $at_stderr || at_failed=:
   16315 $at_diff expout $at_stdout || at_failed=:
   16316 case $at_status in
   16317    77) echo 77 > $at_status_file
   16318             exit 77;;
   16319    0) ;;
   16320    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16321       at_failed=:;;
   16322 esac
   16323 if $at_failed; then
   16324 
   16325   echo 1 > $at_status_file
   16326   exit 1
   16327 fi
   16328 
   16329 $at_traceon
   16330 
   16331 
   16332 cat >input <<'_ATEOF'
   16333 error
   16334 _ATEOF
   16335 
   16336 $at_traceoff
   16337 echo "calc.at:555: \$PREPARSER ./calc input"
   16338 echo calc.at:555 >$at_check_line_file
   16339 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   16340 at_status=$?
   16341 grep '^ *+' $at_stder1 >&2
   16342 grep -v '^ *+' $at_stder1 >$at_stderr
   16343 at_failed=false
   16344 echo stderr:; tee stderr <$at_stderr
   16345 $at_diff $at_devnull $at_stdout || at_failed=:
   16346 case $at_status in
   16347    77) echo 77 > $at_status_file
   16348             exit 77;;
   16349    1) ;;
   16350    *) echo "calc.at:555: exit code was $at_status, expected 1"
   16351       at_failed=:;;
   16352 esac
   16353 if $at_failed; then
   16354 
   16355   echo 1 > $at_status_file
   16356   exit 1
   16357 fi
   16358 
   16359 $at_traceon
   16360 
   16361 
   16362 # Normalize the observed and expected error messages, depending upon the
   16363 # options.
   16364 # 1. Remove the traces from observed.
   16365 sed '/^Starting/d
   16366 /^Entering/d
   16367 /^Stack/d
   16368 /^Reading/d
   16369 /^Reducing/d
   16370 /^Shifting/d
   16371 /^state/d
   16372 /^Cleanup:/d
   16373 /^Error:/d
   16374 /^Next/d
   16375 /^Discarding/d
   16376 / \$[0-9$]* = /d
   16377 /^yydestructor:/d' stderr >at-stderr
   16378 mv at-stderr stderr
   16379 # 2. Create the reference error message.
   16380 cat >expout <<'_ATEOF'
   16381 1.0: syntax error, unexpected $undefined
   16382 _ATEOF
   16383 
   16384 # 3. If locations are not used, remove them.
   16385 sed 's/^[-0-9.]*: //' expout >at-expout
   16386 mv at-expout expout
   16387 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   16388 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   16389 mv at-expout expout
   16390 # 5. Check
   16391 $at_traceoff
   16392 echo "calc.at:555: cat stderr"
   16393 echo calc.at:555 >$at_check_line_file
   16394 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   16395 at_status=$?
   16396 grep '^ *+' $at_stder1 >&2
   16397 grep -v '^ *+' $at_stder1 >$at_stderr
   16398 at_failed=false
   16399 $at_diff $at_devnull $at_stderr || at_failed=:
   16400 $at_diff expout $at_stdout || at_failed=:
   16401 case $at_status in
   16402    77) echo 77 > $at_status_file
   16403             exit 77;;
   16404    0) ;;
   16405    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16406       at_failed=:;;
   16407 esac
   16408 if $at_failed; then
   16409 
   16410   echo 1 > $at_status_file
   16411   exit 1
   16412 fi
   16413 
   16414 $at_traceon
   16415 
   16416 
   16417 cat >input <<'_ATEOF'
   16418 1 = 2 = 3
   16419 _ATEOF
   16420 
   16421 $at_traceoff
   16422 echo "calc.at:555: \$PREPARSER ./calc input"
   16423 echo calc.at:555 >$at_check_line_file
   16424 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   16425 at_status=$?
   16426 grep '^ *+' $at_stder1 >&2
   16427 grep -v '^ *+' $at_stder1 >$at_stderr
   16428 at_failed=false
   16429 echo stderr:; tee stderr <$at_stderr
   16430 $at_diff $at_devnull $at_stdout || at_failed=:
   16431 case $at_status in
   16432    77) echo 77 > $at_status_file
   16433             exit 77;;
   16434    1) ;;
   16435    *) echo "calc.at:555: exit code was $at_status, expected 1"
   16436       at_failed=:;;
   16437 esac
   16438 if $at_failed; then
   16439 
   16440   echo 1 > $at_status_file
   16441   exit 1
   16442 fi
   16443 
   16444 $at_traceon
   16445 
   16446 
   16447 # Normalize the observed and expected error messages, depending upon the
   16448 # options.
   16449 # 1. Remove the traces from observed.
   16450 sed '/^Starting/d
   16451 /^Entering/d
   16452 /^Stack/d
   16453 /^Reading/d
   16454 /^Reducing/d
   16455 /^Shifting/d
   16456 /^state/d
   16457 /^Cleanup:/d
   16458 /^Error:/d
   16459 /^Next/d
   16460 /^Discarding/d
   16461 / \$[0-9$]* = /d
   16462 /^yydestructor:/d' stderr >at-stderr
   16463 mv at-stderr stderr
   16464 # 2. Create the reference error message.
   16465 cat >expout <<'_ATEOF'
   16466 1.6: syntax error, unexpected '='
   16467 _ATEOF
   16468 
   16469 # 3. If locations are not used, remove them.
   16470 sed 's/^[-0-9.]*: //' expout >at-expout
   16471 mv at-expout expout
   16472 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   16473 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   16474 mv at-expout expout
   16475 # 5. Check
   16476 $at_traceoff
   16477 echo "calc.at:555: cat stderr"
   16478 echo calc.at:555 >$at_check_line_file
   16479 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   16480 at_status=$?
   16481 grep '^ *+' $at_stder1 >&2
   16482 grep -v '^ *+' $at_stder1 >$at_stderr
   16483 at_failed=false
   16484 $at_diff $at_devnull $at_stderr || at_failed=:
   16485 $at_diff expout $at_stdout || at_failed=:
   16486 case $at_status in
   16487    77) echo 77 > $at_status_file
   16488             exit 77;;
   16489    0) ;;
   16490    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16491       at_failed=:;;
   16492 esac
   16493 if $at_failed; then
   16494 
   16495   echo 1 > $at_status_file
   16496   exit 1
   16497 fi
   16498 
   16499 $at_traceon
   16500 
   16501 
   16502 cat >input <<'_ATEOF'
   16503 
   16504 +1
   16505 _ATEOF
   16506 
   16507 $at_traceoff
   16508 echo "calc.at:555: \$PREPARSER ./calc input"
   16509 echo calc.at:555 >$at_check_line_file
   16510 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   16511 at_status=$?
   16512 grep '^ *+' $at_stder1 >&2
   16513 grep -v '^ *+' $at_stder1 >$at_stderr
   16514 at_failed=false
   16515 echo stderr:; tee stderr <$at_stderr
   16516 $at_diff $at_devnull $at_stdout || at_failed=:
   16517 case $at_status in
   16518    77) echo 77 > $at_status_file
   16519             exit 77;;
   16520    1) ;;
   16521    *) echo "calc.at:555: exit code was $at_status, expected 1"
   16522       at_failed=:;;
   16523 esac
   16524 if $at_failed; then
   16525 
   16526   echo 1 > $at_status_file
   16527   exit 1
   16528 fi
   16529 
   16530 $at_traceon
   16531 
   16532 
   16533 # Normalize the observed and expected error messages, depending upon the
   16534 # options.
   16535 # 1. Remove the traces from observed.
   16536 sed '/^Starting/d
   16537 /^Entering/d
   16538 /^Stack/d
   16539 /^Reading/d
   16540 /^Reducing/d
   16541 /^Shifting/d
   16542 /^state/d
   16543 /^Cleanup:/d
   16544 /^Error:/d
   16545 /^Next/d
   16546 /^Discarding/d
   16547 / \$[0-9$]* = /d
   16548 /^yydestructor:/d' stderr >at-stderr
   16549 mv at-stderr stderr
   16550 # 2. Create the reference error message.
   16551 cat >expout <<'_ATEOF'
   16552 2.0: syntax error, unexpected '+'
   16553 _ATEOF
   16554 
   16555 # 3. If locations are not used, remove them.
   16556 sed 's/^[-0-9.]*: //' expout >at-expout
   16557 mv at-expout expout
   16558 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   16559 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   16560 mv at-expout expout
   16561 # 5. Check
   16562 $at_traceoff
   16563 echo "calc.at:555: cat stderr"
   16564 echo calc.at:555 >$at_check_line_file
   16565 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   16566 at_status=$?
   16567 grep '^ *+' $at_stder1 >&2
   16568 grep -v '^ *+' $at_stder1 >$at_stderr
   16569 at_failed=false
   16570 $at_diff $at_devnull $at_stderr || at_failed=:
   16571 $at_diff expout $at_stdout || at_failed=:
   16572 case $at_status in
   16573    77) echo 77 > $at_status_file
   16574             exit 77;;
   16575    0) ;;
   16576    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16577       at_failed=:;;
   16578 esac
   16579 if $at_failed; then
   16580 
   16581   echo 1 > $at_status_file
   16582   exit 1
   16583 fi
   16584 
   16585 $at_traceon
   16586 
   16587 
   16588 # Exercise error messages with EOF: work on an empty file.
   16589 $at_traceoff
   16590 echo "calc.at:555: \$PREPARSER ./calc /dev/null"
   16591 echo calc.at:555 >$at_check_line_file
   16592 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   16593 at_status=$?
   16594 grep '^ *+' $at_stder1 >&2
   16595 grep -v '^ *+' $at_stder1 >$at_stderr
   16596 at_failed=false
   16597 echo stderr:; tee stderr <$at_stderr
   16598 $at_diff $at_devnull $at_stdout || at_failed=:
   16599 case $at_status in
   16600    77) echo 77 > $at_status_file
   16601             exit 77;;
   16602    1) ;;
   16603    *) echo "calc.at:555: exit code was $at_status, expected 1"
   16604       at_failed=:;;
   16605 esac
   16606 if $at_failed; then
   16607 
   16608   echo 1 > $at_status_file
   16609   exit 1
   16610 fi
   16611 
   16612 $at_traceon
   16613 
   16614 
   16615 # Normalize the observed and expected error messages, depending upon the
   16616 # options.
   16617 # 1. Remove the traces from observed.
   16618 sed '/^Starting/d
   16619 /^Entering/d
   16620 /^Stack/d
   16621 /^Reading/d
   16622 /^Reducing/d
   16623 /^Shifting/d
   16624 /^state/d
   16625 /^Cleanup:/d
   16626 /^Error:/d
   16627 /^Next/d
   16628 /^Discarding/d
   16629 / \$[0-9$]* = /d
   16630 /^yydestructor:/d' stderr >at-stderr
   16631 mv at-stderr stderr
   16632 # 2. Create the reference error message.
   16633 cat >expout <<'_ATEOF'
   16634 1.0: syntax error, unexpected end of input
   16635 _ATEOF
   16636 
   16637 # 3. If locations are not used, remove them.
   16638 sed 's/^[-0-9.]*: //' expout >at-expout
   16639 mv at-expout expout
   16640 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   16641 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   16642 mv at-expout expout
   16643 # 5. Check
   16644 $at_traceoff
   16645 echo "calc.at:555: cat stderr"
   16646 echo calc.at:555 >$at_check_line_file
   16647 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   16648 at_status=$?
   16649 grep '^ *+' $at_stder1 >&2
   16650 grep -v '^ *+' $at_stder1 >$at_stderr
   16651 at_failed=false
   16652 $at_diff $at_devnull $at_stderr || at_failed=:
   16653 $at_diff expout $at_stdout || at_failed=:
   16654 case $at_status in
   16655    77) echo 77 > $at_status_file
   16656             exit 77;;
   16657    0) ;;
   16658    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16659       at_failed=:;;
   16660 esac
   16661 if $at_failed; then
   16662 
   16663   echo 1 > $at_status_file
   16664   exit 1
   16665 fi
   16666 
   16667 $at_traceon
   16668 
   16669 
   16670 
   16671 # Exercise the error token: without it, we die at the first error,
   16672 # hence be sure to
   16673 #
   16674 # - have several errors which exercise different shift/discardings
   16675 #   - (): nothing to pop, nothing to discard
   16676 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   16677 #   - (* * *): nothing to pop, a lot to discard
   16678 #   - (1 + 2 * *): some to pop and discard
   16679 #
   16680 # - test the action associated to `error'
   16681 #
   16682 # - check the look-ahead that triggers an error is not discarded
   16683 #   when we enter error recovery.  Below, the look-ahead causing the
   16684 #   first error is ")", which is needed to recover from the error and
   16685 #   produce the "0" that triggers the "0 != 1" error.
   16686 #
   16687 cat >input <<'_ATEOF'
   16688 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   16689 _ATEOF
   16690 
   16691 $at_traceoff
   16692 echo "calc.at:555: \$PREPARSER ./calc input"
   16693 echo calc.at:555 >$at_check_line_file
   16694 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   16695 at_status=$?
   16696 grep '^ *+' $at_stder1 >&2
   16697 grep -v '^ *+' $at_stder1 >$at_stderr
   16698 at_failed=false
   16699 echo stderr:; tee stderr <$at_stderr
   16700 $at_diff $at_devnull $at_stdout || at_failed=:
   16701 case $at_status in
   16702    77) echo 77 > $at_status_file
   16703             exit 77;;
   16704    0) ;;
   16705    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16706       at_failed=:;;
   16707 esac
   16708 if $at_failed; then
   16709 
   16710   echo 1 > $at_status_file
   16711   exit 1
   16712 fi
   16713 
   16714 $at_traceon
   16715 
   16716 
   16717 # Normalize the observed and expected error messages, depending upon the
   16718 # options.
   16719 # 1. Remove the traces from observed.
   16720 sed '/^Starting/d
   16721 /^Entering/d
   16722 /^Stack/d
   16723 /^Reading/d
   16724 /^Reducing/d
   16725 /^Shifting/d
   16726 /^state/d
   16727 /^Cleanup:/d
   16728 /^Error:/d
   16729 /^Next/d
   16730 /^Discarding/d
   16731 / \$[0-9$]* = /d
   16732 /^yydestructor:/d' stderr >at-stderr
   16733 mv at-stderr stderr
   16734 # 2. Create the reference error message.
   16735 cat >expout <<'_ATEOF'
   16736 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   16737 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   16738 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   16739 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   16740 calc: error: 4444 != 1
   16741 _ATEOF
   16742 
   16743 # 3. If locations are not used, remove them.
   16744 sed 's/^[-0-9.]*: //' expout >at-expout
   16745 mv at-expout expout
   16746 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   16747 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   16748 mv at-expout expout
   16749 # 5. Check
   16750 $at_traceoff
   16751 echo "calc.at:555: cat stderr"
   16752 echo calc.at:555 >$at_check_line_file
   16753 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   16754 at_status=$?
   16755 grep '^ *+' $at_stder1 >&2
   16756 grep -v '^ *+' $at_stder1 >$at_stderr
   16757 at_failed=false
   16758 $at_diff $at_devnull $at_stderr || at_failed=:
   16759 $at_diff expout $at_stdout || at_failed=:
   16760 case $at_status in
   16761    77) echo 77 > $at_status_file
   16762             exit 77;;
   16763    0) ;;
   16764    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16765       at_failed=:;;
   16766 esac
   16767 if $at_failed; then
   16768 
   16769   echo 1 > $at_status_file
   16770   exit 1
   16771 fi
   16772 
   16773 $at_traceon
   16774 
   16775 
   16776 
   16777 # The same, but this time exercising explicitly triggered syntax errors.
   16778 # POSIX says the look-ahead causing the error should not be discarded.
   16779 cat >input <<'_ATEOF'
   16780 (!) + (0 0) = 1
   16781 _ATEOF
   16782 
   16783 $at_traceoff
   16784 echo "calc.at:555: \$PREPARSER ./calc input"
   16785 echo calc.at:555 >$at_check_line_file
   16786 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   16787 at_status=$?
   16788 grep '^ *+' $at_stder1 >&2
   16789 grep -v '^ *+' $at_stder1 >$at_stderr
   16790 at_failed=false
   16791 echo stderr:; tee stderr <$at_stderr
   16792 $at_diff $at_devnull $at_stdout || at_failed=:
   16793 case $at_status in
   16794    77) echo 77 > $at_status_file
   16795             exit 77;;
   16796    0) ;;
   16797    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16798       at_failed=:;;
   16799 esac
   16800 if $at_failed; then
   16801 
   16802   echo 1 > $at_status_file
   16803   exit 1
   16804 fi
   16805 
   16806 $at_traceon
   16807 
   16808 
   16809 # Normalize the observed and expected error messages, depending upon the
   16810 # options.
   16811 # 1. Remove the traces from observed.
   16812 sed '/^Starting/d
   16813 /^Entering/d
   16814 /^Stack/d
   16815 /^Reading/d
   16816 /^Reducing/d
   16817 /^Shifting/d
   16818 /^state/d
   16819 /^Cleanup:/d
   16820 /^Error:/d
   16821 /^Next/d
   16822 /^Discarding/d
   16823 / \$[0-9$]* = /d
   16824 /^yydestructor:/d' stderr >at-stderr
   16825 mv at-stderr stderr
   16826 # 2. Create the reference error message.
   16827 cat >expout <<'_ATEOF'
   16828 1.9: syntax error, unexpected number
   16829 calc: error: 2222 != 1
   16830 _ATEOF
   16831 
   16832 # 3. If locations are not used, remove them.
   16833 sed 's/^[-0-9.]*: //' expout >at-expout
   16834 mv at-expout expout
   16835 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   16836 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   16837 mv at-expout expout
   16838 # 5. Check
   16839 $at_traceoff
   16840 echo "calc.at:555: cat stderr"
   16841 echo calc.at:555 >$at_check_line_file
   16842 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   16843 at_status=$?
   16844 grep '^ *+' $at_stder1 >&2
   16845 grep -v '^ *+' $at_stder1 >$at_stderr
   16846 at_failed=false
   16847 $at_diff $at_devnull $at_stderr || at_failed=:
   16848 $at_diff expout $at_stdout || at_failed=:
   16849 case $at_status in
   16850    77) echo 77 > $at_status_file
   16851             exit 77;;
   16852    0) ;;
   16853    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16854       at_failed=:;;
   16855 esac
   16856 if $at_failed; then
   16857 
   16858   echo 1 > $at_status_file
   16859   exit 1
   16860 fi
   16861 
   16862 $at_traceon
   16863 
   16864 
   16865 cat >input <<'_ATEOF'
   16866 (- *) + (0 0) = 1
   16867 _ATEOF
   16868 
   16869 $at_traceoff
   16870 echo "calc.at:555: \$PREPARSER ./calc input"
   16871 echo calc.at:555 >$at_check_line_file
   16872 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   16873 at_status=$?
   16874 grep '^ *+' $at_stder1 >&2
   16875 grep -v '^ *+' $at_stder1 >$at_stderr
   16876 at_failed=false
   16877 echo stderr:; tee stderr <$at_stderr
   16878 $at_diff $at_devnull $at_stdout || at_failed=:
   16879 case $at_status in
   16880    77) echo 77 > $at_status_file
   16881             exit 77;;
   16882    0) ;;
   16883    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16884       at_failed=:;;
   16885 esac
   16886 if $at_failed; then
   16887 
   16888   echo 1 > $at_status_file
   16889   exit 1
   16890 fi
   16891 
   16892 $at_traceon
   16893 
   16894 
   16895 # Normalize the observed and expected error messages, depending upon the
   16896 # options.
   16897 # 1. Remove the traces from observed.
   16898 sed '/^Starting/d
   16899 /^Entering/d
   16900 /^Stack/d
   16901 /^Reading/d
   16902 /^Reducing/d
   16903 /^Shifting/d
   16904 /^state/d
   16905 /^Cleanup:/d
   16906 /^Error:/d
   16907 /^Next/d
   16908 /^Discarding/d
   16909 / \$[0-9$]* = /d
   16910 /^yydestructor:/d' stderr >at-stderr
   16911 mv at-stderr stderr
   16912 # 2. Create the reference error message.
   16913 cat >expout <<'_ATEOF'
   16914 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   16915 1.11: syntax error, unexpected number
   16916 calc: error: 2222 != 1
   16917 _ATEOF
   16918 
   16919 # 3. If locations are not used, remove them.
   16920 sed 's/^[-0-9.]*: //' expout >at-expout
   16921 mv at-expout expout
   16922 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   16923 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   16924 mv at-expout expout
   16925 # 5. Check
   16926 $at_traceoff
   16927 echo "calc.at:555: cat stderr"
   16928 echo calc.at:555 >$at_check_line_file
   16929 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   16930 at_status=$?
   16931 grep '^ *+' $at_stder1 >&2
   16932 grep -v '^ *+' $at_stder1 >$at_stderr
   16933 at_failed=false
   16934 $at_diff $at_devnull $at_stderr || at_failed=:
   16935 $at_diff expout $at_stdout || at_failed=:
   16936 case $at_status in
   16937    77) echo 77 > $at_status_file
   16938             exit 77;;
   16939    0) ;;
   16940    *) echo "calc.at:555: exit code was $at_status, expected 0"
   16941       at_failed=:;;
   16942 esac
   16943 if $at_failed; then
   16944 
   16945   echo 1 > $at_status_file
   16946   exit 1
   16947 fi
   16948 
   16949 $at_traceon
   16950 
   16951 
   16952 
   16953 
   16954 
   16955 
   16956 
   16957 
   16958 
   16959 
   16960 
   16961 
   16962 
   16963 
   16964 
   16965 
   16966 
   16967 
   16968 
   16969 
   16970 
   16971 
   16972 
   16973 
   16974       $at_traceoff
   16975       $at_times_p && times >$at_times_file
   16976     ) 5>&1 2>&1 | eval $at_tee_pipe
   16977     at_status=`cat $at_status_file`
   16978     ;;
   16979 
   16980   75 ) # 75. calc.at:556: Calculator %yacc
   16981     at_setup_line='calc.at:556'
   16982     at_desc='Calculator %yacc'
   16983     $at_quiet $ECHO_N " 75: Calculator %yacc                             $ECHO_C"
   16984     at_xfail=no
   16985     (
   16986       echo "75. calc.at:556: testing ..."
   16987       $at_traceon
   16988 
   16989 
   16990 
   16991 
   16992 
   16993 
   16994 
   16995 
   16996 # Using yacc.c?
   16997 
   16998 
   16999 
   17000 
   17001 
   17002 
   17003 
   17004 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   17005 
   17006 # yyerror always sees the locations (when activated), except if
   17007 # yacc & pure & !param.
   17008 
   17009 
   17010 # The interface is pure: either because %pure-parser, or because we
   17011 # are using the C++ parsers.
   17012 
   17013 
   17014 
   17015 
   17016 
   17017 
   17018 
   17019 
   17020 
   17021 
   17022 
   17023 
   17024 cat >calc.y <<'_ATEOF'
   17025 %{
   17026 #ifdef HAVE_CONFIG_H
   17027 # include <config.h>
   17028   /* We don't need perfect functions for these tests. */
   17029 # undef malloc
   17030 # undef memcmp
   17031 # undef realloc
   17032 #endif
   17033 %}
   17034 
   17035 /* Infix notation calculator--calc */
   17036 %yacc
   17037 
   17038 %{
   17039 #include <stdio.h>
   17040 
   17041 #include <stdlib.h>
   17042 #include <string.h>
   17043 #if HAVE_UNISTD_H
   17044 # include <unistd.h>
   17045 #else
   17046 # undef alarm
   17047 # define alarm(seconds) /* empty */
   17048 #endif
   17049 #include <ctype.h>
   17050 #define USE(Var)
   17051 
   17052 /* Exercise pre-prologue dependency to %union.  */
   17053 typedef int semantic_value;
   17054 
   17055 static semantic_value global_result = 0;
   17056 static int global_count = 0;
   17057 %}
   17058 
   17059 /* Exercise %union. */
   17060 %union
   17061 {
   17062   semantic_value ival;
   17063 };
   17064 
   17065 %{
   17066 static int power (int base, int exponent);
   17067 /* yyerror receives the location if:
   17068    - %location & %pure & %glr
   17069    - %location & %pure & %yacc & %parse-param. */
   17070 static void yyerror (
   17071 
   17072                      const char *s
   17073                      );
   17074 static int yylex (void);
   17075 static int get_char (void);
   17076 static void unget_char ( int c);
   17077 %}
   17078 
   17079 
   17080 
   17081 /* Bison Declarations */
   17082 %token CALC_EOF 0 "end of input"
   17083 %token <ival> NUM "number"
   17084 %type  <ival> exp
   17085 
   17086 %nonassoc '=' /* comparison	       */
   17087 %left '-' '+'
   17088 %left '*' '/'
   17089 %left NEG     /* negation--unary minus */
   17090 %right '^'    /* exponentiation        */
   17091 
   17092 /* Grammar follows */
   17093 %%
   17094 input:
   17095   line
   17096 | input line         {  }
   17097 ;
   17098 
   17099 line:
   17100   '\n'
   17101 | exp '\n'           { USE ($1); }
   17102 ;
   17103 
   17104 exp:
   17105   NUM                { $$ = $1;             }
   17106 | exp '=' exp
   17107   {
   17108     if ($1 != $3)
   17109       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   17110     $$ = $1;
   17111   }
   17112 | exp '+' exp        { $$ = $1 + $3;        }
   17113 | exp '-' exp        { $$ = $1 - $3;        }
   17114 | exp '*' exp        { $$ = $1 * $3;        }
   17115 | exp '/' exp        { $$ = $1 / $3;        }
   17116 | '-' exp  %prec NEG { $$ = -$2;            }
   17117 | exp '^' exp        { $$ = power ($1, $3); }
   17118 | '(' exp ')'        { $$ = $2;             }
   17119 | '(' error ')'      { $$ = 1111;           }
   17120 | '!'                { $$ = 0; YYERROR;     }
   17121 | '-' error          { $$ = 0; YYERROR;     }
   17122 ;
   17123 %%
   17124 /* The input.  */
   17125 static FILE *input;
   17126 
   17127 static void
   17128 yyerror (
   17129 
   17130          const char *s)
   17131 {
   17132 
   17133 
   17134   fprintf (stderr, "%s\n", s);
   17135 }
   17136 
   17137 
   17138 
   17139 static int
   17140 get_char (void)
   17141 {
   17142   int res = getc (input);
   17143   ;
   17144 
   17145   return res;
   17146 }
   17147 
   17148 
   17149 static void
   17150 unget_char ( int c)
   17151 {
   17152   ;
   17153 
   17154   ungetc (c, input);
   17155 }
   17156 
   17157 static int
   17158 read_signed_integer (void)
   17159 {
   17160   int c = get_char ();
   17161   int sign = 1;
   17162   int n = 0;
   17163 
   17164   ;
   17165   if (c == '-')
   17166     {
   17167       c = get_char ();
   17168       sign = -1;
   17169     }
   17170 
   17171   while (isdigit (c))
   17172     {
   17173       n = 10 * n + (c - '0');
   17174       c = get_char ();
   17175     }
   17176 
   17177   unget_char ( c);
   17178 
   17179   return sign * n;
   17180 }
   17181 
   17182 
   17183 
   17184 /*---------------------------------------------------------------.
   17185 | Lexical analyzer returns an integer on the stack and the token |
   17186 | NUM, or the ASCII character read if not a number.  Skips all   |
   17187 | blanks and tabs, returns 0 for EOF.                            |
   17188 `---------------------------------------------------------------*/
   17189 
   17190 static int
   17191 yylex (void)
   17192 {
   17193   static int init = 1;
   17194   int c;
   17195 
   17196   if (init)
   17197     {
   17198       init = 0;
   17199 
   17200     }
   17201 
   17202 
   17203 
   17204   /* Skip white space.  */
   17205   while ((c = get_char ()) == ' ' || c == '\t')
   17206     {
   17207 
   17208     }
   17209 
   17210   /* process numbers   */
   17211   if (c == '.' || isdigit (c))
   17212     {
   17213       unget_char ( c);
   17214       (yylval).ival = read_signed_integer ();
   17215       return NUM;
   17216     }
   17217 
   17218   /* Return end-of-file.  */
   17219   if (c == EOF)
   17220     return CALC_EOF;
   17221 
   17222   /* Return single chars. */
   17223   return c;
   17224 }
   17225 
   17226 static int
   17227 power (int base, int exponent)
   17228 {
   17229   int res = 1;
   17230   if (exponent < 0)
   17231     exit (3);
   17232   for (/* Niente */; exponent; --exponent)
   17233     res *= base;
   17234   return res;
   17235 }
   17236 
   17237 
   17238 int
   17239 main (int argc, const char **argv)
   17240 {
   17241   semantic_value result = 0;
   17242   int count = 0;
   17243   int status;
   17244 
   17245   /* This used to be alarm (10), but that isn't enough time for
   17246      a July 1995 vintage DEC Alphastation 200 4/100 system,
   17247      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   17248   alarm (100);
   17249 
   17250   if (argc == 2)
   17251     input = fopen (argv[1], "r");
   17252   else
   17253     input = stdin;
   17254 
   17255   if (!input)
   17256     {
   17257       perror (argv[1]);
   17258       return 3;
   17259     }
   17260 
   17261 
   17262   status = yyparse ();
   17263   if (global_result != result)
   17264     abort ();
   17265   if (global_count != count)
   17266     abort ();
   17267   return status;
   17268 }
   17269 _ATEOF
   17270 
   17271 
   17272 
   17273 
   17274 
   17275 $at_traceoff
   17276 echo "calc.at:556: bison -o calc.c calc.y"
   17277 echo calc.at:556 >$at_check_line_file
   17278 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   17279 at_status=$?
   17280 grep '^ *+' $at_stder1 >&2
   17281 grep -v '^ *+' $at_stder1 >$at_stderr
   17282 at_failed=false
   17283 $at_diff $at_devnull $at_stderr || at_failed=:
   17284 $at_diff $at_devnull $at_stdout || at_failed=:
   17285 case $at_status in
   17286    77) echo 77 > $at_status_file
   17287             exit 77;;
   17288    0) ;;
   17289    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17290       at_failed=:;;
   17291 esac
   17292 if $at_failed; then
   17293 
   17294   echo 1 > $at_status_file
   17295   exit 1
   17296 fi
   17297 
   17298 $at_traceon
   17299 
   17300    $at_traceoff
   17301 echo "calc.at:556: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   17302 echo calc.at:556 >$at_check_line_file
   17303 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   17304 at_status=$?
   17305 grep '^ *+' $at_stder1 >&2
   17306 grep -v '^ *+' $at_stder1 >$at_stderr
   17307 at_failed=false
   17308 echo stderr:; cat $at_stderr
   17309 echo stdout:; cat $at_stdout
   17310 case $at_status in
   17311    77) echo 77 > $at_status_file
   17312             exit 77;;
   17313    0) ;;
   17314    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17315       at_failed=:;;
   17316 esac
   17317 if $at_failed; then
   17318 
   17319   echo 1 > $at_status_file
   17320   exit 1
   17321 fi
   17322 
   17323 $at_traceon
   17324 
   17325 
   17326 # Test the priorities.
   17327 cat >input <<'_ATEOF'
   17328 1 + 2 * 3 = 7
   17329 1 + 2 * -3 = -5
   17330 
   17331 -1^2 = -1
   17332 (-1)^2 = 1
   17333 
   17334 ---1 = -1
   17335 
   17336 1 - 2 - 3 = -4
   17337 1 - (2 - 3) = 2
   17338 
   17339 2^2^3 = 256
   17340 (2^2)^3 = 64
   17341 _ATEOF
   17342 
   17343 $at_traceoff
   17344 echo "calc.at:556: \$PREPARSER ./calc input"
   17345 echo calc.at:556 >$at_check_line_file
   17346 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   17347 at_status=$?
   17348 grep '^ *+' $at_stder1 >&2
   17349 grep -v '^ *+' $at_stder1 >$at_stderr
   17350 at_failed=false
   17351 echo stderr:; tee stderr <$at_stderr
   17352 $at_diff $at_devnull $at_stdout || at_failed=:
   17353 case $at_status in
   17354    77) echo 77 > $at_status_file
   17355             exit 77;;
   17356    0) ;;
   17357    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17358       at_failed=:;;
   17359 esac
   17360 if $at_failed; then
   17361 
   17362   echo 1 > $at_status_file
   17363   exit 1
   17364 fi
   17365 
   17366 $at_traceon
   17367 
   17368 
   17369 
   17370 # Some syntax errors.
   17371 cat >input <<'_ATEOF'
   17372 0 0
   17373 _ATEOF
   17374 
   17375 $at_traceoff
   17376 echo "calc.at:556: \$PREPARSER ./calc input"
   17377 echo calc.at:556 >$at_check_line_file
   17378 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   17379 at_status=$?
   17380 grep '^ *+' $at_stder1 >&2
   17381 grep -v '^ *+' $at_stder1 >$at_stderr
   17382 at_failed=false
   17383 echo stderr:; tee stderr <$at_stderr
   17384 $at_diff $at_devnull $at_stdout || at_failed=:
   17385 case $at_status in
   17386    77) echo 77 > $at_status_file
   17387             exit 77;;
   17388    1) ;;
   17389    *) echo "calc.at:556: exit code was $at_status, expected 1"
   17390       at_failed=:;;
   17391 esac
   17392 if $at_failed; then
   17393 
   17394   echo 1 > $at_status_file
   17395   exit 1
   17396 fi
   17397 
   17398 $at_traceon
   17399 
   17400 
   17401 # Normalize the observed and expected error messages, depending upon the
   17402 # options.
   17403 # 1. Remove the traces from observed.
   17404 sed '/^Starting/d
   17405 /^Entering/d
   17406 /^Stack/d
   17407 /^Reading/d
   17408 /^Reducing/d
   17409 /^Shifting/d
   17410 /^state/d
   17411 /^Cleanup:/d
   17412 /^Error:/d
   17413 /^Next/d
   17414 /^Discarding/d
   17415 / \$[0-9$]* = /d
   17416 /^yydestructor:/d' stderr >at-stderr
   17417 mv at-stderr stderr
   17418 # 2. Create the reference error message.
   17419 cat >expout <<'_ATEOF'
   17420 1.2: syntax error, unexpected number
   17421 _ATEOF
   17422 
   17423 # 3. If locations are not used, remove them.
   17424 sed 's/^[-0-9.]*: //' expout >at-expout
   17425 mv at-expout expout
   17426 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   17427 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   17428 mv at-expout expout
   17429 # 5. Check
   17430 $at_traceoff
   17431 echo "calc.at:556: cat stderr"
   17432 echo calc.at:556 >$at_check_line_file
   17433 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   17434 at_status=$?
   17435 grep '^ *+' $at_stder1 >&2
   17436 grep -v '^ *+' $at_stder1 >$at_stderr
   17437 at_failed=false
   17438 $at_diff $at_devnull $at_stderr || at_failed=:
   17439 $at_diff expout $at_stdout || at_failed=:
   17440 case $at_status in
   17441    77) echo 77 > $at_status_file
   17442             exit 77;;
   17443    0) ;;
   17444    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17445       at_failed=:;;
   17446 esac
   17447 if $at_failed; then
   17448 
   17449   echo 1 > $at_status_file
   17450   exit 1
   17451 fi
   17452 
   17453 $at_traceon
   17454 
   17455 
   17456 cat >input <<'_ATEOF'
   17457 1//2
   17458 _ATEOF
   17459 
   17460 $at_traceoff
   17461 echo "calc.at:556: \$PREPARSER ./calc input"
   17462 echo calc.at:556 >$at_check_line_file
   17463 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   17464 at_status=$?
   17465 grep '^ *+' $at_stder1 >&2
   17466 grep -v '^ *+' $at_stder1 >$at_stderr
   17467 at_failed=false
   17468 echo stderr:; tee stderr <$at_stderr
   17469 $at_diff $at_devnull $at_stdout || at_failed=:
   17470 case $at_status in
   17471    77) echo 77 > $at_status_file
   17472             exit 77;;
   17473    1) ;;
   17474    *) echo "calc.at:556: exit code was $at_status, expected 1"
   17475       at_failed=:;;
   17476 esac
   17477 if $at_failed; then
   17478 
   17479   echo 1 > $at_status_file
   17480   exit 1
   17481 fi
   17482 
   17483 $at_traceon
   17484 
   17485 
   17486 # Normalize the observed and expected error messages, depending upon the
   17487 # options.
   17488 # 1. Remove the traces from observed.
   17489 sed '/^Starting/d
   17490 /^Entering/d
   17491 /^Stack/d
   17492 /^Reading/d
   17493 /^Reducing/d
   17494 /^Shifting/d
   17495 /^state/d
   17496 /^Cleanup:/d
   17497 /^Error:/d
   17498 /^Next/d
   17499 /^Discarding/d
   17500 / \$[0-9$]* = /d
   17501 /^yydestructor:/d' stderr >at-stderr
   17502 mv at-stderr stderr
   17503 # 2. Create the reference error message.
   17504 cat >expout <<'_ATEOF'
   17505 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   17506 _ATEOF
   17507 
   17508 # 3. If locations are not used, remove them.
   17509 sed 's/^[-0-9.]*: //' expout >at-expout
   17510 mv at-expout expout
   17511 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   17512 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   17513 mv at-expout expout
   17514 # 5. Check
   17515 $at_traceoff
   17516 echo "calc.at:556: cat stderr"
   17517 echo calc.at:556 >$at_check_line_file
   17518 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   17519 at_status=$?
   17520 grep '^ *+' $at_stder1 >&2
   17521 grep -v '^ *+' $at_stder1 >$at_stderr
   17522 at_failed=false
   17523 $at_diff $at_devnull $at_stderr || at_failed=:
   17524 $at_diff expout $at_stdout || at_failed=:
   17525 case $at_status in
   17526    77) echo 77 > $at_status_file
   17527             exit 77;;
   17528    0) ;;
   17529    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17530       at_failed=:;;
   17531 esac
   17532 if $at_failed; then
   17533 
   17534   echo 1 > $at_status_file
   17535   exit 1
   17536 fi
   17537 
   17538 $at_traceon
   17539 
   17540 
   17541 cat >input <<'_ATEOF'
   17542 error
   17543 _ATEOF
   17544 
   17545 $at_traceoff
   17546 echo "calc.at:556: \$PREPARSER ./calc input"
   17547 echo calc.at:556 >$at_check_line_file
   17548 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   17549 at_status=$?
   17550 grep '^ *+' $at_stder1 >&2
   17551 grep -v '^ *+' $at_stder1 >$at_stderr
   17552 at_failed=false
   17553 echo stderr:; tee stderr <$at_stderr
   17554 $at_diff $at_devnull $at_stdout || at_failed=:
   17555 case $at_status in
   17556    77) echo 77 > $at_status_file
   17557             exit 77;;
   17558    1) ;;
   17559    *) echo "calc.at:556: exit code was $at_status, expected 1"
   17560       at_failed=:;;
   17561 esac
   17562 if $at_failed; then
   17563 
   17564   echo 1 > $at_status_file
   17565   exit 1
   17566 fi
   17567 
   17568 $at_traceon
   17569 
   17570 
   17571 # Normalize the observed and expected error messages, depending upon the
   17572 # options.
   17573 # 1. Remove the traces from observed.
   17574 sed '/^Starting/d
   17575 /^Entering/d
   17576 /^Stack/d
   17577 /^Reading/d
   17578 /^Reducing/d
   17579 /^Shifting/d
   17580 /^state/d
   17581 /^Cleanup:/d
   17582 /^Error:/d
   17583 /^Next/d
   17584 /^Discarding/d
   17585 / \$[0-9$]* = /d
   17586 /^yydestructor:/d' stderr >at-stderr
   17587 mv at-stderr stderr
   17588 # 2. Create the reference error message.
   17589 cat >expout <<'_ATEOF'
   17590 1.0: syntax error, unexpected $undefined
   17591 _ATEOF
   17592 
   17593 # 3. If locations are not used, remove them.
   17594 sed 's/^[-0-9.]*: //' expout >at-expout
   17595 mv at-expout expout
   17596 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   17597 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   17598 mv at-expout expout
   17599 # 5. Check
   17600 $at_traceoff
   17601 echo "calc.at:556: cat stderr"
   17602 echo calc.at:556 >$at_check_line_file
   17603 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   17604 at_status=$?
   17605 grep '^ *+' $at_stder1 >&2
   17606 grep -v '^ *+' $at_stder1 >$at_stderr
   17607 at_failed=false
   17608 $at_diff $at_devnull $at_stderr || at_failed=:
   17609 $at_diff expout $at_stdout || at_failed=:
   17610 case $at_status in
   17611    77) echo 77 > $at_status_file
   17612             exit 77;;
   17613    0) ;;
   17614    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17615       at_failed=:;;
   17616 esac
   17617 if $at_failed; then
   17618 
   17619   echo 1 > $at_status_file
   17620   exit 1
   17621 fi
   17622 
   17623 $at_traceon
   17624 
   17625 
   17626 cat >input <<'_ATEOF'
   17627 1 = 2 = 3
   17628 _ATEOF
   17629 
   17630 $at_traceoff
   17631 echo "calc.at:556: \$PREPARSER ./calc input"
   17632 echo calc.at:556 >$at_check_line_file
   17633 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   17634 at_status=$?
   17635 grep '^ *+' $at_stder1 >&2
   17636 grep -v '^ *+' $at_stder1 >$at_stderr
   17637 at_failed=false
   17638 echo stderr:; tee stderr <$at_stderr
   17639 $at_diff $at_devnull $at_stdout || at_failed=:
   17640 case $at_status in
   17641    77) echo 77 > $at_status_file
   17642             exit 77;;
   17643    1) ;;
   17644    *) echo "calc.at:556: exit code was $at_status, expected 1"
   17645       at_failed=:;;
   17646 esac
   17647 if $at_failed; then
   17648 
   17649   echo 1 > $at_status_file
   17650   exit 1
   17651 fi
   17652 
   17653 $at_traceon
   17654 
   17655 
   17656 # Normalize the observed and expected error messages, depending upon the
   17657 # options.
   17658 # 1. Remove the traces from observed.
   17659 sed '/^Starting/d
   17660 /^Entering/d
   17661 /^Stack/d
   17662 /^Reading/d
   17663 /^Reducing/d
   17664 /^Shifting/d
   17665 /^state/d
   17666 /^Cleanup:/d
   17667 /^Error:/d
   17668 /^Next/d
   17669 /^Discarding/d
   17670 / \$[0-9$]* = /d
   17671 /^yydestructor:/d' stderr >at-stderr
   17672 mv at-stderr stderr
   17673 # 2. Create the reference error message.
   17674 cat >expout <<'_ATEOF'
   17675 1.6: syntax error, unexpected '='
   17676 _ATEOF
   17677 
   17678 # 3. If locations are not used, remove them.
   17679 sed 's/^[-0-9.]*: //' expout >at-expout
   17680 mv at-expout expout
   17681 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   17682 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   17683 mv at-expout expout
   17684 # 5. Check
   17685 $at_traceoff
   17686 echo "calc.at:556: cat stderr"
   17687 echo calc.at:556 >$at_check_line_file
   17688 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   17689 at_status=$?
   17690 grep '^ *+' $at_stder1 >&2
   17691 grep -v '^ *+' $at_stder1 >$at_stderr
   17692 at_failed=false
   17693 $at_diff $at_devnull $at_stderr || at_failed=:
   17694 $at_diff expout $at_stdout || at_failed=:
   17695 case $at_status in
   17696    77) echo 77 > $at_status_file
   17697             exit 77;;
   17698    0) ;;
   17699    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17700       at_failed=:;;
   17701 esac
   17702 if $at_failed; then
   17703 
   17704   echo 1 > $at_status_file
   17705   exit 1
   17706 fi
   17707 
   17708 $at_traceon
   17709 
   17710 
   17711 cat >input <<'_ATEOF'
   17712 
   17713 +1
   17714 _ATEOF
   17715 
   17716 $at_traceoff
   17717 echo "calc.at:556: \$PREPARSER ./calc input"
   17718 echo calc.at:556 >$at_check_line_file
   17719 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   17720 at_status=$?
   17721 grep '^ *+' $at_stder1 >&2
   17722 grep -v '^ *+' $at_stder1 >$at_stderr
   17723 at_failed=false
   17724 echo stderr:; tee stderr <$at_stderr
   17725 $at_diff $at_devnull $at_stdout || at_failed=:
   17726 case $at_status in
   17727    77) echo 77 > $at_status_file
   17728             exit 77;;
   17729    1) ;;
   17730    *) echo "calc.at:556: exit code was $at_status, expected 1"
   17731       at_failed=:;;
   17732 esac
   17733 if $at_failed; then
   17734 
   17735   echo 1 > $at_status_file
   17736   exit 1
   17737 fi
   17738 
   17739 $at_traceon
   17740 
   17741 
   17742 # Normalize the observed and expected error messages, depending upon the
   17743 # options.
   17744 # 1. Remove the traces from observed.
   17745 sed '/^Starting/d
   17746 /^Entering/d
   17747 /^Stack/d
   17748 /^Reading/d
   17749 /^Reducing/d
   17750 /^Shifting/d
   17751 /^state/d
   17752 /^Cleanup:/d
   17753 /^Error:/d
   17754 /^Next/d
   17755 /^Discarding/d
   17756 / \$[0-9$]* = /d
   17757 /^yydestructor:/d' stderr >at-stderr
   17758 mv at-stderr stderr
   17759 # 2. Create the reference error message.
   17760 cat >expout <<'_ATEOF'
   17761 2.0: syntax error, unexpected '+'
   17762 _ATEOF
   17763 
   17764 # 3. If locations are not used, remove them.
   17765 sed 's/^[-0-9.]*: //' expout >at-expout
   17766 mv at-expout expout
   17767 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   17768 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   17769 mv at-expout expout
   17770 # 5. Check
   17771 $at_traceoff
   17772 echo "calc.at:556: cat stderr"
   17773 echo calc.at:556 >$at_check_line_file
   17774 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   17775 at_status=$?
   17776 grep '^ *+' $at_stder1 >&2
   17777 grep -v '^ *+' $at_stder1 >$at_stderr
   17778 at_failed=false
   17779 $at_diff $at_devnull $at_stderr || at_failed=:
   17780 $at_diff expout $at_stdout || at_failed=:
   17781 case $at_status in
   17782    77) echo 77 > $at_status_file
   17783             exit 77;;
   17784    0) ;;
   17785    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17786       at_failed=:;;
   17787 esac
   17788 if $at_failed; then
   17789 
   17790   echo 1 > $at_status_file
   17791   exit 1
   17792 fi
   17793 
   17794 $at_traceon
   17795 
   17796 
   17797 # Exercise error messages with EOF: work on an empty file.
   17798 $at_traceoff
   17799 echo "calc.at:556: \$PREPARSER ./calc /dev/null"
   17800 echo calc.at:556 >$at_check_line_file
   17801 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   17802 at_status=$?
   17803 grep '^ *+' $at_stder1 >&2
   17804 grep -v '^ *+' $at_stder1 >$at_stderr
   17805 at_failed=false
   17806 echo stderr:; tee stderr <$at_stderr
   17807 $at_diff $at_devnull $at_stdout || at_failed=:
   17808 case $at_status in
   17809    77) echo 77 > $at_status_file
   17810             exit 77;;
   17811    1) ;;
   17812    *) echo "calc.at:556: exit code was $at_status, expected 1"
   17813       at_failed=:;;
   17814 esac
   17815 if $at_failed; then
   17816 
   17817   echo 1 > $at_status_file
   17818   exit 1
   17819 fi
   17820 
   17821 $at_traceon
   17822 
   17823 
   17824 # Normalize the observed and expected error messages, depending upon the
   17825 # options.
   17826 # 1. Remove the traces from observed.
   17827 sed '/^Starting/d
   17828 /^Entering/d
   17829 /^Stack/d
   17830 /^Reading/d
   17831 /^Reducing/d
   17832 /^Shifting/d
   17833 /^state/d
   17834 /^Cleanup:/d
   17835 /^Error:/d
   17836 /^Next/d
   17837 /^Discarding/d
   17838 / \$[0-9$]* = /d
   17839 /^yydestructor:/d' stderr >at-stderr
   17840 mv at-stderr stderr
   17841 # 2. Create the reference error message.
   17842 cat >expout <<'_ATEOF'
   17843 1.0: syntax error, unexpected end of input
   17844 _ATEOF
   17845 
   17846 # 3. If locations are not used, remove them.
   17847 sed 's/^[-0-9.]*: //' expout >at-expout
   17848 mv at-expout expout
   17849 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   17850 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   17851 mv at-expout expout
   17852 # 5. Check
   17853 $at_traceoff
   17854 echo "calc.at:556: cat stderr"
   17855 echo calc.at:556 >$at_check_line_file
   17856 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   17857 at_status=$?
   17858 grep '^ *+' $at_stder1 >&2
   17859 grep -v '^ *+' $at_stder1 >$at_stderr
   17860 at_failed=false
   17861 $at_diff $at_devnull $at_stderr || at_failed=:
   17862 $at_diff expout $at_stdout || at_failed=:
   17863 case $at_status in
   17864    77) echo 77 > $at_status_file
   17865             exit 77;;
   17866    0) ;;
   17867    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17868       at_failed=:;;
   17869 esac
   17870 if $at_failed; then
   17871 
   17872   echo 1 > $at_status_file
   17873   exit 1
   17874 fi
   17875 
   17876 $at_traceon
   17877 
   17878 
   17879 
   17880 # Exercise the error token: without it, we die at the first error,
   17881 # hence be sure to
   17882 #
   17883 # - have several errors which exercise different shift/discardings
   17884 #   - (): nothing to pop, nothing to discard
   17885 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   17886 #   - (* * *): nothing to pop, a lot to discard
   17887 #   - (1 + 2 * *): some to pop and discard
   17888 #
   17889 # - test the action associated to `error'
   17890 #
   17891 # - check the look-ahead that triggers an error is not discarded
   17892 #   when we enter error recovery.  Below, the look-ahead causing the
   17893 #   first error is ")", which is needed to recover from the error and
   17894 #   produce the "0" that triggers the "0 != 1" error.
   17895 #
   17896 cat >input <<'_ATEOF'
   17897 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   17898 _ATEOF
   17899 
   17900 $at_traceoff
   17901 echo "calc.at:556: \$PREPARSER ./calc input"
   17902 echo calc.at:556 >$at_check_line_file
   17903 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   17904 at_status=$?
   17905 grep '^ *+' $at_stder1 >&2
   17906 grep -v '^ *+' $at_stder1 >$at_stderr
   17907 at_failed=false
   17908 echo stderr:; tee stderr <$at_stderr
   17909 $at_diff $at_devnull $at_stdout || at_failed=:
   17910 case $at_status in
   17911    77) echo 77 > $at_status_file
   17912             exit 77;;
   17913    0) ;;
   17914    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17915       at_failed=:;;
   17916 esac
   17917 if $at_failed; then
   17918 
   17919   echo 1 > $at_status_file
   17920   exit 1
   17921 fi
   17922 
   17923 $at_traceon
   17924 
   17925 
   17926 # Normalize the observed and expected error messages, depending upon the
   17927 # options.
   17928 # 1. Remove the traces from observed.
   17929 sed '/^Starting/d
   17930 /^Entering/d
   17931 /^Stack/d
   17932 /^Reading/d
   17933 /^Reducing/d
   17934 /^Shifting/d
   17935 /^state/d
   17936 /^Cleanup:/d
   17937 /^Error:/d
   17938 /^Next/d
   17939 /^Discarding/d
   17940 / \$[0-9$]* = /d
   17941 /^yydestructor:/d' stderr >at-stderr
   17942 mv at-stderr stderr
   17943 # 2. Create the reference error message.
   17944 cat >expout <<'_ATEOF'
   17945 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   17946 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   17947 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   17948 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   17949 calc: error: 4444 != 1
   17950 _ATEOF
   17951 
   17952 # 3. If locations are not used, remove them.
   17953 sed 's/^[-0-9.]*: //' expout >at-expout
   17954 mv at-expout expout
   17955 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   17956 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   17957 mv at-expout expout
   17958 # 5. Check
   17959 $at_traceoff
   17960 echo "calc.at:556: cat stderr"
   17961 echo calc.at:556 >$at_check_line_file
   17962 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   17963 at_status=$?
   17964 grep '^ *+' $at_stder1 >&2
   17965 grep -v '^ *+' $at_stder1 >$at_stderr
   17966 at_failed=false
   17967 $at_diff $at_devnull $at_stderr || at_failed=:
   17968 $at_diff expout $at_stdout || at_failed=:
   17969 case $at_status in
   17970    77) echo 77 > $at_status_file
   17971             exit 77;;
   17972    0) ;;
   17973    *) echo "calc.at:556: exit code was $at_status, expected 0"
   17974       at_failed=:;;
   17975 esac
   17976 if $at_failed; then
   17977 
   17978   echo 1 > $at_status_file
   17979   exit 1
   17980 fi
   17981 
   17982 $at_traceon
   17983 
   17984 
   17985 
   17986 # The same, but this time exercising explicitly triggered syntax errors.
   17987 # POSIX says the look-ahead causing the error should not be discarded.
   17988 cat >input <<'_ATEOF'
   17989 (!) + (0 0) = 1
   17990 _ATEOF
   17991 
   17992 $at_traceoff
   17993 echo "calc.at:556: \$PREPARSER ./calc input"
   17994 echo calc.at:556 >$at_check_line_file
   17995 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   17996 at_status=$?
   17997 grep '^ *+' $at_stder1 >&2
   17998 grep -v '^ *+' $at_stder1 >$at_stderr
   17999 at_failed=false
   18000 echo stderr:; tee stderr <$at_stderr
   18001 $at_diff $at_devnull $at_stdout || at_failed=:
   18002 case $at_status in
   18003    77) echo 77 > $at_status_file
   18004             exit 77;;
   18005    0) ;;
   18006    *) echo "calc.at:556: exit code was $at_status, expected 0"
   18007       at_failed=:;;
   18008 esac
   18009 if $at_failed; then
   18010 
   18011   echo 1 > $at_status_file
   18012   exit 1
   18013 fi
   18014 
   18015 $at_traceon
   18016 
   18017 
   18018 # Normalize the observed and expected error messages, depending upon the
   18019 # options.
   18020 # 1. Remove the traces from observed.
   18021 sed '/^Starting/d
   18022 /^Entering/d
   18023 /^Stack/d
   18024 /^Reading/d
   18025 /^Reducing/d
   18026 /^Shifting/d
   18027 /^state/d
   18028 /^Cleanup:/d
   18029 /^Error:/d
   18030 /^Next/d
   18031 /^Discarding/d
   18032 / \$[0-9$]* = /d
   18033 /^yydestructor:/d' stderr >at-stderr
   18034 mv at-stderr stderr
   18035 # 2. Create the reference error message.
   18036 cat >expout <<'_ATEOF'
   18037 1.9: syntax error, unexpected number
   18038 calc: error: 2222 != 1
   18039 _ATEOF
   18040 
   18041 # 3. If locations are not used, remove them.
   18042 sed 's/^[-0-9.]*: //' expout >at-expout
   18043 mv at-expout expout
   18044 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   18045 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   18046 mv at-expout expout
   18047 # 5. Check
   18048 $at_traceoff
   18049 echo "calc.at:556: cat stderr"
   18050 echo calc.at:556 >$at_check_line_file
   18051 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   18052 at_status=$?
   18053 grep '^ *+' $at_stder1 >&2
   18054 grep -v '^ *+' $at_stder1 >$at_stderr
   18055 at_failed=false
   18056 $at_diff $at_devnull $at_stderr || at_failed=:
   18057 $at_diff expout $at_stdout || at_failed=:
   18058 case $at_status in
   18059    77) echo 77 > $at_status_file
   18060             exit 77;;
   18061    0) ;;
   18062    *) echo "calc.at:556: exit code was $at_status, expected 0"
   18063       at_failed=:;;
   18064 esac
   18065 if $at_failed; then
   18066 
   18067   echo 1 > $at_status_file
   18068   exit 1
   18069 fi
   18070 
   18071 $at_traceon
   18072 
   18073 
   18074 cat >input <<'_ATEOF'
   18075 (- *) + (0 0) = 1
   18076 _ATEOF
   18077 
   18078 $at_traceoff
   18079 echo "calc.at:556: \$PREPARSER ./calc input"
   18080 echo calc.at:556 >$at_check_line_file
   18081 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   18082 at_status=$?
   18083 grep '^ *+' $at_stder1 >&2
   18084 grep -v '^ *+' $at_stder1 >$at_stderr
   18085 at_failed=false
   18086 echo stderr:; tee stderr <$at_stderr
   18087 $at_diff $at_devnull $at_stdout || at_failed=:
   18088 case $at_status in
   18089    77) echo 77 > $at_status_file
   18090             exit 77;;
   18091    0) ;;
   18092    *) echo "calc.at:556: exit code was $at_status, expected 0"
   18093       at_failed=:;;
   18094 esac
   18095 if $at_failed; then
   18096 
   18097   echo 1 > $at_status_file
   18098   exit 1
   18099 fi
   18100 
   18101 $at_traceon
   18102 
   18103 
   18104 # Normalize the observed and expected error messages, depending upon the
   18105 # options.
   18106 # 1. Remove the traces from observed.
   18107 sed '/^Starting/d
   18108 /^Entering/d
   18109 /^Stack/d
   18110 /^Reading/d
   18111 /^Reducing/d
   18112 /^Shifting/d
   18113 /^state/d
   18114 /^Cleanup:/d
   18115 /^Error:/d
   18116 /^Next/d
   18117 /^Discarding/d
   18118 / \$[0-9$]* = /d
   18119 /^yydestructor:/d' stderr >at-stderr
   18120 mv at-stderr stderr
   18121 # 2. Create the reference error message.
   18122 cat >expout <<'_ATEOF'
   18123 1.3: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   18124 1.11: syntax error, unexpected number
   18125 calc: error: 2222 != 1
   18126 _ATEOF
   18127 
   18128 # 3. If locations are not used, remove them.
   18129 sed 's/^[-0-9.]*: //' expout >at-expout
   18130 mv at-expout expout
   18131 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   18132 sed 's/syntax error, .*$/syntax error/' expout >at-expout
   18133 mv at-expout expout
   18134 # 5. Check
   18135 $at_traceoff
   18136 echo "calc.at:556: cat stderr"
   18137 echo calc.at:556 >$at_check_line_file
   18138 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   18139 at_status=$?
   18140 grep '^ *+' $at_stder1 >&2
   18141 grep -v '^ *+' $at_stder1 >$at_stderr
   18142 at_failed=false
   18143 $at_diff $at_devnull $at_stderr || at_failed=:
   18144 $at_diff expout $at_stdout || at_failed=:
   18145 case $at_status in
   18146    77) echo 77 > $at_status_file
   18147             exit 77;;
   18148    0) ;;
   18149    *) echo "calc.at:556: exit code was $at_status, expected 0"
   18150       at_failed=:;;
   18151 esac
   18152 if $at_failed; then
   18153 
   18154   echo 1 > $at_status_file
   18155   exit 1
   18156 fi
   18157 
   18158 $at_traceon
   18159 
   18160 
   18161 
   18162 
   18163 
   18164 
   18165 
   18166 
   18167 
   18168 
   18169 
   18170 
   18171 
   18172 
   18173 
   18174 
   18175 
   18176 
   18177 
   18178 
   18179 
   18180 
   18181 
   18182 
   18183       $at_traceoff
   18184       $at_times_p && times >$at_times_file
   18185     ) 5>&1 2>&1 | eval $at_tee_pipe
   18186     at_status=`cat $at_status_file`
   18187     ;;
   18188 
   18189   76 ) # 76. calc.at:557: Calculator %error-verbose
   18190     at_setup_line='calc.at:557'
   18191     at_desc='Calculator %error-verbose'
   18192     $at_quiet $ECHO_N " 76: Calculator %error-verbose                    $ECHO_C"
   18193     at_xfail=no
   18194     (
   18195       echo "76. calc.at:557: testing ..."
   18196       $at_traceon
   18197 
   18198 
   18199 
   18200 
   18201 
   18202 
   18203 
   18204 
   18205 # Using yacc.c?
   18206 
   18207 
   18208 
   18209 
   18210 
   18211 
   18212 
   18213 # yyerror receives the location if %location & %pure & (%glr or %parse-param).
   18214 
   18215 # yyerror always sees the locations (when activated), except if
   18216 # yacc & pure & !param.
   18217 
   18218 
   18219 # The interface is pure: either because %pure-parser, or because we
   18220 # are using the C++ parsers.
   18221 
   18222 
   18223 
   18224 
   18225 
   18226 
   18227 
   18228 
   18229 
   18230 
   18231 
   18232 
   18233 cat >calc.y <<'_ATEOF'
   18234 %{
   18235 #ifdef HAVE_CONFIG_H
   18236 # include <config.h>
   18237   /* We don't need perfect functions for these tests. */
   18238 # undef malloc
   18239 # undef memcmp
   18240 # undef realloc
   18241 #endif
   18242 %}
   18243 
   18244 /* Infix notation calculator--calc */
   18245 %error-verbose
   18246 
   18247 %{
   18248 #include <stdio.h>
   18249 
   18250 #include <stdlib.h>
   18251 #include <string.h>
   18252 #if HAVE_UNISTD_H
   18253 # include <unistd.h>
   18254 #else
   18255 # undef alarm
   18256 # define alarm(seconds) /* empty */
   18257 #endif
   18258 #include <ctype.h>
   18259 #define USE(Var)
   18260 
   18261 /* Exercise pre-prologue dependency to %union.  */
   18262 typedef int semantic_value;
   18263 
   18264 static semantic_value global_result = 0;
   18265 static int global_count = 0;
   18266 %}
   18267 
   18268 /* Exercise %union. */
   18269 %union
   18270 {
   18271   semantic_value ival;
   18272 };
   18273 
   18274 %{
   18275 static int power (int base, int exponent);
   18276 /* yyerror receives the location if:
   18277    - %location & %pure & %glr
   18278    - %location & %pure & %yacc & %parse-param. */
   18279 static void yyerror (
   18280 
   18281                      const char *s
   18282                      );
   18283 static int yylex (void);
   18284 static int get_char (void);
   18285 static void unget_char ( int c);
   18286 %}
   18287 
   18288 
   18289 
   18290 /* Bison Declarations */
   18291 %token CALC_EOF 0 "end of input"
   18292 %token <ival> NUM "number"
   18293 %type  <ival> exp
   18294 
   18295 %nonassoc '=' /* comparison	       */
   18296 %left '-' '+'
   18297 %left '*' '/'
   18298 %left NEG     /* negation--unary minus */
   18299 %right '^'    /* exponentiation        */
   18300 
   18301 /* Grammar follows */
   18302 %%
   18303 input:
   18304   line
   18305 | input line         {  }
   18306 ;
   18307 
   18308 line:
   18309   '\n'
   18310 | exp '\n'           { USE ($1); }
   18311 ;
   18312 
   18313 exp:
   18314   NUM                { $$ = $1;             }
   18315 | exp '=' exp
   18316   {
   18317     if ($1 != $3)
   18318       fprintf (stderr, "calc: error: %d != %d\n", $1, $3);
   18319     $$ = $1;
   18320   }
   18321 | exp '+' exp        { $$ = $1 + $3;        }
   18322 | exp '-' exp        { $$ = $1 - $3;        }
   18323 | exp '*' exp        { $$ = $1 * $3;        }
   18324 | exp '/' exp        { $$ = $1 / $3;        }
   18325 | '-' exp  %prec NEG { $$ = -$2;            }
   18326 | exp '^' exp        { $$ = power ($1, $3); }
   18327 | '(' exp ')'        { $$ = $2;             }
   18328 | '(' error ')'      { $$ = 1111;           }
   18329 | '!'                { $$ = 0; YYERROR;     }
   18330 | '-' error          { $$ = 0; YYERROR;     }
   18331 ;
   18332 %%
   18333 /* The input.  */
   18334 static FILE *input;
   18335 
   18336 static void
   18337 yyerror (
   18338 
   18339          const char *s)
   18340 {
   18341 
   18342 
   18343   fprintf (stderr, "%s\n", s);
   18344 }
   18345 
   18346 
   18347 
   18348 static int
   18349 get_char (void)
   18350 {
   18351   int res = getc (input);
   18352   ;
   18353 
   18354   return res;
   18355 }
   18356 
   18357 
   18358 static void
   18359 unget_char ( int c)
   18360 {
   18361   ;
   18362 
   18363   ungetc (c, input);
   18364 }
   18365 
   18366 static int
   18367 read_signed_integer (void)
   18368 {
   18369   int c = get_char ();
   18370   int sign = 1;
   18371   int n = 0;
   18372 
   18373   ;
   18374   if (c == '-')
   18375     {
   18376       c = get_char ();
   18377       sign = -1;
   18378     }
   18379 
   18380   while (isdigit (c))
   18381     {
   18382       n = 10 * n + (c - '0');
   18383       c = get_char ();
   18384     }
   18385 
   18386   unget_char ( c);
   18387 
   18388   return sign * n;
   18389 }
   18390 
   18391 
   18392 
   18393 /*---------------------------------------------------------------.
   18394 | Lexical analyzer returns an integer on the stack and the token |
   18395 | NUM, or the ASCII character read if not a number.  Skips all   |
   18396 | blanks and tabs, returns 0 for EOF.                            |
   18397 `---------------------------------------------------------------*/
   18398 
   18399 static int
   18400 yylex (void)
   18401 {
   18402   static int init = 1;
   18403   int c;
   18404 
   18405   if (init)
   18406     {
   18407       init = 0;
   18408 
   18409     }
   18410 
   18411 
   18412 
   18413   /* Skip white space.  */
   18414   while ((c = get_char ()) == ' ' || c == '\t')
   18415     {
   18416 
   18417     }
   18418 
   18419   /* process numbers   */
   18420   if (c == '.' || isdigit (c))
   18421     {
   18422       unget_char ( c);
   18423       (yylval).ival = read_signed_integer ();
   18424       return NUM;
   18425     }
   18426 
   18427   /* Return end-of-file.  */
   18428   if (c == EOF)
   18429     return CALC_EOF;
   18430 
   18431   /* Return single chars. */
   18432   return c;
   18433 }
   18434 
   18435 static int
   18436 power (int base, int exponent)
   18437 {
   18438   int res = 1;
   18439   if (exponent < 0)
   18440     exit (3);
   18441   for (/* Niente */; exponent; --exponent)
   18442     res *= base;
   18443   return res;
   18444 }
   18445 
   18446 
   18447 int
   18448 main (int argc, const char **argv)
   18449 {
   18450   semantic_value result = 0;
   18451   int count = 0;
   18452   int status;
   18453 
   18454   /* This used to be alarm (10), but that isn't enough time for
   18455      a July 1995 vintage DEC Alphastation 200 4/100 system,
   18456      according to Nelson H. F. Beebe.  100 seconds is enough.  */
   18457   alarm (100);
   18458 
   18459   if (argc == 2)
   18460     input = fopen (argv[1], "r");
   18461   else
   18462     input = stdin;
   18463 
   18464   if (!input)
   18465     {
   18466       perror (argv[1]);
   18467       return 3;
   18468     }
   18469 
   18470 
   18471   status = yyparse ();
   18472   if (global_result != result)
   18473     abort ();
   18474   if (global_count != count)
   18475     abort ();
   18476   return status;
   18477 }
   18478 _ATEOF
   18479 
   18480 
   18481 
   18482 
   18483 
   18484 $at_traceoff
   18485 echo "calc.at:557: bison -o calc.c calc.y"
   18486 echo calc.at:557 >$at_check_line_file
   18487 ( $at_traceon; bison -o calc.c calc.y ) >$at_stdout 2>$at_stder1
   18488 at_status=$?
   18489 grep '^ *+' $at_stder1 >&2
   18490 grep -v '^ *+' $at_stder1 >$at_stderr
   18491 at_failed=false
   18492 $at_diff $at_devnull $at_stderr || at_failed=:
   18493 $at_diff $at_devnull $at_stdout || at_failed=:
   18494 case $at_status in
   18495    77) echo 77 > $at_status_file
   18496             exit 77;;
   18497    0) ;;
   18498    *) echo "calc.at:557: exit code was $at_status, expected 0"
   18499       at_failed=:;;
   18500 esac
   18501 if $at_failed; then
   18502 
   18503   echo 1 > $at_status_file
   18504   exit 1
   18505 fi
   18506 
   18507 $at_traceon
   18508 
   18509    $at_traceoff
   18510 echo "calc.at:557: \$CC \$CFLAGS \$CPPFLAGS \$LDFLAGS -o calc calc.c \$LIBS"
   18511 echo calc.at:557 >$at_check_line_file
   18512 ( $at_traceon; $CC $CFLAGS $CPPFLAGS $LDFLAGS -o calc calc.c $LIBS ) >$at_stdout 2>$at_stder1
   18513 at_status=$?
   18514 grep '^ *+' $at_stder1 >&2
   18515 grep -v '^ *+' $at_stder1 >$at_stderr
   18516 at_failed=false
   18517 echo stderr:; cat $at_stderr
   18518 echo stdout:; cat $at_stdout
   18519 case $at_status in
   18520    77) echo 77 > $at_status_file
   18521             exit 77;;
   18522    0) ;;
   18523    *) echo "calc.at:557: exit code was $at_status, expected 0"
   18524       at_failed=:;;
   18525 esac
   18526 if $at_failed; then
   18527 
   18528   echo 1 > $at_status_file
   18529   exit 1
   18530 fi
   18531 
   18532 $at_traceon
   18533 
   18534 
   18535 # Test the priorities.
   18536 cat >input <<'_ATEOF'
   18537 1 + 2 * 3 = 7
   18538 1 + 2 * -3 = -5
   18539 
   18540 -1^2 = -1
   18541 (-1)^2 = 1
   18542 
   18543 ---1 = -1
   18544 
   18545 1 - 2 - 3 = -4
   18546 1 - (2 - 3) = 2
   18547 
   18548 2^2^3 = 256
   18549 (2^2)^3 = 64
   18550 _ATEOF
   18551 
   18552 $at_traceoff
   18553 echo "calc.at:557: \$PREPARSER ./calc input"
   18554 echo calc.at:557 >$at_check_line_file
   18555 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   18556 at_status=$?
   18557 grep '^ *+' $at_stder1 >&2
   18558 grep -v '^ *+' $at_stder1 >$at_stderr
   18559 at_failed=false
   18560 echo stderr:; tee stderr <$at_stderr
   18561 $at_diff $at_devnull $at_stdout || at_failed=:
   18562 case $at_status in
   18563    77) echo 77 > $at_status_file
   18564             exit 77;;
   18565    0) ;;
   18566    *) echo "calc.at:557: exit code was $at_status, expected 0"
   18567       at_failed=:;;
   18568 esac
   18569 if $at_failed; then
   18570 
   18571   echo 1 > $at_status_file
   18572   exit 1
   18573 fi
   18574 
   18575 $at_traceon
   18576 
   18577 
   18578 
   18579 # Some syntax errors.
   18580 cat >input <<'_ATEOF'
   18581 0 0
   18582 _ATEOF
   18583 
   18584 $at_traceoff
   18585 echo "calc.at:557: \$PREPARSER ./calc input"
   18586 echo calc.at:557 >$at_check_line_file
   18587 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   18588 at_status=$?
   18589 grep '^ *+' $at_stder1 >&2
   18590 grep -v '^ *+' $at_stder1 >$at_stderr
   18591 at_failed=false
   18592 echo stderr:; tee stderr <$at_stderr
   18593 $at_diff $at_devnull $at_stdout || at_failed=:
   18594 case $at_status in
   18595    77) echo 77 > $at_status_file
   18596             exit 77;;
   18597    1) ;;
   18598    *) echo "calc.at:557: exit code was $at_status, expected 1"
   18599       at_failed=:;;
   18600 esac
   18601 if $at_failed; then
   18602 
   18603   echo 1 > $at_status_file
   18604   exit 1
   18605 fi
   18606 
   18607 $at_traceon
   18608 
   18609 
   18610 # Normalize the observed and expected error messages, depending upon the
   18611 # options.
   18612 # 1. Remove the traces from observed.
   18613 sed '/^Starting/d
   18614 /^Entering/d
   18615 /^Stack/d
   18616 /^Reading/d
   18617 /^Reducing/d
   18618 /^Shifting/d
   18619 /^state/d
   18620 /^Cleanup:/d
   18621 /^Error:/d
   18622 /^Next/d
   18623 /^Discarding/d
   18624 / \$[0-9$]* = /d
   18625 /^yydestructor:/d' stderr >at-stderr
   18626 mv at-stderr stderr
   18627 # 2. Create the reference error message.
   18628 cat >expout <<'_ATEOF'
   18629 1.2: syntax error, unexpected number
   18630 _ATEOF
   18631 
   18632 # 3. If locations are not used, remove them.
   18633 sed 's/^[-0-9.]*: //' expout >at-expout
   18634 mv at-expout expout
   18635 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   18636 
   18637 # 5. Check
   18638 $at_traceoff
   18639 echo "calc.at:557: cat stderr"
   18640 echo calc.at:557 >$at_check_line_file
   18641 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   18642 at_status=$?
   18643 grep '^ *+' $at_stder1 >&2
   18644 grep -v '^ *+' $at_stder1 >$at_stderr
   18645 at_failed=false
   18646 $at_diff $at_devnull $at_stderr || at_failed=:
   18647 $at_diff expout $at_stdout || at_failed=:
   18648 case $at_status in
   18649    77) echo 77 > $at_status_file
   18650             exit 77;;
   18651    0) ;;
   18652    *) echo "calc.at:557: exit code was $at_status, expected 0"
   18653       at_failed=:;;
   18654 esac
   18655 if $at_failed; then
   18656 
   18657   echo 1 > $at_status_file
   18658   exit 1
   18659 fi
   18660 
   18661 $at_traceon
   18662 
   18663 
   18664 cat >input <<'_ATEOF'
   18665 1//2
   18666 _ATEOF
   18667 
   18668 $at_traceoff
   18669 echo "calc.at:557: \$PREPARSER ./calc input"
   18670 echo calc.at:557 >$at_check_line_file
   18671 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   18672 at_status=$?
   18673 grep '^ *+' $at_stder1 >&2
   18674 grep -v '^ *+' $at_stder1 >$at_stderr
   18675 at_failed=false
   18676 echo stderr:; tee stderr <$at_stderr
   18677 $at_diff $at_devnull $at_stdout || at_failed=:
   18678 case $at_status in
   18679    77) echo 77 > $at_status_file
   18680             exit 77;;
   18681    1) ;;
   18682    *) echo "calc.at:557: exit code was $at_status, expected 1"
   18683       at_failed=:;;
   18684 esac
   18685 if $at_failed; then
   18686 
   18687   echo 1 > $at_status_file
   18688   exit 1
   18689 fi
   18690 
   18691 $at_traceon
   18692 
   18693 
   18694 # Normalize the observed and expected error messages, depending upon the
   18695 # options.
   18696 # 1. Remove the traces from observed.
   18697 sed '/^Starting/d
   18698 /^Entering/d
   18699 /^Stack/d
   18700 /^Reading/d
   18701 /^Reducing/d
   18702 /^Shifting/d
   18703 /^state/d
   18704 /^Cleanup:/d
   18705 /^Error:/d
   18706 /^Next/d
   18707 /^Discarding/d
   18708 / \$[0-9$]* = /d
   18709 /^yydestructor:/d' stderr >at-stderr
   18710 mv at-stderr stderr
   18711 # 2. Create the reference error message.
   18712 cat >expout <<'_ATEOF'
   18713 1.2: syntax error, unexpected '/', expecting number or '-' or '(' or '!'
   18714 _ATEOF
   18715 
   18716 # 3. If locations are not used, remove them.
   18717 sed 's/^[-0-9.]*: //' expout >at-expout
   18718 mv at-expout expout
   18719 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   18720 
   18721 # 5. Check
   18722 $at_traceoff
   18723 echo "calc.at:557: cat stderr"
   18724 echo calc.at:557 >$at_check_line_file
   18725 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   18726 at_status=$?
   18727 grep '^ *+' $at_stder1 >&2
   18728 grep -v '^ *+' $at_stder1 >$at_stderr
   18729 at_failed=false
   18730 $at_diff $at_devnull $at_stderr || at_failed=:
   18731 $at_diff expout $at_stdout || at_failed=:
   18732 case $at_status in
   18733    77) echo 77 > $at_status_file
   18734             exit 77;;
   18735    0) ;;
   18736    *) echo "calc.at:557: exit code was $at_status, expected 0"
   18737       at_failed=:;;
   18738 esac
   18739 if $at_failed; then
   18740 
   18741   echo 1 > $at_status_file
   18742   exit 1
   18743 fi
   18744 
   18745 $at_traceon
   18746 
   18747 
   18748 cat >input <<'_ATEOF'
   18749 error
   18750 _ATEOF
   18751 
   18752 $at_traceoff
   18753 echo "calc.at:557: \$PREPARSER ./calc input"
   18754 echo calc.at:557 >$at_check_line_file
   18755 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   18756 at_status=$?
   18757 grep '^ *+' $at_stder1 >&2
   18758 grep -v '^ *+' $at_stder1 >$at_stderr
   18759 at_failed=false
   18760 echo stderr:; tee stderr <$at_stderr
   18761 $at_diff $at_devnull $at_stdout || at_failed=:
   18762 case $at_status in
   18763    77) echo 77 > $at_status_file
   18764             exit 77;;
   18765    1) ;;
   18766    *) echo "calc.at:557: exit code was $at_status, expected 1"
   18767       at_failed=:;;
   18768 esac
   18769 if $at_failed; then
   18770 
   18771   echo 1 > $at_status_file
   18772   exit 1
   18773 fi
   18774 
   18775 $at_traceon
   18776 
   18777 
   18778 # Normalize the observed and expected error messages, depending upon the
   18779 # options.
   18780 # 1. Remove the traces from observed.
   18781 sed '/^Starting/d
   18782 /^Entering/d
   18783 /^Stack/d
   18784 /^Reading/d
   18785 /^Reducing/d
   18786 /^Shifting/d
   18787 /^state/d
   18788 /^Cleanup:/d
   18789 /^Error:/d
   18790 /^Next/d
   18791 /^Discarding/d
   18792 / \$[0-9$]* = /d
   18793 /^yydestructor:/d' stderr >at-stderr
   18794 mv at-stderr stderr
   18795 # 2. Create the reference error message.
   18796 cat >expout <<'_ATEOF'
   18797 1.0: syntax error, unexpected $undefined
   18798 _ATEOF
   18799 
   18800 # 3. If locations are not used, remove them.
   18801 sed 's/^[-0-9.]*: //' expout >at-expout
   18802 mv at-expout expout
   18803 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   18804 
   18805 # 5. Check
   18806 $at_traceoff
   18807 echo "calc.at:557: cat stderr"
   18808 echo calc.at:557 >$at_check_line_file
   18809 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   18810 at_status=$?
   18811 grep '^ *+' $at_stder1 >&2
   18812 grep -v '^ *+' $at_stder1 >$at_stderr
   18813 at_failed=false
   18814 $at_diff $at_devnull $at_stderr || at_failed=:
   18815 $at_diff expout $at_stdout || at_failed=:
   18816 case $at_status in
   18817    77) echo 77 > $at_status_file
   18818             exit 77;;
   18819    0) ;;
   18820    *) echo "calc.at:557: exit code was $at_status, expected 0"
   18821       at_failed=:;;
   18822 esac
   18823 if $at_failed; then
   18824 
   18825   echo 1 > $at_status_file
   18826   exit 1
   18827 fi
   18828 
   18829 $at_traceon
   18830 
   18831 
   18832 cat >input <<'_ATEOF'
   18833 1 = 2 = 3
   18834 _ATEOF
   18835 
   18836 $at_traceoff
   18837 echo "calc.at:557: \$PREPARSER ./calc input"
   18838 echo calc.at:557 >$at_check_line_file
   18839 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   18840 at_status=$?
   18841 grep '^ *+' $at_stder1 >&2
   18842 grep -v '^ *+' $at_stder1 >$at_stderr
   18843 at_failed=false
   18844 echo stderr:; tee stderr <$at_stderr
   18845 $at_diff $at_devnull $at_stdout || at_failed=:
   18846 case $at_status in
   18847    77) echo 77 > $at_status_file
   18848             exit 77;;
   18849    1) ;;
   18850    *) echo "calc.at:557: exit code was $at_status, expected 1"
   18851       at_failed=:;;
   18852 esac
   18853 if $at_failed; then
   18854 
   18855   echo 1 > $at_status_file
   18856   exit 1
   18857 fi
   18858 
   18859 $at_traceon
   18860 
   18861 
   18862 # Normalize the observed and expected error messages, depending upon the
   18863 # options.
   18864 # 1. Remove the traces from observed.
   18865 sed '/^Starting/d
   18866 /^Entering/d
   18867 /^Stack/d
   18868 /^Reading/d
   18869 /^Reducing/d
   18870 /^Shifting/d
   18871 /^state/d
   18872 /^Cleanup:/d
   18873 /^Error:/d
   18874 /^Next/d
   18875 /^Discarding/d
   18876 / \$[0-9$]* = /d
   18877 /^yydestructor:/d' stderr >at-stderr
   18878 mv at-stderr stderr
   18879 # 2. Create the reference error message.
   18880 cat >expout <<'_ATEOF'
   18881 1.6: syntax error, unexpected '='
   18882 _ATEOF
   18883 
   18884 # 3. If locations are not used, remove them.
   18885 sed 's/^[-0-9.]*: //' expout >at-expout
   18886 mv at-expout expout
   18887 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   18888 
   18889 # 5. Check
   18890 $at_traceoff
   18891 echo "calc.at:557: cat stderr"
   18892 echo calc.at:557 >$at_check_line_file
   18893 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   18894 at_status=$?
   18895 grep '^ *+' $at_stder1 >&2
   18896 grep -v '^ *+' $at_stder1 >$at_stderr
   18897 at_failed=false
   18898 $at_diff $at_devnull $at_stderr || at_failed=:
   18899 $at_diff expout $at_stdout || at_failed=:
   18900 case $at_status in
   18901    77) echo 77 > $at_status_file
   18902             exit 77;;
   18903    0) ;;
   18904    *) echo "calc.at:557: exit code was $at_status, expected 0"
   18905       at_failed=:;;
   18906 esac
   18907 if $at_failed; then
   18908 
   18909   echo 1 > $at_status_file
   18910   exit 1
   18911 fi
   18912 
   18913 $at_traceon
   18914 
   18915 
   18916 cat >input <<'_ATEOF'
   18917 
   18918 +1
   18919 _ATEOF
   18920 
   18921 $at_traceoff
   18922 echo "calc.at:557: \$PREPARSER ./calc input"
   18923 echo calc.at:557 >$at_check_line_file
   18924 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   18925 at_status=$?
   18926 grep '^ *+' $at_stder1 >&2
   18927 grep -v '^ *+' $at_stder1 >$at_stderr
   18928 at_failed=false
   18929 echo stderr:; tee stderr <$at_stderr
   18930 $at_diff $at_devnull $at_stdout || at_failed=:
   18931 case $at_status in
   18932    77) echo 77 > $at_status_file
   18933             exit 77;;
   18934    1) ;;
   18935    *) echo "calc.at:557: exit code was $at_status, expected 1"
   18936       at_failed=:;;
   18937 esac
   18938 if $at_failed; then
   18939 
   18940   echo 1 > $at_status_file
   18941   exit 1
   18942 fi
   18943 
   18944 $at_traceon
   18945 
   18946 
   18947 # Normalize the observed and expected error messages, depending upon the
   18948 # options.
   18949 # 1. Remove the traces from observed.
   18950 sed '/^Starting/d
   18951 /^Entering/d
   18952 /^Stack/d
   18953 /^Reading/d
   18954 /^Reducing/d
   18955 /^Shifting/d
   18956 /^state/d
   18957 /^Cleanup:/d
   18958 /^Error:/d
   18959 /^Next/d
   18960 /^Discarding/d
   18961 / \$[0-9$]* = /d
   18962 /^yydestructor:/d' stderr >at-stderr
   18963 mv at-stderr stderr
   18964 # 2. Create the reference error message.
   18965 cat >expout <<'_ATEOF'
   18966 2.0: syntax error, unexpected '+'
   18967 _ATEOF
   18968 
   18969 # 3. If locations are not used, remove them.
   18970 sed 's/^[-0-9.]*: //' expout >at-expout
   18971 mv at-expout expout
   18972 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   18973 
   18974 # 5. Check
   18975 $at_traceoff
   18976 echo "calc.at:557: cat stderr"
   18977 echo calc.at:557 >$at_check_line_file
   18978 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   18979 at_status=$?
   18980 grep '^ *+' $at_stder1 >&2
   18981 grep -v '^ *+' $at_stder1 >$at_stderr
   18982 at_failed=false
   18983 $at_diff $at_devnull $at_stderr || at_failed=:
   18984 $at_diff expout $at_stdout || at_failed=:
   18985 case $at_status in
   18986    77) echo 77 > $at_status_file
   18987             exit 77;;
   18988    0) ;;
   18989    *) echo "calc.at:557: exit code was $at_status, expected 0"
   18990       at_failed=:;;
   18991 esac
   18992 if $at_failed; then
   18993 
   18994   echo 1 > $at_status_file
   18995   exit 1
   18996 fi
   18997 
   18998 $at_traceon
   18999 
   19000 
   19001 # Exercise error messages with EOF: work on an empty file.
   19002 $at_traceoff
   19003 echo "calc.at:557: \$PREPARSER ./calc /dev/null"
   19004 echo calc.at:557 >$at_check_line_file
   19005 ( $at_traceon; $PREPARSER ./calc /dev/null ) >$at_stdout 2>$at_stder1
   19006 at_status=$?
   19007 grep '^ *+' $at_stder1 >&2
   19008 grep -v '^ *+' $at_stder1 >$at_stderr
   19009 at_failed=false
   19010 echo stderr:; tee stderr <$at_stderr
   19011 $at_diff $at_devnull $at_stdout || at_failed=:
   19012 case $at_status in
   19013    77) echo 77 > $at_status_file
   19014             exit 77;;
   19015    1) ;;
   19016    *) echo "calc.at:557: exit code was $at_status, expected 1"
   19017       at_failed=:;;
   19018 esac
   19019 if $at_failed; then
   19020 
   19021   echo 1 > $at_status_file
   19022   exit 1
   19023 fi
   19024 
   19025 $at_traceon
   19026 
   19027 
   19028 # Normalize the observed and expected error messages, depending upon the
   19029 # options.
   19030 # 1. Remove the traces from observed.
   19031 sed '/^Starting/d
   19032 /^Entering/d
   19033 /^Stack/d
   19034 /^Reading/d
   19035 /^Reducing/d
   19036 /^Shifting/d
   19037 /^state/d
   19038 /^Cleanup:/d
   19039 /^Error:/d
   19040 /^Next/d
   19041 /^Discarding/d
   19042 / \$[0-9$]* = /d
   19043 /^yydestructor:/d' stderr >at-stderr
   19044 mv at-stderr stderr
   19045 # 2. Create the reference error message.
   19046 cat >expout <<'_ATEOF'
   19047 1.0: syntax error, unexpected end of input
   19048 _ATEOF
   19049 
   19050 # 3. If locations are not used, remove them.
   19051 sed 's/^[-0-9.]*: //' expout >at-expout
   19052 mv at-expout expout
   19053 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   19054 
   19055 # 5. Check
   19056 $at_traceoff
   19057 echo "calc.at:557: cat stderr"
   19058 echo calc.at:557 >$at_check_line_file
   19059 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   19060 at_status=$?
   19061 grep '^ *+' $at_stder1 >&2
   19062 grep -v '^ *+' $at_stder1 >$at_stderr
   19063 at_failed=false
   19064 $at_diff $at_devnull $at_stderr || at_failed=:
   19065 $at_diff expout $at_stdout || at_failed=:
   19066 case $at_status in
   19067    77) echo 77 > $at_status_file
   19068             exit 77;;
   19069    0) ;;
   19070    *) echo "calc.at:557: exit code was $at_status, expected 0"
   19071       at_failed=:;;
   19072 esac
   19073 if $at_failed; then
   19074 
   19075   echo 1 > $at_status_file
   19076   exit 1
   19077 fi
   19078 
   19079 $at_traceon
   19080 
   19081 
   19082 
   19083 # Exercise the error token: without it, we die at the first error,
   19084 # hence be sure to
   19085 #
   19086 # - have several errors which exercise different shift/discardings
   19087 #   - (): nothing to pop, nothing to discard
   19088 #   - (1 + 1 + 1 +): a lot to pop, nothing to discard
   19089 #   - (* * *): nothing to pop, a lot to discard
   19090 #   - (1 + 2 * *): some to pop and discard
   19091 #
   19092 # - test the action associated to `error'
   19093 #
   19094 # - check the look-ahead that triggers an error is not discarded
   19095 #   when we enter error recovery.  Below, the look-ahead causing the
   19096 #   first error is ")", which is needed to recover from the error and
   19097 #   produce the "0" that triggers the "0 != 1" error.
   19098 #
   19099 cat >input <<'_ATEOF'
   19100 () + (1 + 1 + 1 +) + (* * *) + (1 * 2 * *) = 1
   19101 _ATEOF
   19102 
   19103 $at_traceoff
   19104 echo "calc.at:557: \$PREPARSER ./calc input"
   19105 echo calc.at:557 >$at_check_line_file
   19106 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   19107 at_status=$?
   19108 grep '^ *+' $at_stder1 >&2
   19109 grep -v '^ *+' $at_stder1 >$at_stderr
   19110 at_failed=false
   19111 echo stderr:; tee stderr <$at_stderr
   19112 $at_diff $at_devnull $at_stdout || at_failed=:
   19113 case $at_status in
   19114    77) echo 77 > $at_status_file
   19115             exit 77;;
   19116    0) ;;
   19117    *) echo "calc.at:557: exit code was $at_status, expected 0"
   19118       at_failed=:;;
   19119 esac
   19120 if $at_failed; then
   19121 
   19122   echo 1 > $at_status_file
   19123   exit 1
   19124 fi
   19125 
   19126 $at_traceon
   19127 
   19128 
   19129 # Normalize the observed and expected error messages, depending upon the
   19130 # options.
   19131 # 1. Remove the traces from observed.
   19132 sed '/^Starting/d
   19133 /^Entering/d
   19134 /^Stack/d
   19135 /^Reading/d
   19136 /^Reducing/d
   19137 /^Shifting/d
   19138 /^state/d
   19139 /^Cleanup:/d
   19140 /^Error:/d
   19141 /^Next/d
   19142 /^Discarding/d
   19143 / \$[0-9$]* = /d
   19144 /^yydestructor:/d' stderr >at-stderr
   19145 mv at-stderr stderr
   19146 # 2. Create the reference error message.
   19147 cat >expout <<'_ATEOF'
   19148 1.1: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   19149 1.17: syntax error, unexpected ')', expecting number or '-' or '(' or '!'
   19150 1.22: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   19151 1.40: syntax error, unexpected '*', expecting number or '-' or '(' or '!'
   19152 calc: error: 4444 != 1
   19153 _ATEOF
   19154 
   19155 # 3. If locations are not used, remove them.
   19156 sed 's/^[-0-9.]*: //' expout >at-expout
   19157 mv at-expout expout
   19158 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   19159 
   19160 # 5. Check
   19161 $at_traceoff
   19162 echo "calc.at:557: cat stderr"
   19163 echo calc.at:557 >$at_check_line_file
   19164 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   19165 at_status=$?
   19166 grep '^ *+' $at_stder1 >&2
   19167 grep -v '^ *+' $at_stder1 >$at_stderr
   19168 at_failed=false
   19169 $at_diff $at_devnull $at_stderr || at_failed=:
   19170 $at_diff expout $at_stdout || at_failed=:
   19171 case $at_status in
   19172    77) echo 77 > $at_status_file
   19173             exit 77;;
   19174    0) ;;
   19175    *) echo "calc.at:557: exit code was $at_status, expected 0"
   19176       at_failed=:;;
   19177 esac
   19178 if $at_failed; then
   19179 
   19180   echo 1 > $at_status_file
   19181   exit 1
   19182 fi
   19183 
   19184 $at_traceon
   19185 
   19186 
   19187 
   19188 # The same, but this time exercising explicitly triggered syntax errors.
   19189 # POSIX says the look-ahead causing the error should not be discarded.
   19190 cat >input <<'_ATEOF'
   19191 (!) + (0 0) = 1
   19192 _ATEOF
   19193 
   19194 $at_traceoff
   19195 echo "calc.at:557: \$PREPARSER ./calc input"
   19196 echo calc.at:557 >$at_check_line_file
   19197 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   19198 at_status=$?
   19199 grep '^ *+' $at_stder1 >&2
   19200 grep -v '^ *+' $at_stder1 >$at_stderr
   19201 at_failed=false
   19202 echo stderr:; tee stderr <$at_stderr
   19203 $at_diff $at_devnull $at_stdout || at_failed=:
   19204 case $at_status in
   19205    77) echo 77 > $at_status_file
   19206             exit 77;;
   19207    0) ;;
   19208    *) echo "calc.at:557: exit code was $at_status, expected 0"
   19209       at_failed=:;;
   19210 esac
   19211 if $at_failed; then
   19212 
   19213   echo 1 > $at_status_file
   19214   exit 1
   19215 fi
   19216 
   19217 $at_traceon
   19218 
   19219 
   19220 # Normalize the observed and expected error messages, depending upon the
   19221 # options.
   19222 # 1. Remove the traces from observed.
   19223 sed '/^Starting/d
   19224 /^Entering/d
   19225 /^Stack/d
   19226 /^Reading/d
   19227 /^Reducing/d
   19228 /^Shifting/d
   19229 /^state/d
   19230 /^Cleanup:/d
   19231 /^Error:/d
   19232 /^Next/d
   19233 /^Discarding/d
   19234 / \$[0-9$]* = /d
   19235 /^yydestructor:/d' stderr >at-stderr
   19236 mv at-stderr stderr
   19237 # 2. Create the reference error message.
   19238 cat >expout <<'_ATEOF'
   19239 1.9: syntax error, unexpected number
   19240 calc: error: 2222 != 1
   19241 _ATEOF
   19242 
   19243 # 3. If locations are not used, remove them.
   19244 sed 's/^[-0-9.]*: //' expout >at-expout
   19245 mv at-expout expout
   19246 # 4. If error-verbose is not used, strip the`, unexpected....' part.
   19247 
   19248 # 5. Check
   19249 $at_traceoff
   19250 echo "calc.at:557: cat stderr"
   19251 echo calc.at:557 >$at_check_line_file
   19252 ( $at_traceon; cat stderr ) >$at_stdout 2>$at_stder1
   19253 at_status=$?
   19254 grep '^ *+' $at_stder1 >&2
   19255 grep -v '^ *+' $at_stder1 >$at_stderr
   19256 at_failed=false
   19257 $at_diff $at_devnull $at_stderr || at_failed=:
   19258 $at_diff expout $at_stdout || at_failed=:
   19259 case $at_status in
   19260    77) echo 77 > $at_status_file
   19261             exit 77;;
   19262    0) ;;
   19263    *) echo "calc.at:557: exit code was $at_status, expected 0"
   19264       at_failed=:;;
   19265 esac
   19266 if $at_failed; then
   19267 
   19268   echo 1 > $at_status_file
   19269   exit 1
   19270 fi
   19271 
   19272 $at_traceon
   19273 
   19274 
   19275 cat >input <<'_ATEOF'
   19276 (- *) + (0 0) = 1
   19277 _ATEOF
   19278 
   19279 $at_traceoff
   19280 echo "calc.at:557: \$PREPARSER ./calc input"
   19281 echo calc.at:557 >$at_check_line_file
   19282 ( $at_traceon; $PREPARSER ./calc input ) >$at_stdout 2>$at_stder1
   19283 at_status=$?
   19284 grep '^ *+' $at_stder1 >&2
   19285 grep -v '^ *+' $at_stder1 >$at_stderr
   19286 at_failed=false
   19287 echo stderr:; tee stderr <$at_stderr
   19288 $at_diff $at_devnull $at_stdout || at_failed=:
   19289 case $at_status in
   19290    77) echo 77 > $at_status_file
   19291             exit 77;;
   19292    0) ;;
   19293    *) echo "calc.at:557: exit code was $at_status, expected 0"
   19294       at_failed=:;;
   19295 esac
   19296 if $at_failed; then
   19297 
   19298   echo 1 > $at_status_file
   19299   exit 1
   19300 fi
   19301 
   19302 $at_traceon
   19303 
   19304 
   19305 # Normalize the observed and expected error messages, depending upon the
   19306 # options.
   19307 # 1. Remove the traces from observed.<